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

Nacos Configuration Center Example

Description

This directory contains an example demonstrating how to integrate Nacos configuration center with GoFrame applications. It shows:

  1. Nacos Client Configuration

    • Nacos client setup and initialization
    • Configuration adapter implementation
    • Error handling and logging
  2. Configuration Management

    • Configuration loading and parsing
    • Dynamic configuration updates
    • Configuration value retrieval

Directory Structure

.
├── boot/ # Bootstrap configuration
│ └── boot.go # Nacos client initialization
├── main.go # Main application entry
├── go.mod # Go module file
└── go.sum # Go module checksums

Requirements

Features

The example showcases the following features:

  1. Nacos Integration

    • Client configuration
    • Server connection management
    • Configuration namespace
    • Error handling
  2. Configuration Management

    • Configuration loading
    • Value retrieval
    • Type conversion
    • Default values
  3. Dynamic Updates

    • Configuration watching
    • Change notification
    • Hot reload support

Configuration

Nacos Server

  1. Server Configuration:

    • Default port: 8848
    • Default address: localhost
    • Default protocol: HTTP
  2. Authentication:

    • Username/Password authentication
    • Namespace isolation
    • Group level access control

Client Configuration

  1. Basic Settings:

    • Server address and port
    • Cache directory
    • Log directory
    • Data ID and Group
  2. Advanced Options:

    • Namespace customization
    • Cache management
    • Logging configuration
    • Retry settings

Usage

  1. Start Nacos Server:

    # Start Nacos server using Docker
    docker run -d --name nacos \
    -p 8848:8848 -p 9848:9848 \
    -e MODE=standalone \
    nacos/nacos-server:latest
  2. Configure Nacos:

  3. Run Example:

    go run main.go