Multi-language gRPC code generation using Buf and Bazel. Generates Python, Go, and C++ code from Protocol Buffer definitions with working client/server examples.
# Generate gRPC code for all languages
make generate
# Run example applications
make run-py-server # Python server
make run-go-client # Go client
make run-cpp-server-dev # C++ server (fast build - recommended)
make run-cpp-server # C++ server (optimized build)
# Clean generated code and Bazel cache
make clean
proto/
- Protocol Buffer definitionsgen/
- Generated gRPC code (Python, Go, C++)src/
- Example client/server implementationsscripts/
- Build automation scriptsbuf.yaml
- Buf configuration for linting and breaking changesbuf.gen.yaml
- Code generation configuration
The ProductInfo
service provides:
addProduct(Product) -> ProductID
- Add a new productgetProduct(ProductID) -> Product
- Retrieve a product by ID
Generated files are placed in gen/
:
- Python:
gen/python/product/
-*_pb2.py
and*_pb2_grpc.py
- Go:
gen/go/product/
-*.pb.go
- C++:
gen/c++/product/
-*.pb.h/cc
and*.grpc.pb.h/cc
Working client/server implementations are provided in src/
:
Python: src/python/product/
server.py
- gRPC server implementationclient.py
- gRPC client implementation
Go: src/go/product/
server/
- gRPC server with main.go and server.goclient/
- gRPC client implementation
C++: src/c++/product/
server/
- gRPC server with product_info_server.h/cppclient/
- gRPC client implementation
# Python
make run-py-server
make run-py-client
# Go
make run-go-server
make run-go-client
# C++
make run-cpp-server
make run-cpp-client
# Build with Docker
docker build -t grpc-sandbox .
docker run -v $(pwd):/app grpc-sandbox buf generate
- Buf: Modern protobuf toolchain for code generation
- Bazel: Build system for compiling and running applications
- Automated BUILD files: Scripts generate Bazel BUILD files automatically
- Version synchronization: buf.gen.yaml and MODULE.bazel versions are kept in sync
- Create
.proto
file inproto/
- Run
make generate
(automatically creates BUILD files) - Implement client/server in
src/