How tokopedia/gripmock works
Main Components
a) Core Components:
• gRPC Server (Port 4770)
• Stub HTTP Server (Port 4771)
• Protoc Plugin Generator
• Storage Layer
b) External Interfaces:
• Client gRPC Connections
• HTTP Stub Management API
• Proto File Input
• Stub File Input
• Client Layer |
• gRPC Clients | | HTTP Clients | | Proto Files | | Stub Files | |
• ↓
• GripMock Core |
• gRPC Server |←-| Stub Server | |
• (Port 4770) | | (Port 4771) | |
• ↑ ↑ |
• Generated Code | | Storage Layer | |
• ↑
• Generation Layer |
• protoc-gen-gripmock | | Proto Compiler | |
Important Details
a) API Endpoints:
Stub Server (4771):
• GET /
• POST /add
• POST /find
• GET /clear
b) Data Flow Markers:
• Client → gRPC Server (4770)
• HTTP Client → Stub Server (4771)
• gRPC Server ↔ Stub Server
• Proto Files → Generator
• Generated Code → gRPC Server
Implementation Details
• Example implementations (/example directory)
• Protocol buffer generation (/protogen directory)
• Core mock server implementation (gripmock.go)
• Stub handling (stub directory)
Architectural Patterns to Highlight
• Service-based architecture
• Plugin-based code generation
• RESTful stub management
• Dynamic configuration support