etcd

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateEventFunc

type CreateEventFunc func(ctx context.Context, key, value []byte)

CreateEventFunc defines etcd create event function handler.

type DeleteEventFunc

type DeleteEventFunc func(ctx context.Context, key []byte)

DeleteEventFunc defines etcd delete event function handler.

type KeyValue

type KeyValue struct {
	Key   string
	Value []byte
}

KeyValue defines etcd returned key-value pairs.

type Options

type Options struct {
	Endpoints      []string      `json:"endpoints"       mapstructure:"endpoints"`
	Username       string        `json:"username"        mapstructure:"username"`
	Password       string        `json:"password"        mapstructure:"password"`
	Namespace      string        `json:"namespace"       mapstructure:"namespace"`
	TLS            TLSOptions    `json:"tls"             mapstructure:"tls"`
	Timeout        time.Duration `json:"timeout"         mapstructure:"timeout"`
	RequestTimeout time.Duration `json:"request-timeout" mapstructure:"request-timeout"`
	LeaseExpire    time.Duration `json:"lease-expire"    mapstructure:"lease-expire"`
}

Options defines options for etcd cluster.

func NewOptions

func NewOptions() *Options

NewOptions create a new options instance.

func (*Options) AddFlags

func (o *Options) AddFlags(fs *pflag.FlagSet)

AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.

func (*Options) Validate

func (o *Options) Validate() []error

Validate verifies flags passed to RedisOptions.

type Store

type Store interface {
	RawClient() *clientv3.Client
	Put(ctx context.Context, key string, val string) error
	PutWithSession(ctx context.Context, key string, val string) error
	PutWithLease(ctx context.Context, key string, val string, ttlSeconds int64) error
	Get(ctx context.Context, key string) ([]byte, error)
	List(ctx context.Context, prefix string) ([]KeyValue, error)
	Delete(ctx context.Context, key string) ([]byte, error)
	Watch(ctx context.Context, prefix string,
		onCreate CreateEventFunc, onUpdate UpdateEventFunc, onDelete DeleteEventFunc) error
	Unwatch(prefix string)
	Close() error
}

Store defines the interface of etcd store.

func New

func New(opts *Options) Store

New creates a new etcd client store.

type TLSOptions

type TLSOptions struct {
	Enabled bool `json:"enabled"          mapstructure:"enabled"`
	// CertFile is a file containing a PEM-encoded certificate, and possibly the complete certificate chain
	CertFile string `json:"cert-file"        mapstructure:"cert-file"`
	// KeyFile is a file containing a PEM-encoded private key for the certificate specified by CertFile
	KeyFile string `json:"private-key-file" mapstructure:"private-key-file"`
}

TLSOptions contains configuration for TLS.

type UpdateEventFunc

type UpdateEventFunc func(ctx context.Context, key, oldvalue, value []byte)

UpdateEventFunc defines etcd update event function handler.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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