geoplay

command module
v0.0.0-...-943c59f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2017 License: MIT Imports: 23 Imported by: 0

README

Toy grpc server and client in Go.

Toy server accepts RPCs with latitude/longitude and returns the 10 nearest Starbucks locations.

GoDoc Go Report Card

Install, run, request

go get -u github.com/jamessanford/geoplay
geoplay &
geoplay -client -loc=37.486,-122.232

Included endpoints

A letmegrpc HTTP handler is at http://localhost:6796/GeoLookup/Lookup

Prometheus metrics with go-grpc-prometheus support are at http://localhost:6796/metrics

grpc is on port 6797 by default (-grpc.addr flag)

grpc uses x/net/trace by default, check out http://localhost:6796/debug/requests and http://localhost:6796/debug/events after making some RPCs.

grpc reflection is enabled, try grpc_cli:

grpc_cli call localhost:6797 latlonpb.GeoLookup.Lookup 'lat:37.486 lon:-122.232'

Suggestions

Instead of "rolling your own" this way, there are various "microservice helpers", and you probably want to use one or make a standard one for your organization.

The data/locations.json file came from https://github.com/mmcloughlin/starbucks

Documentation

Overview

geoplay is a toy grpc server and client. It returns up to 10 nearest Starbucks locations when given a latitude/longitude.

CLIENT MODE

When used with the -client flag, it dials the server and displays results on standard output.

geoplay -client
geoplay -client -loc=37.486,-122.232 # Redwood City, CA
geoplay -client -loc=37,122 # China

SERVER MODE

The default mode is an RPC server mode.

geoplay

Try the LetMeGRPC handler at http://localhost:6796/GeoLookup/Lookup or the built-in Prometheus metrics at http://localhost:6796/metrics. After making some RPCs, look at http://localhost:6796/debug/requests.

INCLUDED DATA

The data/locations.json file came from https://github.com/mmcloughlin/starbucks

Directories

Path Synopsis
Package latlonpb is a generated protocol buffer package.
Package latlonpb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL