Skip to content

Instantly share code, notes, and snippets.

@daneshk
Last active August 18, 2021 04:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daneshk/e0ab3bf320be516a306b2e8d4997203a to your computer and use it in GitHub Desktop.
Save daneshk/e0ab3bf320be516a306b2e8d4997203a to your computer and use it in GitHub Desktop.
service "RouteGuide" on new grpc:Listener(8980) {
remote function ListFeatures(Rectangle rectangle) returns stream<Feature, grpc:Error?>|error {
int left = int:min(rectangle.lo.longitude, rectangle.hi.longitude);
int right = int:max(rectangle.lo.longitude, rectangle.hi.longitude);
int top = int:max(rectangle.lo.latitude, rectangle.hi.latitude);
int bottom = int:min(rectangle.lo.latitude, rectangle.hi.latitude);
Feature[] selectedFeatures = from var feature in FEATURES
where feature.name != ""
where feature.location.longitude >= left
where feature.location.longitude <= right
where feature.location.latitude >= bottom
where feature.location.latitude <= top
select feature;
return selectedFeatures.toStream();
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment