nacosstarter

package
v0.1.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RawConfigInstance

func RawConfigInstance() config_client.IConfigClient

func RawNamingInstance

func RawNamingInstance() naming_client.INamingClient

Types

type ConfigChangeData added in v0.1.2

type ConfigChangeData func(namespace, group, dataId, data string)

ConfigChangeData 文件变动监听回调

type ConfigClient added in v0.1.2

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

func GetConfigClient

func GetConfigClient(group string) (*ConfigClient, error)

func (*ConfigClient) GetConfig added in v0.1.2

func (c *ConfigClient) GetConfig(dataId string, configType ConfigType, value any) error

GetConfig 获取指定文件内容并反序列化

func (*ConfigClient) GetConfigRawContent added in v0.1.2

func (c *ConfigClient) GetConfigRawContent(dataId string) (string, error)

GetConfigRawContent 获取指定配置的源文件内容

func (*ConfigClient) LoadAndWatchConfig added in v0.1.2

func (c *ConfigClient) LoadAndWatchConfig(configFiles []*ConfigFileSetting) error

LoadAndWatchConfig 获取并监听配置变化

func (*ConfigClient) UnwatchConfig added in v0.1.2

func (c *ConfigClient) UnwatchConfig(watchId string) error

UnwatchConfig 取消监听文件变化

func (*ConfigClient) WatchConfig added in v0.1.2

func (c *ConfigClient) WatchConfig(dataId string, watch func(namespace, group, dataId, data string)) (string, error)

WatchConfig 监听文件变化

type ConfigFileSetting

type ConfigFileSetting struct {
	DataId string
	Type   ConfigType
	Watch  bool
	Value  any
}

type ConfigType

type ConfigType string
const (
	ConfigTypeJson ConfigType = "json"
	ConfigTypeYaml ConfigType = "yaml"
)

type InitConfigSettings

type InitConfigSettings struct {
	ConfigSetting []*ConfigFileSetting
	GroupName     string
}

type Instance added in v0.1.2

type Instance struct {
	Ip          string
	ServiceName string
	Port        uint
	Weight      uint
	Metadata    map[string]string
}

type InstanceBatch added in v0.1.2

type InstanceBatch struct {
	Ip       string
	Port     uint
	Weight   uint
	Metadata map[string]string
}

type NacosClientConfig

type NacosClientConfig struct {
	*constant.ClientConfig
}

type NacosServerConfig

type NacosServerConfig struct {
	Services []constant.ServerConfig
}

type NacosStarter

type NacosStarter struct {
	ServerConfig *NacosServerConfig
	ClientConfig *NacosClientConfig

	// 禁用配置功能
	DisableConfig bool
	// 禁用服务发现功能
	DisableDiscovery bool

	// 需要立即初始化的配置
	// 该设置将在nacos就绪后立即执行,适用于初始化配置其他模块可以立即在后续读取
	InitConfigSettings *InitConfigSettings

	NacosSetting *parent.Setting
}

func (*NacosStarter) Setting

func (n *NacosStarter) Setting() *parent.Setting

func (*NacosStarter) Start

func (n *NacosStarter) Start() (interface{}, error)

func (*NacosStarter) Stop

func (n *NacosStarter) Stop(maxWaitTime time.Duration) (gracefully, stopped bool, err error)

type NamingClient added in v0.1.2

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

func GetNamingClient

func GetNamingClient(group string) (*NamingClient, error)

func (*NamingClient) ChooseOneHealthyInstance added in v0.1.2

func (n *NamingClient) ChooseOneHealthyInstance(serviceName string) (*RegisteredInstance, error)

ChooseOneHealthyInstance 选择一个可用的实例

func (*NamingClient) GetAllInstances added in v0.1.2

func (n *NamingClient) GetAllInstances(serviceName string) ([]RegisteredInstance, error)

GetAllInstances 获取指定服务的所有实例(不论当前是否可用)

func (*NamingClient) GetHealthyInstances added in v0.1.2

func (n *NamingClient) GetHealthyInstances(serviceName string) ([]RegisteredInstance, error)

GetHealthyInstances 获取指定服务的可用实例

func (*NamingClient) GetService added in v0.1.2

func (n *NamingClient) GetService(serviceName string) (model.Service, error)

GetService 获取指定服务的概要信息

func (*NamingClient) GetServicePage added in v0.1.2

func (n *NamingClient) GetServicePage(pageNo, pageSize uint) (model.ServiceList, error)

GetServicePage 获取指定服务的注册信息

func (*NamingClient) Register added in v0.1.2

func (n *NamingClient) Register(instance Instance) (string, error)

Register 向注册中心注册临时实例 一个NamingClient只能注册一个实例,重复注册将出现替换

func (*NamingClient) RegisterBatch added in v0.1.2

func (n *NamingClient) RegisterBatch(serviceName string, instances []InstanceBatch) ([]string, error)

func (*NamingClient) Unregister added in v0.1.2

func (n *NamingClient) Unregister(instanceId string) (bool, error)

Unregister 向注册中心注销实例

func (*NamingClient) UnwatchNaming added in v0.1.2

func (n *NamingClient) UnwatchNaming(watchId string) error

UnwatchNaming 取消监控服务实例变化

func (*NamingClient) WatchNaming added in v0.1.2

func (n *NamingClient) WatchNaming(serviceName string, watch func(instance []model.Instance, err error)) (string, error)

WatchNaming 监控服务的实例变化

type RegisteredInstance added in v0.1.2

type RegisteredInstance struct {
	Instance           model.Instance
	InstanceIdentifier string
}

Jump to

Keyboard shortcuts

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