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

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:

  1. Service Registration

    • Automatic service registration
    • Health check configuration
    • Metadata management
    • Service routing
    • Rate limiting
  2. Service Discovery

    • Dynamic service discovery
    • Load balancing
    • Failover support
    • Circuit breaking
    • Fault tolerance
  3. Protocol Support

    • HTTP services
    • Custom protocols
    • Protocol extension

Requirements

Prerequisites

  1. 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

  1. Start the server:

    cd server
    go run server.go
  2. Run the client:

    cd client
    go run client.go

Implementation Details

The example demonstrates:

  1. Polaris client configuration
  2. Service registration process
  3. Service discovery mechanism
  4. Health check implementation
  5. Load balancing strategies
  6. Circuit breaker configuration
  7. Rate limiting setup