nacos

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToProviderInstance added in v0.4.0

func ToProviderInstance(nacosInstances []model.Instance) []provider.Instancer

ToProviderInstance converts Nacos instances to the internal service instance format.

Types

type Discovery added in v0.10.0

type Discovery struct {
	// contains filtered or unexported fields
}

Discovery implements service discovery using Nacos.

func NewNacosServiceDiscovery added in v0.4.0

func NewNacosServiceDiscovery(options Options) (*Discovery, error)

NewNacosServiceDiscovery creates a new NacosServiceDiscovery instance.

func (*Discovery) Close added in v0.10.0

func (d *Discovery) Close() error

Close stops the Nacos service discovery and cleans up resources.

func (*Discovery) GetInstances added in v0.10.0

func (d *Discovery) GetInstances(
	_ context.Context,
	options provider.GetInstanceOptions,
) ([]provider.Instancer, error)

GetInstances returns the current list of healthy service instances from Nacos.

func (*Discovery) Watch added in v0.10.0

func (d *Discovery) Watch(
	_ context.Context,
	options provider.GetInstanceOptions,
) (<-chan []provider.Instancer, error)

Watch subscribes to service changes in Nacos and returns a channel for updates.

type File

type File struct {
	DataID  string
	Group   string
	Content string
}

File defines the Nacos data ID, group, and content.

type Options

type Options struct {
	Username    string
	Password    string
	NamespaceID string
	Prefix      string
	LogDir      string
	LogLevel    string // debug, info, warn, error
	CacheDir    string
	Endpoints   []string
	Files       []*File
	Timeout     time.Duration
	Watch       bool
}

Options defines the configuration for the Nacos configuration provider.

type Provider added in v0.10.0

type Provider struct {
	OnChanged provider.ChangeFunc
	// contains filtered or unexported fields
}

Provider implements a configuration provider that reads from Nacos.

func NewProvider

func NewProvider(options Options) (*Provider, error)

NewProvider creates a new NacosProvider instance.

func (*Provider) ConfigOpen added in v0.10.0

func (p *Provider) ConfigOpen() ([]*File, error)

ConfigOpen reads the configured files from Nacos and returns their content.

func (*Provider) SetOnChanged added in v0.10.0

func (p *Provider) SetOnChanged(changeFunc provider.ChangeFunc)

SetOnChanged sets the callback function to be called when configuration changes in Nacos.

func (*Provider) Watch added in v0.10.0

func (p *Provider) Watch() error

Watch starts listening for configuration changes in Nacos.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL