Created
July 27, 2018 18:35
-
-
Save autodidaddict/e73318f340da4ed2b2b71887b44cb494 to your computer and use it in GitHub Desktop.
gRPC Ballerina Blog Posts - 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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