Registry - Polaris
Integration
Code Source: https://github.com/gogf/examples/tree/main/registry/polaris
Description
This example demonstrates how to integrate Polaris
service registry with GoFrame
applications. It shows how to:
- Register services with
Polaris
- Discover services using
Polaris
- Implement service health checks
- Build distributed systems
Structure
.
├── client/ # Client example
│ └── client.go # Client implementation with Polaris discovery
├── server/ # Server example
│ └── server.go # Server implementation with Polaris registration
├── go.mod # Go module file
└── go.sum # Go module checksums
Features
The example showcases the following features:
-
Service Registration
- Automatic service registration
- Health check configuration
- Metadata management
- Service routing
- Rate limiting
-
Service Discovery
- Dynamic service discovery
- Load balancing
- Failover support
- Circuit breaking
- Fault tolerance
-
Protocol Support
HTTP
services- Custom protocols
- Protocol extension
Requirements
- Go 1.22 or higher
- Git
- GoFrame
- GoFrame Polaris Registry
- Polaris
Prerequisites
- Running
Polaris
server:# Using docker
docker run -d \
--name polaris \
-p 8090:8090 \
-p 8091:8091 \
-p 8093:8093 \
-p 8761:8761 \
polarismesh/polaris-server
Usage
-
Start the server:
cd server
go run server.go -
Run the client:
cd client
go run client.go
Implementation Details
The example demonstrates:
Polaris
client configuration- Service registration process
- Service discovery mechanism
- Health check implementation
- Load balancing strategies
- Circuit breaker configuration
- Rate limiting setup