Skip to content

Instantly share code, notes, and snippets.

@autodidaddict
Created July 27, 2018 18:35
Show Gist options
  • Save autodidaddict/e73318f340da4ed2b2b71887b44cb494 to your computer and use it in GitHub Desktop.
Save autodidaddict/e73318f340da4ed2b2b71887b44cb494 to your computer and use it in GitHub Desktop.
gRPC Ballerina Blog Posts - 4
import ballerina/io;
import ballerina/log;
import ballerina/grpc;
function main(string... args) {
endpoint DroneMgmtBlockingClient droneMgmtBlockingEp {
url: "http://localhost:9090"
};
DroneInfo req = {battery_remaining: 12, id: "DRONE1",
name: "Drone One"};
var addResponse = droneMgmtBlockingEp->AddDrone(req);
match addResponse {
(DroneInfo, grpc:Headers) payload => {
DroneInfo drone;
grpc:Headers headers;
(drone, headers) = payload;
log:printInfo("Drone " + drone.id + " added.");
}
error err => {
log:printError("Failed to add drone: " + err.message + "\n");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment