etcd

package
v0.55.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Endpoints            []string      `fig:"endpoints" default:"[http://localhost:2379]"`
	DialTimeout          time.Duration `fig:"dial_timeout" default:"20s"`
	DialKeepAliveTime    time.Duration `fig:"dial_keep_alive_time" default:"30s"`
	DialKeepAliveTimeout time.Duration `fig:"dial_keep_alive_timeout" default:"10s"`
	KeepAliveTime        time.Duration `fig:"keep_alive" default:"10s"`
	Timeout              time.Duration `fig:"keep_alive" default:"20m"`
}

Config contains etcd configuration parameters.

type KV

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

KV represents an etcd key-value store implementation.

func NewKV

func NewKV(cfg Config) *KV

NewKV returns a new etcd key-value store instance.

func (*KV) Del

func (k *KV) Del(ctx context.Context, key string) error

Del deletes a value associated to a given key.

func (*KV) Get

func (k *KV) Get(ctx context.Context, key string) ([]byte, error)

Get retrieves a value associated to a given key.

func (*KV) GetPrefix

func (k *KV) GetPrefix(ctx context.Context, prefix string) (map[string][]byte, error)

GetPrefix retrieves all values whose key matches prefix.

func (*KV) Put

func (k *KV) Put(ctx context.Context, key string, value string) error

Put stores a new value associated to a given key.

func (*KV) Start

func (k *KV) Start(ctx context.Context) error

Start initializes etcd key-value store.

func (*KV) Stop

func (k *KV) Stop(ctx context.Context) error

Stop closes etcd underlying connection.

func (*KV) Watch

func (k *KV) Watch(ctx context.Context, prefix string, withPrevVal bool) <-chan kv.WatchResp

Watch watches on a key or prefix.

type Locker

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

Locker defines etcd locker.Locker implementation.

func NewLocker

func NewLocker(cfg Config) *Locker

NewLocker returns a new initialized etcd locker.

func (*Locker) AcquireLock

func (l *Locker) AcquireLock(ctx context.Context, lockID string) (locker.Lock, error)

AcquireLock acquires and returns an etcd locker.

func (*Locker) Start

func (l *Locker) Start(_ context.Context) error

Start starts etcd locker.

func (*Locker) Stop

func (l *Locker) Stop(_ context.Context) error

Stop stops etcd locker.

Jump to

Keyboard shortcuts

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