Skip to main content
Version: 2.10.x(Latest)

📄️ Basic Usage

Demonstrates fundamental gRPC implementation in GoFrame applications covering protocol buffer definitions, service creation, and client-server communication. This example showcases how to create gRPC servers and clients using GoFrame, define and compile protocol buffers for service contracts, implement service handlers with business logic, make synchronous and asynchronous RPC calls, handle errors and status codes, and integrate with GoFrame's configuration and logging systems. Features include complete server and client setup, protocol buffer integration, service interface implementation, request-response patterns, error handling best practices, and production-ready code structure. Ideal for developers new to gRPC, building microservices with GoFrame, learning protocol buffer usage, and implementing inter-service communication patterns.

📄️ Context Usage

Demonstrates advanced context and metadata management in gRPC services using GoFrame for request tracking and data propagation. This example showcases how to pass metadata through gRPC context for cross-cutting concerns, handle context values and deadlines for request cancellation, manage request context across service boundaries, process and extract context metadata, implement distributed tracing integration, and propagate authentication tokens and correlation IDs. Features include metadata injection and extraction, context timeout and cancellation handling, custom metadata keys and values, interceptor-based metadata processing, distributed tracing support, and request correlation patterns. Perfect for implementing observability in microservices, tracking requests across distributed systems, implementing authentication and authorization, managing request timeouts and cancellation, and building production-ready gRPC services with proper context management.

📄️ Raw gRPC Example

Demonstrates raw gRPC implementation in GoFrame without framework abstractions for maximum control and flexibility. This example showcases how to create gRPC servers and clients using raw gRPC libraries directly, use protocol buffers without additional wrappers, implement service handlers with direct gRPC API access, make low-level RPC calls with full control, handle streaming RPCs and advanced patterns, and integrate with GoFrame components selectively. Features include direct gRPC server and client creation, unabstracted protocol buffer usage, manual connection management, custom interceptors and middleware, streaming support (unary, client-streaming, server-streaming, bidirectional), and production-ready error handling. Perfect for advanced users requiring fine-grained control, implementing custom gRPC patterns, optimizing performance-critical applications, and integrating third-party gRPC libraries.

📄️ Load Balancing

Demonstrates comprehensive gRPC load balancing implementation in GoFrame for building resilient distributed systems. This example showcases how to configure gRPC load balancers with multiple strategies, implement client-side load balancing for optimal performance, integrate with service discovery mechanisms like etcd, handle automatic failover and service health checks, distribute requests across multiple server instances, and manage connection pooling. Features include multiple load balancing algorithms (round-robin, weighted, least-connection), automatic service instance discovery, health-based routing, connection state management, retry policies, and production-ready error handling. Perfect for building highly available microservices, implementing fault-tolerant distributed systems, scaling gRPC services horizontally, and ensuring optimal resource utilization across service instances.

📄️ Service Resolver

Demonstrates gRPC service resolver implementation with etcd integration in GoFrame for dynamic service discovery and resolution. This example showcases how to configure service resolver with etcd as the service registry, register gRPC services to etcd with automatic heartbeat, discover and resolve services dynamically using resolver API, handle service instance updates and removals automatically, implement client-side service discovery, and manage service health monitoring. Features include etcd-based service registry, automatic service registration and deregistration, dynamic service resolution, health check integration, automatic failover on service changes, and production-ready connection management. Ideal for building cloud-native microservices with dynamic service discovery, implementing service mesh patterns, scaling services without client reconfiguration, and ensuring high availability through automatic service resolution.