nacs

package
v0.3.12 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register added in v0.3.12

func Register(name string, builder any)

Types

type ConfigListener added in v0.3.12

type ConfigListener func(fname string, payload []byte, err error)

ConfigListener 定义配置变更监听器

type Configor

type Configor interface {
	// GetConfig 获取配置项的值
	GetConfig(fname string) ([]byte, error)

	// SetConfig 设置配置项的值
	SetConfig(fname string, payload []byte) error

	// DeleteConfig 删除配置项
	DeleteConfig(fname string) error

	// WatchConfig 监听配置项的变化
	WatchConfig(listener ConfigListener) error
}

Configor 配置中心接口

type ConfigorBuilder added in v0.3.12

type ConfigorBuilder interface{ Build() Configor }

func LookupConfigor added in v0.3.12

func LookupConfigor(name string) (ConfigorBuilder, bool)

type Registry

type Registry interface {
	// Register 注册服务实例
	Register(instance *ServiceInstance) error

	// Deregister 注销服务实例
	Deregister(instanceID string) error

	// Discover 发现服务实例
	Discover(serviceName string) ([]*ServiceInstance, error)

	// Watch 监听服务实例的变化
	Watch(serviceName string, callback func([]*ServiceInstance)) error
}

Registry 注册中心接口

type RegistryBuilder added in v0.3.12

type RegistryBuilder interface{ Build() Registry }

func LookupRegister added in v0.3.12

func LookupRegister(name string) (RegistryBuilder, bool)

type ServiceInstance added in v0.3.12

type ServiceInstance struct {
	ID       string            // 服务实例ID
	Name     string            // 服务名称
	Address  string            // 服务地址
	Port     int               // 服务端口
	Metadata map[string]string // 元数据
}

ServiceInstance 定义服务实例

Directories

Path Synopsis
configor

Jump to

Keyboard shortcuts

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