nacos

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	TimeoutMs           uint64         `mapstructure:"timeoutMs"` // 连接nacos服务器的超时时间,默认10000ms
	Username            string         `mapstructure:"username"`
	Password            string         `mapstructure:"password"`
	NamespaceId         string         `mapstructure:"namespaceId"`
	DataId              string         `mapstructure:"dataId"`
	Group               string         `mapstructure:"group"`
	Type                string         `mapstructure:"type"` // nacos存储配置信息的格式
	Tag                 string         `mapstructure:"tag"`
	Servers             []ServerConfig `mapstructure:"servers"`
	ClusterName         string         `mapstructure:"clusterName"`
	CacheDir            string         `mapstructure:"cacheDir"`            // 缓存nacos服务信息的目录,默认当前目录
	NotLoadCacheAtStart bool           `mapstructure:"notLoadCacheAtStart"` // 应用每次启动时,是否从缓存中加载nacos服务信息,true:不从缓存中加载
	LogLevel            string         `mapstructure:"logLevel"`            // debug | info | warn | error,默认:info
	LogDir              string         `mapstructure:"logDir"`              // 默认当前目录
	BeatInterval        uint64         `mapstructure:"beatInterval"`        // 与nacos服务器保持心跳的时间间隔,默认5000ms
	ServiceInfo         ServiceInfo    `mapstructure:"serviceInfo"`         // 服务注册
}

type Nacoser

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

func CreateNacoser

func CreateNacoser(cfg *Config) *Nacoser

func (*Nacoser) GetConfig

func (n *Nacoser) GetConfig() string

func (*Nacoser) GetService

func (n *Nacoser) GetService(param vo.GetServiceParam) *model.Service

func (*Nacoser) GetServiceInstance

func (n *Nacoser) GetServiceInstance(param vo.SelectOneHealthInstanceParam) *model.Instance

func (*Nacoser) RegisterService

func (n *Nacoser) RegisterService(listenAddr string) error

func (*Nacoser) UnregisterService

func (n *Nacoser) UnregisterService()

type ServerConfig

type ServerConfig struct {
	IpAddr   string `mapstructure:"ipAddr"`
	Port     uint64 `mapstructure:"port"`
	GrpcPort uint64 `mapstructure:"grpcPort"` // 通常是port + 1000
}

type ServiceInfo

type ServiceInfo struct {
	ServiceName string  `mapstructure:"serviceName"`
	Weight      float64 `mapstructure:"weight"`    // 权重
	Enable      bool    `mapstructure:"enable"`    // 服务实例是否可用
	Healthy     bool    `mapstructure:"healthy"`   // 服务实例是否健康
	Ephemeral   bool    `mapstructure:"ephemeral"` // 是否为临时实例,实例下线时自动删除
}

Jump to

Keyboard shortcuts

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