nacosKit

package
v2.9.114 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultNamespaceId = constant.DEFAULT_NAMESPACE_ID

	DefaultGroup = constant.DEFAULT_GROUP
)

Variables

View Source
var (
	NotSetUpError = errorKit.New("Haven’t been set up correctly")
)

Functions

func GetClientConfigCopy

func GetClientConfigCopy(options ...constant.ClientOption) (*constant.ClientConfig, error)

func GetNamespaceId added in v2.8.118

func GetNamespaceId() (string, error)

GetNamespaceId

PS: 如果一个服务仅使用一个NamespaceId,可以调用此方法.

func MustSetUp

func MustSetUp(config *Config, options ...constant.ClientOption)

func NewConfigClient

func NewConfigClient(options ...constant.ClientOption) (config_client.IConfigClient, error)

NewConfigClient 创建 动态配置(config) 客户端.

!!!: (1) 需要先set up. (2) config_client.IConfigClient 实例,如果不用了需要"手动关闭".

@param options 可以用于修改: NamespaceId、CacheDir、LogDir、LogLevel...

func NewNamingClient

func NewNamingClient(options ...constant.ClientOption) (naming_client.INamingClient, error)

NewNamingClient 创建 服务发现(naming) 客户端.

!!!: (1) 需要先set up; (2) naming_client.INamingClient 实例,如果不用了需要"手动关闭"; (3) !!!: 不要在 Nacos管理页面 上修改服务实例的信息(weight等),否则可能导致后续 RegisterInstance 、UpdateInstance 会失败(虽然方法返回true, nil).

@param options 可以用于修改: NamespaceId...

func SetUp

func SetUp(config *Config, options ...constant.ClientOption) (err error)

SetUp

@param options !!!:

(1) 建议配置 客户端的缓存目录(default is current path)		constant.WithCacheDir
(2) 建议配置 客户端的日志目录(default is current path)		constant.WithLogDir
(3) 建议配置 客户端的日志级别(default value is info)		constant.WithLogLevel	"debug" || "info"(默认)...

Types

type Config

type Config struct {
	// NamespaceId 命名空间的id,配置 "" 和 "public" 效果一样(都是使用保留空间public)
	NamespaceId string `json:"namespaceId" yaml:"namespaceId" validate:"omitempty,gte=6"`

	Addrs []string `json:"addrs" yaml:"addrs" validate:"required,dive,http_url"`
}

Jump to

Keyboard shortcuts

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