nacos

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 14 Imported by: 4

Documentation

Index

Constants

View Source
const (
	NacosAliServerAddrEnv = "serverAddr"
	NacosAliPortEnv       = "serverPort"
	NacosAliNamespaceEnv  = "namespace"
)

keep consistent with the env with alicloud

View Source
const (
	NacosDefaultServerAddr   = "127.0.0.1"
	NacosDefaultPort         = 8848
	NacosDefaultConfigGroup  = "DEFAULT_GROUP"
	NacosDefaultClientDataID = "{{.ClientServiceName}}.{{.ServerServiceName}}.{{.Category}}"
	NacosDefaultServerDataID = "{{.ServerServiceName}}.{{.Category}}"
)

Variables

This section is empty.

Functions

func GetUniqueID added in v0.3.0

func GetUniqueID() int64

GetUniqueID get the unique id

func NacosAddr added in v0.4.0

func NacosAddr() string

NacosAddr Get Nacos addr from environment variables

func NacosNameSpaceId added in v0.4.0

func NacosNameSpaceId() string

NacosNameSpaceId Get Nacos namespace id from environment variables

func NacosPort added in v0.4.0

func NacosPort() uint64

NacosPort Get Nacos port from environment variables

func NewCustomNacosLogger

func NewCustomNacosLogger() logger.Logger

Types

type Client

type Client interface {
	SetParser(ConfigParser)
	ClientConfigParam(cpc *ConfigParamConfig) (vo.ConfigParam, error)
	ServerConfigParam(cpc *ConfigParamConfig) (vo.ConfigParam, error)
	RegisterConfigCallback(vo.ConfigParam, func(string, ConfigParser), int64)
	DeregisterConfig(vo.ConfigParam, int64) error
}

Client the wrapper of nacos client.

func NewClient added in v0.2.0

func NewClient(opts Options) (Client, error)

NewClient Create a default Nacos client

type ConfigParamConfig

type ConfigParamConfig struct {
	Category          string
	ClientServiceName string
	ServerServiceName string
}

ConfigParamConfig use for render the dataId or group info by go template, ref: https://pkg.go.dev/text/template The fixed key shows as below.

type ConfigParser

type ConfigParser interface {
	Decode(kind vo.ConfigType, data string, config interface{}) error
}

ConfigParser the parser for nacos config.

type CustomFunction

type CustomFunction func(*vo.ConfigParam)

CustomFunction use for customize the config parameters.

type Options

type Options struct {
	Address            string
	Port               uint64
	NamespaceID        string
	RegionID           string
	Group              string
	ServerDataIDFormat string
	ClientDataIDFormat string
	CustomLogger       logger.Logger
	Password           string
	Username           string
	ConfigParser       ConfigParser
}

Options nacos config options. All the fields have default value.

Jump to

Keyboard shortcuts

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