etcd

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	EtcdDefaultNode         = "http://127.0.0.1:2379"
	EtcdDefaultConfigPrefix = "/KitexConfig"
	EtcdDefaultTimeout      = 5 * time.Second
	EtcdDefaultClientPath   = "{{.ClientServiceName}}/{{.ServerServiceName}}/{{.Category}}"
	EtcdDefaultServerPath   = "{{.ServerServiceName}}/{{.Category}}"
)

Variables

This section is empty.

Functions

func AllocateUniqueID

func AllocateUniqueID() int64

Types

type Client

type Client interface {
	SetParser(ConfigParser)
	ClientConfigParam(cpc *ConfigParamConfig, cfs ...CustomFunction) (Key, error)
	ServerConfigParam(cpc *ConfigParamConfig, cfs ...CustomFunction) (Key, error)
	RegisterConfigCallback(ctx context.Context, key string, clientId int64, callback func(restoreDefault bool, data string, parser ConfigParser))
	DeregisterConfig(key string, uniqueId int64)
}

func NewClient

func NewClient(opts Options) (Client, error)

NewClient Create a default etcd client It can create a client with default config by env variable. See: env.go

type ConfigParamConfig

type ConfigParamConfig struct {
	Category          string
	ClientServiceName string
	ServerServiceName string
}

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

type ConfigParser

type ConfigParser interface {
	Decode(data string, config interface{}) error
}

ConfigParser the parser for etcd config.

type CustomFunction

type CustomFunction func(*Key)

CustomFunction use for customize the config parameters.

type Key

type Key struct {
	Prefix string
	Path   string
}

type Options

type Options struct {
	Node             []string
	Prefix           string
	ServerPathFormat string
	ClientPathFormat string
	Timeout          time.Duration
	LoggerConfig     *zap.Config
	ConfigParser     ConfigParser
}

Options etcd 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