https://github.com/h3poteto/grpc_example
https://github.com/h3poteto/grpc_example
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/h3poteto/grpc_example
- Owner: h3poteto
- Created: 2017-09-13T03:44:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-16T04:13:18.000Z (about 6 years ago)
- Last Synced: 2025-02-26T15:06:38.146Z (2 months ago)
- Language: Python
- Size: 30.3 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gRPC example
## configure
Set ip address and port in `.envrc`, for example:```bash
export SERVER_IP=127.0.0.1
export SERVER_PORT=9090
```And Install `protobuf`:
```bash
$ brew install protobuf
```## server
### python
Install `grpcio` and `grpcio-tools`:```bash
$ pip install grpcio grpcio-tools
```Generate a server interface, and start gRPC server.
```bash
$ python server_codegen.py
$ cd server/python
$ python server.py
Starting server...
Listen :50051
```### go
Generate a server interface, and start gRPC server.
```
$ protoc \
--go_out=plugins=grpc:./server/go \
proto/*.proto
$ go run server/go/server.go
```### scala
Generate a server interface, and start gRPC server.
```
$ cd server/scala
$ sbt "compile"
$ sbt "run"
```## client
### rubyGenerate a ruby interface.
```
$ gem install grpc
$ gem install grpc-tools
$ grpc_tools_ruby_protoc -I ./proto --ruby_out=client/ruby/lib --grpc_out=client/ruby/lib ./proto/customer_service.proto
```### python
Generate a python interface.
```bash
$ client_codegen.py
```And request to server.
```bash
$ python add.py
Added$ python list.py
Name: akira, Age: 12
```