etcd

package
v0.0.0-...-7bf94b4 Latest Latest
Warning

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

Go to latest
Published: May 26, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultKeyFile    = "tls.key"
	DefaultCertFile   = "tls.crt"
	DefaultCACertFile = "ca.crt"
)
View Source
var (
	ErrReadConfig      = errors.New("etcd: read config")
	ErrWriteConfig     = errors.New("ercd: write config")
	ErrMarshalConfig   = errors.New("etcd: marshal config")
	ErrUnmarshalConfig = errors.New("etcd: unmarshal config")
)

Functions

func Connect

func Connect(ctx context.Context, tlsConfig *tls.Config, endpoint string, opts ...ConnectOpt) (*etcdv3.Client, error)

func LoadConfig

func LoadConfig(name string, config *Config) error

func TLSConfig

func TLSConfig(creds *Credentials, err error) (*tls.Config, error)

Types

type Config

type Config struct {
	Name    string `json:"name,omitempty"`
	DataDir string `json:"data-dir,omitempty"`
	WALDir  string `json:"wal-dir,omitempty"`

	SnapshotCount     int64 `json:"snapshot-count,omitempty"`
	HeartbeatInterval int64 `json:"heartbeat-interval,omitempty"`
	ElectionTimeout   int64 `json:"election-timeout,omitempty"`
	QuotaBackendBytes int64 `json:"quota-backend-bytes,omitempty"`

	ListenPeerURLs    string `json:"listen-peer-urls,omitempty"`
	ListenClientURLs  string `json:"listen-client-urls,omitempty"`
	ListenMetricsURLs string `json:"listen-metrics-urls,omitempty"`

	InitialAdvertisePeerURLs string `json:"initial-advertise-peer-urls,omitempty"`
	AdvertiseClientURLs      string `json:"advertise-client-urls,omitempty"`

	InitialCluster      string       `json:"initial-cluster,omitempty"`
	InitialClusterToken string       `json:"initial-cluster-token,omitempty"`
	InitialClusterState InitialState `json:"initial-cluster-state,omitempty"`

	ClientTransportSecurity *TransportSecurity `json:"client-transport-security,omitempty"`
	PeerTransportSecurity   *TransportSecurity `json:"peer-transport-security,omitempty"`

	StrictReconfigCheck bool     `json:"strict-reconfig-check,omitempty"`
	EnablePProf         bool     `json:"enable-pprof,omitempty"`
	LogLevel            LogLevel `json:"log-level,omitempty"`

	AutoCompactionMode      string `json:"auto-compaction-mode,omitempty"`
	AutoCompactionRetention string `json:"auto-compaction-retention,omitempty"`

	ExpInitialCorruptCheck         bool          `json:"experimental-initial-corrupt-check,omitempty"`
	ExpWatchProgressNotifyInterval time.Duration `json:"experimental-watch-progress-notify-interval,omitempty"`
}

func (Config) IsZero

func (c Config) IsZero() bool

type ConnectOpt

type ConnectOpt func(c *connectConfig)

func WithDialTimeout

func WithDialTimeout(timeout time.Duration) ConnectOpt

func WithLogger

func WithLogger(logger *zap.Logger) ConnectOpt

type Credentials

type Credentials struct {
	Key     []byte
	Cert    []byte
	CACert  []byte
	RenewAt time.Time
}

func LoadDir

func LoadDir(fsys fs.FS) (*Credentials, error)

func LoadSecret

func LoadSecret(ctx context.Context, kcl client.Client, key client.ObjectKey) (*Credentials, error)

func LoadTransportSecurity

func LoadTransportSecurity(ts TransportSecurity) (*Credentials, error)

func (*Credentials) TLSConfig

func (c *Credentials) TLSConfig(tlsConfig *tls.Config) error

func (*Credentials) WriteTransportSecurity

func (c *Credentials) WriteTransportSecurity(ts TransportSecurity) error

type InitialState

type InitialState string
const (
	InitialStateNew       InitialState = "new"
	InitialStateExisiting InitialState = "existing"
)

type LogLevel

type LogLevel string
const (
	LogLevelDebug LogLevel = "debug"
	LogLevelInfo  LogLevel = "info"
	LogLevelWarn  LogLevel = "warn"
	LogLevelError LogLevel = "error"
	LogLevelPanic LogLevel = "panic"
	LogLevelFatal LogLevel = "fatal"
)

type TLSCache

type TLSCache struct {
	// contains filtered or unexported fields
}

func NewTLSCache

func NewTLSCache(kcl client.Client, size int) (*TLSCache, error)

func (*TLSCache) Get

func (c *TLSCache) Get(ctx context.Context, key client.ObjectKey) (*tls.Config, error)

type TransportSecurity

type TransportSecurity struct {
	CertFile       string `json:"cert-file"`
	KeyFile        string `json:"key-file"`
	ClientCertAuth bool   `json:"client-cert-auth"`
	TrustedCAFile  string `json:"trusted-ca-file,omitempty"`
	AutoTLS        bool   `json:"auto-tls"`
}

Jump to

Keyboard shortcuts

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