A comprehensive collection of gRPC implementations in Go, demonstrating various communication patterns and real-world use cases.
This repository contains three complete gRPC services showcasing different aspects of gRPC development:
- Greet Service - Demonstrates all four gRPC communication patterns
- Calculator Service - Implements mathematical operations with streaming
- Blog Service - Full CRUD application with MongoDB integration
- Unary RPC - Single request, single response
- Server Streaming - Single request, multiple responses
- Client Streaming - Multiple requests, single response
- Bidirectional Streaming - Multiple requests and responses
- Simple greeting with various streaming patterns
- Deadline/timeout handling
- All four communication patterns implemented
- Prime number decomposition (server streaming)
- Average calculation (client streaming)
- Maximum number finder (bidirectional streaming)
- Square root with error handling
- Complete CRUD operations
- MongoDB integration
- Create, Read, Update, Delete blogs
- List all blogs with streaming
- Go 1.22.1+
- gRPC - High-performance RPC framework
- Protocol Buffers - Data serialization
- MongoDB - Database for blog service
- Docker - Containerization support
- Go 1.22.1 or higher
- Protocol Buffers compiler (
protoc) - MongoDB (for blog service)
- Clone the repository:
git clone https://github.com/Vova4o/grpc.git
cd grpc- Install dependencies:
go mod download- Generate protocol buffer code:
make allmake allmake greet # Build greet service
make calculator # Build calculator service
make blog # Build blog service# Greet server
./bin/greet/server
# Calculator server
./bin/calculator/server
# Blog server (requires MongoDB)
./bin/blog/server# Greet client
./bin/greet/client
# Calculator client
./bin/calculator/client
# Blog client
./bin/blog/client.
├── greet/ # Greet service implementation
│ ├── client/ # Client implementations
│ ├── server/ # Server implementations
│ └── proto/ # Protocol buffer definitions
├── calculator/ # Calculator service implementation
│ ├── client/ # Client implementations
│ ├── server/ # Server implementations
│ └── proto/ # Protocol buffer definitions
├── blog/ # Blog service with MongoDB
│ ├── client/ # Client implementations
│ ├── server/ # Server implementations
│ ├── proto/ # Protocol buffer definitions
│ └── docker-compose.yml
├── ssl/ # SSL/TLS certificates
└── Makefile # Build automation
make all # Generate protobuf code and build all services
make greet # Build greet service
make calculator # Build calculator service
make blog # Build blog service
make test # Run tests
make clean # Clean generated files
make rebuild # Clean and rebuild everything
make bump # Update dependencies
make about # Display build information
make help # Show available commandsThis project demonstrates:
- Protocol buffer schema design
- Code generation from
.protofiles - Implementation of all gRPC communication patterns
- Error handling and deadlines
- Database integration with gRPC
- Reflection API for debugging
- Best practices for service architecture
Greet()- Simple unary callGreetManyTimes()- Server streamingLongGreet()- Client streamingGreetEveryone()- Bidirectional streamingGreetWithDeadline()- Timeout handling
Numbers()- Prime number decompositionAverageOfSumm()- Calculate averageSqrt()- Square root with error handling
CreateBlog()- Create new blog postReadBlog()- Read blog by IDUpdateBlog()- Update existing blogDeleteBlog()- Delete blog postListBlogs()- Stream all blogs
The project includes SSL certificate generation scripts in the ssl/ directory for secure communication.
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is for educational purposes.
Vladimir Gavrilenko (@Vova4o)
⭐ If you found this project helpful, please give it a star!