nacos

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientConfig

type ClientConfig struct {
	ServerAddr  string
	ServerPort  uint64
	Username    string
	Password    string
	NamespaceId string
	Schema      string
	ContextPath string
	TLSOption   *tls.TLSOptions
	Proxy       func(reqURL *url.URL) (*url.URL, error)
}

type ClientOption

type ClientOption func(*ClientConfig)

func WithContextPath

func WithContextPath(path string) ClientOption

func WithNamespaceId

func WithNamespaceId(namespaceId string) ClientOption

WithNamespaceId ...

func WithPassword

func WithPassword(password string) ClientOption

WithPassword ...

func WithProxy

func WithProxy(addr string) ClientOption

func WithScheme

func WithScheme(scheme string) ClientOption

func WithServerAddr

func WithServerAddr(addr string) ClientOption

func WithServerPort

func WithServerPort(num uint64) ClientOption

func WithServerURL

func WithServerURL(u string) (ClientOption, error)

func WithTLSOption

func WithTLSOption(tlsOptions tls.TLSOptions) ClientOption

func WithUsername

func WithUsername(username string) ClientOption

WithUsername ...

type ConfigItem

type ConfigItem struct {
	Id      json.Number `param:"id"`
	DataId  string      `param:"dataId"`
	Group   string      `param:"group"`
	Content string      `param:"content"`
	Md5     string      `param:"md5"`
	Tenant  string      `param:"tenant"`
	Appname string      `param:"appname"`
}

type ConfigPage

type ConfigPage struct {
	TotalCount     int          `param:"totalCount"`
	PageNumber     int          `param:"pageNumber"`
	PagesAvailable int          `param:"pagesAvailable"`
	PageItems      []ConfigItem `param:"pageItems"`
}

type ConfigParam

type ConfigParam struct {
	DataId     string `param:"dataId"`  //required
	Group      string `param:"group"`   //required
	Content    string `param:"content"` //required
	Tag        string `param:"tag"`
	AppName    string `param:"appName"`
	Desc       string `param:"desc"`
	Effect     string `param:"effect"`
	BetaIps    string `param:"betaIps"`
	CasMd5     string `param:"casMd5"`
	Type       string `param:"type"`
	Schema     string `param:"schema"`
	SrcUser    string `param:"srcUser"`
	ConfigTags string `param:"configTags"`
	OnChange   OnChangeFunc
}

type ConfigQueryResponse

type ConfigQueryResponse struct {
	Error      string `json:"error"`
	Message    string `json:"message"`
	Code       int    `json:"code"`
	Data       string `json:"data"`
	ContentMd5 string `json:"-"`
	ConfigType string `json:"-"`
}

type DeleteConfigResponse

type DeleteConfigResponse struct {
	Timestamp time.Time `json:"timestamp"`
	Error     string    `json:"error"`
	Message   string    `json:"message"`
	Code      int       `json:"code"`
	Data      bool      `json:"data"`
}

type GetConfigResponse

type GetConfigResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    string `json:"data"`
}

type IConfigClient

type IConfigClient interface {
	// GetConfig use to get config from nacos server
	// dataId  require
	// group   require
	// tenant ==>nacos.namespace optional
	GetConfig(ctx context.Context, param ConfigParam) (string, error)

	// ListenConfig use to listen a config from nacos server
	// dataId  require
	// group   require
	// onChange require
	// tenant ==>nacos.namespace optional
	ListenConfig(ctx context.Context, param ConfigParam) (listenId string, data *ConfigQueryResponse)

	// PublishConfig use to publish config to nacos server
	// dataId  require
	// group   require
	// content require
	// tenant ==>nacos.namespace optional
	PublishConfig(ctx context.Context, param ConfigParam) (bool, error)

	// DeleteConfig use to delete config
	// dataId  require
	// group   require
	// tenant ==>nacos.namespace optional
	DeleteConfig(ctx context.Context, param ConfigParam) (bool, error)

	// SearchConfig use to search nacos config
	// search  require search=accurate--精确搜索  search=blur--模糊搜索
	// group   option
	// dataId  option
	// tenant ==>nacos.namespace optional
	// pageNo  option,default is 1
	// pageSize option,default is 10
	SearchConfig(ctx context.Context, param SearchConfigParam) (*ConfigPage, error)

	QueryConfig(ctx context.Context, param ConfigParam) (content *ConfigQueryResponse, err error)
}

func NewConfigClient

func NewConfigClient(ctx context.Context, opts ...ClientOption) (IConfigClient, error)

type LoginResponse

type LoginResponse struct {
	AccessToken string    `json:"accessToken"`
	TokenTTL    int       `json:"tokenTtl"`
	Timestamp   time.Time `json:"timestamp"`
	Error       string    `json:"error"`
	Message     string    `json:"message"`
	Path        string    `json:"path"`
}

type OnChangeFunc

type OnChangeFunc func(item *ConfigQueryResponse)

type PublishConfigResponse

type PublishConfigResponse struct {
	Timestamp time.Time `json:"timestamp"`
	Error     string    `json:"error"`
	Message   string    `json:"message"`
	Code      int       `json:"code"`
	Data      bool      `json:"data"`
}

type SearchConfigParam

type SearchConfigParam struct {
	Search   string `param:"search"`
	DataId   string `param:"dataId"`
	Group    string `param:"group"`
	Tag      string `param:"tag"`
	AppName  string `param:"appName"`
	PageNo   int    `param:"pageNo"`
	PageSize int    `param:"pageSize"`
}

Jump to

Keyboard shortcuts

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