constant

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KEY_USERNAME                = "username"
	KEY_PASSWORD                = "password"
	KEY_ENDPOINT                = "endpoint"
	KEY_NAME_SPACE              = "namespace"
	KEY_ACCESS_KEY              = "accessKey"
	KEY_SECRET_KEY              = "secretKey"
	KEY_SERVER_ADDR             = "serverAddr"
	KEY_CONTEXT_PATH            = "contextPath"
	KEY_ENCODE                  = "encode"
	KEY_DATA_ID                 = "dataId"
	KEY_GROUP                   = "group"
	KEY_TENANT                  = "tenant"
	KEY_DESC                    = "desc"
	KEY_APP_NAME                = "appName"
	KEY_CONTENT                 = "content"
	KEY_TIMEOUT_MS              = "timeoutMs"
	KEY_LISTEN_INTERVAL         = "listenInterval"
	KEY_SERVER_CONFIGS          = "serverConfigs"
	KEY_CLIENT_CONFIG           = "clientConfig"
	KEY_TOKEN                   = "token"
	KEY_ACCESS_TOKEN            = "accessToken"
	KEY_TOKEN_TTL               = "tokenTtl"
	KEY_GLOBAL_ADMIN            = "globalAdmin"
	KEY_TOKEN_REFRESH_WINDOW    = "tokenRefreshWindow"
	WEB_CONTEXT                 = "/nacos"
	CONFIG_BASE_PATH            = "/v1/cs"
	CONFIG_PATH                 = CONFIG_BASE_PATH + "/configs"
	CONFIG_AGG_PATH             = "/datum.do"
	CONFIG_LISTEN_PATH          = CONFIG_BASE_PATH + "/configs/listener"
	SERVICE_BASE_PATH           = "/v1/ns"
	SERVICE_PATH                = SERVICE_BASE_PATH + "/instance"
	SERVICE_INFO_PATH           = SERVICE_BASE_PATH + "/service"
	SERVICE_SUBSCRIBE_PATH      = SERVICE_PATH + "/list"
	NAMESPACE_PATH              = "/v1/console/namespaces"
	SPLIT_CONFIG                = string(rune(1))
	SPLIT_CONFIG_INNER          = string(rune(2))
	KEY_LISTEN_CONFIGS          = "Listening-Configs"
	KEY_SERVICE_NAME            = "serviceName"
	KEY_IP                      = "ip"
	KEY_PORT                    = "port"
	KEY_WEIGHT                  = "weight"
	KEY_ENABLE                  = "enable"
	KEY_HEALTHY                 = "healthy"
	KEY_METADATA                = "metadata"
	KEY_CLUSTER_NAME            = "clusterName"
	KEY_CLUSTER                 = "cluster"
	KEY_BEAT                    = "beat"
	KEY_DOM                     = "dom"
	DEFAULT_CONTEXT_PATH        = "/nacos"
	CLIENT_VERSION              = "Nacos-Go-Client:v2.2.6"
	REQUEST_DOMAIN_RETRY_TIME   = 3
	SERVICE_INFO_SPLITER        = "@@"
	CONFIG_INFO_SPLITER         = "@@"
	DEFAULT_NAMESPACE_ID        = "public"
	DEFAULT_GROUP               = "DEFAULT_GROUP"
	NAMING_INSTANCE_ID_SPLITTER = "#"
	DefaultClientErrorCode      = "SDK.NacosError"
	DEFAULT_SERVER_SCHEME       = "http"
	HTTPS_SERVER_SCHEME         = "https"
	LABEL_SOURCE                = "source"
	LABEL_SOURCE_SDK            = "sdk"
	LABEL_MODULE                = "module"
	LABEL_MODULE_CONFIG         = "config"
	LABEL_MODULE_NAMING         = "naming"
	RESPONSE_CODE_SUCCESS       = 200
	UN_REGISTER                 = 301
	KEEP_ALIVE_TIME             = 5
	DEFAULT_TIMEOUT_MILLS       = 3000
	ALL_SYNC_INTERNAL           = 5 * time.Minute
	CLIENT_APPNAME_HEADER       = "Client-AppName"
	APPNAME_HEADER              = "AppName"
	CLIENT_REQUEST_TS_HEADER    = "Client-RequestTS"
	CLIENT_REQUEST_TOKEN_HEADER = "Client-RequestToken"
	EX_CONFIG_INFO              = "exConfigInfo"
	CHARSET_KEY                 = "charset"
	LOG_FILE_NAME               = "nacos-sdk.log"
	HTTPS_SERVER_PORT           = 443
	GRPC                        = "grpc"
	RpcPortOffset               = 1000
	MSE_KMSv1_DEFAULT_KEY_ID    = "alias/acs/mse"
)
View Source
const (
	HEART_BEAT_TIMEOUT  = "preserved.heart.beat.timeout"
	IP_DELETE_TIMEOUT   = "preserved.ip.delete.timeout"
	HEART_BEAT_INTERVAL = "preserved.heart.beat.interval"
)

Variables

View Source
var SkipVerifyConfig = TLSConfig{Enable: true}

Functions

This section is empty.

Types

type ClientConfig

type ClientConfig struct {
	TimeoutMs            uint64                   // timeout for requesting Nacos server, default value is 10000ms
	ListenInterval       uint64                   // Deprecated
	BeatInterval         int64                    // the time interval for sending beat to server,default value is 5000ms
	NamespaceId          string                   // the namespaceId of Nacos.When namespace is public, fill in the blank string here.
	AppName              string                   // the appName
	AppKey               string                   // the client identity information
	Endpoint             string                   // the endpoint for get Nacos server addresses
	RegionId             string                   // the regionId for kms
	AccessKey            string                   // the AccessKey for kms
	SecretKey            string                   // the SecretKey for kms
	OpenKMS              bool                     // it's to open kms, default is false. https://help.aliyun.com/product/28933.html
	KMSVersion           KMSVersion               // kms client version. https://help.aliyun.com/document_detail/380927.html
	KMSv3Config          *KMSv3Config             //KMSv3 configuration. https://help.aliyun.com/document_detail/601596.html
	CacheDir             string                   // the directory for persist nacos service info,default value is current path
	DisableUseSnapShot   bool                     // It's a switch, default is false, means that when get remote config fail, use local cache file instead
	UpdateThreadNum      int                      // the number of goroutine for update nacos service info,default value is 20
	NotLoadCacheAtStart  bool                     // not to load persistent nacos service info in CacheDir at start time
	UpdateCacheWhenEmpty bool                     // update cache when get empty service instance from server
	Username             string                   // the username for nacos auth
	Password             string                   // the password for nacos auth
	LogDir               string                   // the directory for log, default is current path
	LogLevel             string                   // the level of log, it's must be debug,info,warn,error, default value is info
	ContextPath          string                   // the nacos server contextpath
	AppendToStdout       bool                     // if append log to stdout
	LogSampling          *ClientLogSamplingConfig // the sampling config of log
	LogRollingConfig     *ClientLogRollingConfig  // log rolling config
	TLSCfg               TLSConfig                // tls Config
	AsyncUpdateService   bool                     // open async update service by query
	EndpointContextPath  string                   // the address server  endpoint contextPath
	EndpointQueryParams  string                   // the address server  endpoint query params
	ClusterName          string                   // the address server  clusterName
	AppConnLabels        map[string]string        // app conn labels
}

func NewClientConfig

func NewClientConfig(opts ...ClientOption) *ClientConfig

type ClientLogRollingConfig

type ClientLogRollingConfig struct {
	// MaxSize is the maximum size in megabytes of the log file before it gets
	// rotated. It defaults to 100 megabytes.
	MaxSize int

	// MaxAge is the maximum number of days to retain old log files based on the
	// timestamp encoded in their filename.  Note that a day is defined as 24
	// hours and may not exactly correspond to calendar days due to daylight
	// savings, leap seconds, etc. The default is not to remove old log files
	// based on age.
	MaxAge int

	// MaxBackups is the maximum number of old log files to retain.  The default
	// is to retain all old log files (though MaxAge may still cause them to get
	// deleted.)
	MaxBackups int

	// LocalTime determines if the time used for formatting the timestamps in
	// backup files is the computer's local time.  The default is to use UTC
	// time.
	LocalTime bool

	// Compress determines if the rotated log files should be compressed
	// using gzip. The default is not to perform compression.
	Compress bool
}

type ClientLogSamplingConfig

type ClientLogSamplingConfig struct {
	Initial    int           //the sampling initial of log
	Thereafter int           //the sampling thereafter of log
	Tick       time.Duration //the sampling tick of log
}

type ClientOption

type ClientOption func(*ClientConfig)

ClientOption ...

func WithAccessKey

func WithAccessKey(accessKey string) ClientOption

WithAccessKey ...

func WithAppConnLabels added in v1.2.5

func WithAppConnLabels(appConnLabels map[string]string) ClientOption

func WithAppName

func WithAppName(appName string) ClientOption

WithAppName ...

func WithBeatInterval

func WithBeatInterval(beatInterval int64) ClientOption

WithBeatInterval ...

func WithCacheDir

func WithCacheDir(cacheDir string) ClientOption

WithCacheDir ...

func WithClusterName added in v1.2.5

func WithClusterName(clusterName string) ClientOption

WithClusterName ...

func WithDisableUseSnapShot added in v1.2.5

func WithDisableUseSnapShot(disableUseSnapShot bool) ClientOption

WithDisableUseSnapShot ...

func WithEndpoint

func WithEndpoint(endpoint string) ClientOption

WithEndpoint ...

func WithEndpointContextPath added in v1.2.5

func WithEndpointContextPath(endpointContextPath string) ClientOption

WithEndpointContextPath ...

func WithEndpointQueryParams added in v1.2.5

func WithEndpointQueryParams(endpointQueryPrams string) ClientOption

WithEndpointQueryParams ...

func WithKMSVersion added in v1.2.5

func WithKMSVersion(kmsVersion KMSVersion) ClientOption

WithOpenKMS ...

func WithKMSv3Config added in v1.2.5

func WithKMSv3Config(kmsv3Config *KMSv3Config) ClientOption

func WithLogDir

func WithLogDir(logDir string) ClientOption

WithLogDir ...

func WithLogLevel

func WithLogLevel(logLevel string) ClientOption

WithLogLevel ...

func WithLogRollingConfig

func WithLogRollingConfig(rollingConfig *ClientLogRollingConfig) ClientOption

WithLogRollingConfig ...

func WithLogSampling

func WithLogSampling(tick time.Duration, initial int, thereafter int) ClientOption

WithLogSampling ...

func WithNamespaceId

func WithNamespaceId(namespaceId string) ClientOption

WithNamespaceId ...

func WithNotLoadCacheAtStart

func WithNotLoadCacheAtStart(notLoadCacheAtStart bool) ClientOption

WithNotLoadCacheAtStart ...

func WithOpenKMS

func WithOpenKMS(openKMS bool) ClientOption

WithOpenKMS ...

func WithPassword

func WithPassword(password string) ClientOption

WithPassword ...

func WithRegionId

func WithRegionId(regionId string) ClientOption

WithRegionId ...

func WithSecretKey

func WithSecretKey(secretKey string) ClientOption

WithSecretKey ...

func WithTLS

func WithTLS(tlsCfg TLSConfig) ClientOption

func WithTimeoutMs

func WithTimeoutMs(timeoutMs uint64) ClientOption

WithTimeoutMs ...

func WithUpdateCacheWhenEmpty

func WithUpdateCacheWhenEmpty(updateCacheWhenEmpty bool) ClientOption

WithUpdateCacheWhenEmpty ...

func WithUpdateThreadNum

func WithUpdateThreadNum(updateThreadNum int) ClientOption

WithUpdateThreadNum ...

func WithUsername

func WithUsername(username string) ClientOption

WithUsername ...

type KMSVersion added in v1.2.5

type KMSVersion string
const (
	KMSv1               KMSVersion = "KMSv1"
	KMSv3               KMSVersion = "KMSv3"
	DEFAULT_KMS_VERSION KMSVersion = "" //to fit original version
	UNKNOWN_KMS_VERSION KMSVersion = "UNKNOWN_KMS_VERSION"
)

type KMSv3Config added in v1.2.5

type KMSv3Config struct {
	ClientKeyContent string
	Password         string
	Endpoint         string
	CaContent        string
}

type ServerConfig

type ServerConfig struct {
	Scheme      string // the nacos server scheme,default=http,this is not required in 2.0
	ContextPath string // the nacos server contextpath,default=/nacos,this is not required in 2.0
	IpAddr      string // the nacos server address
	Port        uint64 // nacos server port
	GrpcPort    uint64 // nacos server grpc port, default=server port + 1000, this is not required
}

func NewServerConfig

func NewServerConfig(ipAddr string, port uint64, opts ...ServerOption) *ServerConfig

type ServerOption

type ServerOption func(*ServerConfig)

ServerOption ...

func WithContextPath

func WithContextPath(contextPath string) ServerOption

WithContextPath set contextPath for server

func WithGrpcPort added in v1.2.5

func WithGrpcPort(port uint64) ServerOption

WithGrpcPort set grpc port for server

func WithIpAddr

func WithIpAddr(ipAddr string) ServerOption

WithIpAddr set ip address for server

func WithPort

func WithPort(port uint64) ServerOption

WithPort set port for server

func WithScheme

func WithScheme(scheme string) ServerOption

WithScheme set Scheme for server

type TLSConfig

type TLSConfig struct {
	Appointed          bool   // Appointed or not ,if false,will get from env.
	Enable             bool   // enable tls
	TrustAll           bool   // trust all server
	CaFile             string // clients use when verifying server certificates
	CertFile           string // server use when verifying client certificates
	KeyFile            string // server use when verifying client certificates
	ServerNameOverride string // serverNameOverride is for testing only
}

func NewTLSConfig

func NewTLSConfig(opts ...TLSOption) *TLSConfig

type TLSOption

type TLSOption func(*TLSConfig)

func WithCA

func WithCA(caFile, serverNameOverride string) TLSOption

func WithCertificate

func WithCertificate(certFile, keyFile string) TLSOption

Jump to

Keyboard shortcuts

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