Documentation ¶
Index ¶
- Constants
- func Get(key string) interface{}
- func GetIP() (string, error)
- func GetIPX() string
- func Init(configPath string) error
- func IsRemote() bool
- func LoadConfig(configPath string, callback func(string, string, string, string)) error
- func SetILogger(log ILogger)
- type Config
- type ConfigName
- type DefaultLogger
- type IConfigCenter
- type IConfigurationCenter
- type IDiscoverCenter
- type ILogger
- type IRegisterCenter
- type NacosCenter
- func (n *NacosCenter) AddConfigListener(id, group string, callback func(string, string, string, string)) error
- func (n *NacosCenter) BatchRegisterService(param vo.BatchRegisterInstanceParam) (bool, error)
- func (n *NacosCenter) DeRegisterMine() error
- func (n *NacosCenter) DeRegisterServ(srvname string, port uint64) error
- func (n *NacosCenter) DeRegisterService(param vo.DeregisterInstanceParam) (bool, error)
- func (n *NacosCenter) DiscoverInstanceOne(group, service string, clusters ...string) (string, error)
- func (n *NacosCenter) Get(key string) interface{}
- func (n *NacosCenter) GetAllService(param vo.GetAllServiceInfoParam) (model.ServiceList, error)
- func (n *NacosCenter) GetByID(group, id, key string) interface{}
- func (n *NacosCenter) GetConfigClient() config_client.IConfigClient
- func (n *NacosCenter) GetContent(group, id string) (string, error)
- func (n *NacosCenter) GetIP() string
- func (n *NacosCenter) GetNamingClient() naming_client.INamingClient
- func (n *NacosCenter) GetPort() uint64
- func (n *NacosCenter) GetService(param vo.GetServiceParam) (model.Service, error)
- func (n *NacosCenter) GetServiceInfo() ServiceInfo
- func (n *NacosCenter) GetServiceName() string
- func (n *NacosCenter) ListenContent(group, id string, f func(namespace, group, dataId, data string)) error
- func (n *NacosCenter) RegisterMine(meta map[string]string) error
- func (n *NacosCenter) RegisterServ(meta map[string]string, srvname string, port uint64) error
- func (n *NacosCenter) RegisterService(param vo.RegisterInstanceParam) (bool, error)
- func (n *NacosCenter) SelectAllInstances(param vo.SelectAllInstancesParam) ([]model.Instance, error)
- func (n *NacosCenter) SelectInstances(param vo.SelectInstancesParam) ([]model.Instance, error)
- func (n *NacosCenter) SelectOneHealthyInstance(param vo.SelectOneHealthInstanceParam) (*model.Instance, error)
- func (n *NacosCenter) SetConfig(namespace, group, dataId, data string, ...) error
- func (n *NacosCenter) SetILogger(log ILogger)
- func (n *NacosCenter) SetRealPort(port int) error
- func (n *NacosCenter) Subscribe(param *vo.SubscribeParam)
- func (n *NacosCenter) UnSubscribe(param *vo.SubscribeParam)
- func (n *NacosCenter) UpdateMine() error
- func (n *NacosCenter) UpdateServ(srvname string, port uint64) error
- func (n *NacosCenter) UpdateService(param vo.UpdateInstanceParam) (bool, error)
- type ServiceInfo
- type SimpleClientConfig
- type SimpleConfig
- type SimpleServerConfig
Constants ¶
View Source
const ( KEY_IS_REMOTE = "isRemote" KEY_TMP_PORT_PATH = "./tmp/port.txt" )
Variables ¶
This section is empty.
Functions ¶
func LoadConfig ¶
func SetILogger ¶ added in v0.0.7
func SetILogger(log ILogger)
Types ¶
type Config ¶
type Config vo.NacosClientParam
type ConfigName ¶ added in v0.0.10
type DefaultLogger ¶
type DefaultLogger struct { }
type IConfigCenter ¶ added in v0.0.2
type IConfigCenter interface { AddConfigListener(id, group string, callback func(string, string, string, string)) error GetConfigClient() config_client.IConfigClient Get(key string) interface{} GetByID(group, id, key string) interface{} }
type IConfigurationCenter ¶
type IConfigurationCenter interface { IConfigCenter IRegisterCenter IDiscoverCenter SetILogger(log ILogger) GetServiceInfo() ServiceInfo }
var DefaultCenter IConfigurationCenter
func NewNacos ¶
func NewNacos(param vo.NacosClientParam, serv ServiceInfo) (IConfigurationCenter, error)
func NewSimpleNacos ¶
func NewSimpleNacos(cfg *SimpleConfig) (IConfigurationCenter, error)
type IDiscoverCenter ¶ added in v0.0.2
type IDiscoverCenter interface { GetNamingClient() naming_client.INamingClient DiscoverInstanceOne(group, service string, clusters ...string) (string, error) }
type IRegisterCenter ¶ added in v0.0.2
type IRegisterCenter interface { SetRealPort(port int) error GetIP() string GetPort() uint64 GetServiceName() string RegisterMine(meta map[string]string) error RegisterServ(meta map[string]string, srvname string, port uint64) error DeRegisterMine() error DeRegisterServ(srvname string, port uint64) error }
type NacosCenter ¶
type NacosCenter struct { ServiceInfo RealPort uint64 ConfigClient config_client.IConfigClient NamingClient naming_client.INamingClient // contains filtered or unexported fields }
func (*NacosCenter) AddConfigListener ¶
func (n *NacosCenter) AddConfigListener(id, group string, callback func(string, string, string, string)) error
AddConfigListener add config listen from remote nacos center
func (*NacosCenter) BatchRegisterService ¶
func (n *NacosCenter) BatchRegisterService(param vo.BatchRegisterInstanceParam) (bool, error)
func (*NacosCenter) DeRegisterMine ¶
func (n *NacosCenter) DeRegisterMine() error
func (*NacosCenter) DeRegisterServ ¶ added in v1.1.0
func (n *NacosCenter) DeRegisterServ(srvname string, port uint64) error
func (*NacosCenter) DeRegisterService ¶
func (n *NacosCenter) DeRegisterService(param vo.DeregisterInstanceParam) (bool, error)
func (*NacosCenter) DiscoverInstanceOne ¶ added in v0.0.2
func (n *NacosCenter) DiscoverInstanceOne(group, service string, clusters ...string) (string, error)
func (*NacosCenter) GetAllService ¶
func (n *NacosCenter) GetAllService(param vo.GetAllServiceInfoParam) (model.ServiceList, error)
func (*NacosCenter) GetByID ¶
func (n *NacosCenter) GetByID(group, id, key string) interface{}
GetByID get kv
func (*NacosCenter) GetConfigClient ¶ added in v1.3.0
func (n *NacosCenter) GetConfigClient() config_client.IConfigClient
func (*NacosCenter) GetContent ¶
func (n *NacosCenter) GetContent(group, id string) (string, error)
func (*NacosCenter) GetIP ¶ added in v1.2.0
func (n *NacosCenter) GetIP() string
func (*NacosCenter) GetNamingClient ¶ added in v1.3.0
func (n *NacosCenter) GetNamingClient() naming_client.INamingClient
func (*NacosCenter) GetPort ¶
func (n *NacosCenter) GetPort() uint64
func (*NacosCenter) GetService ¶
func (n *NacosCenter) GetService(param vo.GetServiceParam) (model.Service, error)
func (*NacosCenter) GetServiceInfo ¶ added in v1.3.0
func (n *NacosCenter) GetServiceInfo() ServiceInfo
func (*NacosCenter) GetServiceName ¶ added in v1.1.0
func (n *NacosCenter) GetServiceName() string
func (*NacosCenter) ListenContent ¶
func (n *NacosCenter) ListenContent(group, id string, f func(namespace, group, dataId, data string)) error
func (*NacosCenter) RegisterMine ¶
func (n *NacosCenter) RegisterMine(meta map[string]string) error
func (*NacosCenter) RegisterServ ¶ added in v1.1.0
func (*NacosCenter) RegisterService ¶
func (n *NacosCenter) RegisterService(param vo.RegisterInstanceParam) (bool, error)
func (*NacosCenter) SelectAllInstances ¶
func (n *NacosCenter) SelectAllInstances(param vo.SelectAllInstancesParam) ([]model.Instance, error)
func (*NacosCenter) SelectInstances ¶
func (n *NacosCenter) SelectInstances(param vo.SelectInstancesParam) ([]model.Instance, error)
func (*NacosCenter) SelectOneHealthyInstance ¶
func (n *NacosCenter) SelectOneHealthyInstance(param vo.SelectOneHealthInstanceParam) (*model.Instance, error)
func (*NacosCenter) SetConfig ¶
func (n *NacosCenter) SetConfig(namespace, group, dataId, data string, callback func(string, string, string, string)) error
SetConfig set viper config
func (*NacosCenter) SetILogger ¶ added in v0.0.6
func (n *NacosCenter) SetILogger(log ILogger)
func (*NacosCenter) SetRealPort ¶
func (n *NacosCenter) SetRealPort(port int) error
func (*NacosCenter) Subscribe ¶
func (n *NacosCenter) Subscribe(param *vo.SubscribeParam)
func (*NacosCenter) UnSubscribe ¶
func (n *NacosCenter) UnSubscribe(param *vo.SubscribeParam)
func (*NacosCenter) UpdateMine ¶
func (n *NacosCenter) UpdateMine() error
func (*NacosCenter) UpdateServ ¶ added in v1.1.0
func (n *NacosCenter) UpdateServ(srvname string, port uint64) error
func (*NacosCenter) UpdateService ¶
func (n *NacosCenter) UpdateService(param vo.UpdateInstanceParam) (bool, error)
type ServiceInfo ¶
type ServiceInfo struct { GroupName string `yaml:"groupname" json:"groupname"` ServiceName string `yaml:"servicename" json:"servicename"` ClusterName string `yaml:"clustername" json:"clustername"` IP string `yaml:"ip" json:"ip"` Port uint64 `yaml:"port" json:"port"` Weight float64 `yaml:"weight" json:"weight"` Ephemeral bool `yaml:"ephemeral" json:"ephemeral"` Enable bool `yaml:"enable" json:"enable"` Healthy bool `yaml:"healthy" json:"healthy"` Others []ConfigName `yaml:"others" json:"others"` Sentinel ConfigName `yaml:"sentinel" json:"sentinel"` }
type SimpleClientConfig ¶
type SimpleClientConfig struct { NamespaceId string `yaml:"namespaceid" json:"namespaceid"` // the namespaceId of Nacos.When namespace is public, fill in the blank string here. AppName string `yaml:"appname" json:"appname"` // the appName Endpoint string `yaml:"endpoint" json:"endpoint"` // the endpoint for get Nacos server addresses Username string `yaml:"username" json:"username"` // the username for nacos auth Password string `yaml:"password" json:"password"` // the password for nacos auth }
func (*SimpleClientConfig) ToOption ¶
func (c *SimpleClientConfig) ToOption() ([]constant.ClientOption, error)
type SimpleConfig ¶
type SimpleConfig struct { Service ServiceInfo `yaml:"service" json:"service"` ClientConfig *SimpleClientConfig `yaml:"clientconfig" json:"clientconfig"` // optional ServerConfigs []SimpleServerConfig `yaml:"serverconfigs" json:"serverconfigs"` // optional }
func (*SimpleConfig) ToParam ¶
func (c *SimpleConfig) ToParam() (vo.NacosClientParam, error)
type SimpleServerConfig ¶
type SimpleServerConfig struct { IpAddr string `yaml:"ipaddr" json:"ipaddr"` // the nacos server address Port uint64 `yaml:"port" json:"port"` // nacos server port GrpcPort uint64 `yaml:"grpcport" json:"grpcport"` // nacos server grpc port, default=server port + 1000, this is not required }
func (*SimpleServerConfig) ToNacosServerConfig ¶
func (c *SimpleServerConfig) ToNacosServerConfig() constant.ServerConfig
Source Files ¶
Click to show internal directories.
Click to hide internal directories.