Created
July 27, 2018 18:33
-
-
Save autodidaddict/c69593e91986a58584fe89153a36f22f to your computer and use it in GitHub Desktop.
gRPC Ballerina Blog Posts - 2
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
@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