https://github.com/clarkmcc/brpc
Bi-directional gRPC. Easily call client RPCs from your gRPC server.
https://github.com/clarkmcc/brpc
grpc grpc-go multiplexing
Last synced: 30 days ago
JSON representation
Bi-directional gRPC. Easily call client RPCs from your gRPC server.
- Host: GitHub
- URL: https://github.com/clarkmcc/brpc
- Owner: clarkmcc
- License: mit
- Created: 2023-11-07T00:08:19.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-30T14:54:16.000Z (almost 2 years ago)
- Last Synced: 2023-11-30T15:45:43.989Z (almost 2 years ago)
- Topics: grpc, grpc-go, multiplexing
- Language: Go
- Homepage:
- Size: 48.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# brpc
A low-invasive, bidirectional gRPC framework for Go. This library is a proof of concept that allows your clients to connect to a gRPC server, and then expose a gRPC server of their own, allowing the real gRPC server to call RPCs on the client.```go
func (s *GreeterService) Greet(ctx context.Context, _ *example.GreetRequest) (*example.GreetResponse, error) {
// The client provides a gRPC service. Let's extract it from the context.
client, err := s.ClientFromContext(ctx)
if err != nil {
return nil, err
}
// Let's call the client's Name method, an RPC on the client's gRPC service.
res, err := client.Name(ctx, &example.NameRequest{})
if err != nil {
return nil, err
}
return &example.GreetResponse{
Greeting: fmt.Sprintf("Hello %v", res.GetName()),
}, nil
}
```## Features
* **Bidirectional** - Clients can expose a gRPC server of their own, allowing the real gRPC server to call RPCs on the client.
* **Low-invasive** - Takes advantage of all the generated types and functions from `protoc`, you just need to plug everything into brpc.
* **Single connection** - All connections are multiplexed across a single QUIC connection.
* **Go generics** - Uses Go generics to make it easy to plug everything together correctly.## Internals
This library uses a single QUIC connection and all other connections are multiplexed across this connection. Clients receive connection IDs from the server which they then provide with every subsequent client-to-server RPC request, and the brpc server exposes the client's RPC methods inside your gRPC service so that you can call them from the server.## Example
See [EXAMPLE.md](EXAMPLE.md) for a full example.