https://github.com/felipeagger/grpc
Demo gRPC Project with Golang and Python
https://github.com/felipeagger/grpc
golang grpc python
Last synced: 22 days ago
JSON representation
Demo gRPC Project with Golang and Python
- Host: GitHub
- URL: https://github.com/felipeagger/grpc
- Owner: felipeagger
- License: bsd-2-clause
- Created: 2020-07-05T16:24:28.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-13T19:21:17.000Z (over 4 years ago)
- Last Synced: 2025-05-14T13:19:55.854Z (11 months ago)
- Topics: golang, grpc, python
- Language: Python
- Homepage:
- Size: 9.16 MB
- Stars: 10
- Watchers: 0
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gRPC
Demo gRPC Project with Golang and Python
Server and Client communication.
**Golang com gRPC - Comunicação entre micro-serviços**
[](http://www.youtube.com/watch?v=2b_4QA6D1qw "Golang com gRPC - Comunicação entre micro-serviços")
# Pontos positivos
- Estrutura RPC leve e de alto desempenho. Alem de usar HTTP/2 que é muito mais rápido que o HTTP/1.1 usado no REST padrão.
- Usa o protobuf para serializar dados, trafegando-os em binários.
- gRPC possui streaming de dados, e é bidirecional;
# Pontos Negativos
- Nao suporta comunicacao com Browsers (é mais indicado o uso entre servicos)
- Por trafegar os dados em binários, nao são legiveis aos humanos
# ProtoBuf model
```
syntax = "proto3";
package user;
service UserService {
rpc GetUser(UserRequest) returns (UserResponse) {}
}
message UserRequest {
string username = 1;
}
message UserResponse {
int64 id = 1;
string name = 2;
string username = 3;
string avatarurl = 4;
string location = 5;
Statistics statistics = 6;
repeated string listURLs = 7;
}
message Statistics {
int64 followers = 1;
int64 following = 2;
int64 repos = 3;
int64 gists = 4;
}
```
# Running
Golang running on Port 8200.
Python running on Port 8300.
```
//Server
make run
//client
make run_client
```
# Output
Golang
```
2020/07/23 10:04:28 Response from server:
id: 43504172
name: "Filipe Alves"
username: "felipeagger"
avatarurl: "https://avatars0.githubusercontent.com/u/43504172?v=4"
location: "Blumenau - SC / Brazil"
statistics: {
followers:8
following:4
repos:19
gists:1
}
listURLs: ["https://api.github.com/users/felipeagger",
"https://api.github.com/users/felipeagger/starred",
"https://api.github.com/users/felipeagger/repos"]
```
Python
```
id: 43504172
name: "Filipe Alves"
username: "felipeagger"
avatarurl: "https://avatars0.githubusercontent.com/u/43504172?v=4"
location: "Blumenau - SC / Brazil"
repos: 17
```
# Installation required:
ProtoBuff/Protoc
http://google.github.io/proto-lens/installing-protoc.html
# Links
https://developers.google.com/protocol-buffers