Skip to content

caiofilipini/grpc-weather

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gRPC Weather

Simple gRPC example implemented in Go. It features a server and a client for a service that provides information about the weather.

This service relies on openweathermap.org's API and Weather Underground as weather information providers.

Building and running

You will need to install protoc and the protoc-gen-go plugin in order to generate server and client stubs.

Additionally, you will need API keys for both providers.

Once that's all in place, you can build the server:

$ make build-server

And then run it:

$ OPEN_WEATHER_MAP_API_KEY="s3cr3+" WEATHER_UNDERGROUND_API_KEY="s3cr3+2" ./weather_server/server

If all goes well, you should see a message like this (assuming the server is running in the default port (i.e. 9000):

2015/11/18 17:32:59 Listening on :9000

Similarly, you can build the client:

$ make build-client

And then run it, providing a location:

./weather_client/client Berlin, Germany

An example output:

2015/11/18 17:33:03 It's currently 9.5°C, broken clouds in Berlin, Germany

Running with Docker

If you don't want to mess with your local environment and would prefer running everything in a Docker container, you have two options. The easiest option is running the existing image from Docker Hub, by running the following command:

$ docker run --rm -p 9000:9000 \
  -e OPEN_WEATHER_MAP_API_KEY="<your-api-key-here>" \
  -e WEATHER_UNDERGROUND_API_KEY="<your-api-key-here>" \
  --name weather_service caiofilipini/grpc-weather:master

This command will pull the image from Docker Hub and run the weather_server in a container. Then you can run the client on the same container:

$ docker exec weather_service weather_client Berlin, Germany

If you'd rather build the image yourself, just use the provided Dockerfile.

About

Simple gRPC example implemented in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published