nacos

package
v0.0.0-...-532f4bb Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Config = ExternalConfig{}
)

Functions

func GetNacosSdkConfig

func GetNacosSdkConfig(config *NacosConfig) ([]constant.ServerConfig, *constant.ClientConfig, error)

Types

type ExternalConfig

type ExternalConfig struct {
	ListenOn        string           `yaml:"listenOn"`
	Redis           *Redis           `yaml:"redis"`
	Mongodb         *Mongodb         `yaml:"mongodb"`
	Kafka           *Kafka           `yaml:"kafka"`
	NacosConf       *NacosConf       `yaml:"nacosConf"`
	NacosServicName *NacosServicName `yaml:"nacosServicName"`
	KeysPath        *KeysPath        `yaml:"keysPath"`
	Log             *Log             `yaml:"log"`
}

func InitConfig

func InitConfig(data []byte) (*ExternalConfig, error)

type Kafka

type Kafka struct {
	Topic            string   `yaml:"topic"`
	TopicPush        string   `yaml:"topicPush"`
	TopicSessionTime string   `yaml:"topicSessionTime"`
	Group            string   `yaml:"group"`
	Brokers          []string `yaml:"brokers"`
}

type KeysPath

type KeysPath struct {
	Path string `yaml:"path"`
}

type Log

type Log struct {
	LogPath    string `yaml:"logPath"`    // 日志文件路径
	LogLevel   string `yaml:"logLevel"`   //日志级别 debug/info/warn/error
	MaxBackups int    `yaml:"maxBackups"` // 保存的文件个数
	MaxAge     int    `yaml:"maxAge"`     // 保存的天数, 没有的话不删除
	ServerName string `yaml:"serverName"` // 服务名称
}

type Mongodb

type Mongodb struct {
	Uri         string `yaml:"uri"`
	MaxPoolSize uint64 `yaml:"maxPoolSize"`
	DbName      string `yaml:"dbName"`
}

type NacosClient

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

func InitNacos

func InitNacos(config *NacosConfig) (*NacosClient, error)

func (*NacosClient) CancelListenConfig

func (client *NacosClient) CancelListenConfig(dataId, group string) error

func (*NacosClient) DeleteConfig

func (client *NacosClient) DeleteConfig(dataId, group string) (bool, error)

func (*NacosClient) Deregister

func (client *NacosClient) Deregister(svcIp string, svcPort uint64, svcName string) (bool, error)

func (*NacosClient) DeregisterInstance

func (client *NacosClient) DeregisterInstance() (bool, error)

func (*NacosClient) GetConfig

func (client *NacosClient) GetConfig(dataId, group string) (string, error)

func (*NacosClient) ListenConfig

func (client *NacosClient) ListenConfig(dataId, group string, changeCb func(namespace, group, dataId, data string)) error

func (*NacosClient) PublishConfig

func (client *NacosClient) PublishConfig(dataId, group, content string) (bool, error)

func (*NacosClient) RegisterInstance

func (client *NacosClient) RegisterInstance(config *NacosRegisterConfig) (bool, error)

func (*NacosClient) SelectAllInstances

func (client *NacosClient) SelectAllInstances(svcName, groupName string) ([]model.Instance, error)

func (*NacosClient) SelectInstances

func (client *NacosClient) SelectInstances(svcName, groupName string) ([]model.Instance, error)

func (*NacosClient) SelectOneHealthyInstance

func (client *NacosClient) SelectOneHealthyInstance(svcName, groupName string) (*model.Instance, error)

func (*NacosClient) Subscribe

func (client *NacosClient) Subscribe(svcName, groupName string, cb func(services []model.Instance, err error)) error

func (*NacosClient) Unsubscribe

func (client *NacosClient) Unsubscribe(svcName, groupName string, cb func(services []model.Instance, err error)) error

func (*NacosClient) UpdateMetaData

func (client *NacosClient) UpdateMetaData(metadata map[string]string) (bool, error)

type NacosConf

type NacosConf struct {
	Host        string `yaml:"host"`
	GroupName   string `yaml:"groupName"`
	NameSpaceId string `yaml:"nameSpaceId"`
	ServiceName string `yaml:"serviceName"`
	ServiceIp   string `yaml:"serviceIp"`
	ServicePort uint64 `yaml:"servicePort"`
}

type NacosConfig

type NacosConfig struct {
	Host        string // 地址 例:"http://127.0.0.1:8848;127.0.0.1:8849;127.0.0.1:8850"
	NameSpaceId string // 命名空间

	// 以下基本使用默认值,调用DefaultNacosConfig
	NotLoadCacheAtStart bool
	TimeoutMs           uint64 // 超时时间 毫秒
	CacheDir            string // 缓存地址
	LogDir              string // 日志地址
	LogLevel            string // 日志等级
}

func DefaultNacosConfig

func DefaultNacosConfig() *NacosConfig

type NacosRegisterConfig

type NacosRegisterConfig struct {
	SvcIp     string            // 注册服务的ip
	SvcPort   uint64            // 注册服务的端口
	SvcName   string            // 注册服务名称
	GroupName string            // 服务组名
	Metadata  map[string]string // 数据

	// 以下基本使用默认值,调用DefaultNacosRegisterConfig
	Healthy   bool // 健康检查
	Enable    bool // 服务启用
	Ephemeral bool
}

func DefaultNacosRegisterConfig

func DefaultNacosRegisterConfig() *NacosRegisterConfig

type NacosServicName

type NacosServicName struct {
	AuthServiceName string `yaml:"authServiceName"`
	UserServiceName string `yaml:"userServiceName"`
	ImcServiceName  string `yaml:"imcServiceName"`
	DmsServiceName  string `yaml:"dmsServiceName"`
}

type Redis

type Redis struct {
	Addr         []string `yaml:"addr"`         // 地址
	Type         string   `yaml:"type"`         // node/cluster
	Pwd          string   `yaml:"pwd"`          // 密码
	MaxRetries   int      `yaml:"maxRetries"`   // 最大尝试次数, 默认3
	MinIdleConns int      `yaml:"minIdleConns"` // 最初连接数, 默认8
}

Jump to

Keyboard shortcuts

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