Skip to content

Instantly share code, notes, and snippets.

@autodidaddict
Created July 27, 2018 18:33
Show Gist options
  • Save autodidaddict/c69593e91986a58584fe89153a36f22f to your computer and use it in GitHub Desktop.
Save autodidaddict/c69593e91986a58584fe89153a36f22f to your computer and use it in GitHub Desktop.
gRPC Ballerina Blog Posts - 2
@grpc:ServiceConfig
service DroneMgmt bind listener {
GetDrone(endpoint caller, string droneId) {
DroneInfo info = dronesMap[droneId] but { ()=>{} };
_ = caller->send(info);
_ = caller->complete();
}
AddDrone(endpoint caller, DroneInfo droneReq) {
string droneId = droneReq.id;
dronesMap[droneId] = droneReq;
DroneInfo info = dronesMap[droneId] but { () => {} };
_ = caller->send(info);
_ = caller->complete();
}
UpdateDrone(endpoint caller, DroneInfo updateReq) {
string droneId = updateReq.id;
DroneInfo info;
if (dronesMap.hasKey(droneId)) {
dronesMap[droneId] = updateReq;
info = updateReq;
} else {
info = {};
}
_ = caller->send(info);
_ = caller->complete();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment