Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/d-alejandro/grpc
Go, gRPC, Golang 1.22, Protobuf, Client, Server, OOP, Makefile
https://github.com/d-alejandro/grpc
client go golang grpc makefile oop protobuf protocol-buffers server
Last synced: about 1 month ago
JSON representation
Go, gRPC, Golang 1.22, Protobuf, Client, Server, OOP, Makefile
- Host: GitHub
- URL: https://github.com/d-alejandro/grpc
- Owner: d-alejandro
- Created: 2024-07-29T11:18:11.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2024-07-30T23:48:00.000Z (4 months ago)
- Last Synced: 2024-09-30T15:41:18.225Z (about 1 month ago)
- Topics: client, go, golang, grpc, makefile, oop, protobuf, protocol-buffers, server
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## gRPC Example
Server Address: `grpc://127.0.0.1:50051`
### RPC methods
- `GetOrder`
- `GetOrders`### Defining the gRPC service
Full Protobuf file in `pkg/proto/service/order/v1/order.proto`
```protobuf
syntax = "proto3";service OrderService {
rpc GetOrder (OrderRequest) returns (OrderResponse);
rpc GetOrders (Empty) returns (OrdersResponse);
}message OrderRequest {
int64 order_id = 1;
}message OrderResponse {
Order order = 1;
}message Order {
int64 order_id = 1;
string user_name = 2;
string email = 3;
}message Empty {}
message OrdersResponse {
repeated Order orders = 1;
}
```### GetOrder response
Status code: `0 OK`
```json
{
"order": {
"order_id": 3,
"user_name": "TestUserName3",
"email": "[email protected]"
}
}
```### GetOrders response
Status code: `0 OK`
```json
{
"orders": [
{
"order_id": 3,
"user_name": "TestUserName3",
"email": "[email protected]"
},
{
"order_id": 2,
"user_name": "TestUserName2",
"email": "[email protected]"
},
{
"order_id": 1,
"user_name": "TestUserName1",
"email": "[email protected]"
}
]
}
```