etcd

package
v0.0.0-...-a385994 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: AGPL-3.0, AGPL-3.0-or-later Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultDialTimeout is the default dial timeout for the etc client.
	DefaultDialTimeout = 5 * time.Second
	// DefaultRequestTimeout is the default request timeout for the etc client.
	DefaultRequestTimeout = 5 * time.Second
	// DefaultCacheTimeout is the default timeout for a health check when waiting for a response from the cache.
	DefaultCacheTimeout = 2 * time.Second
	// DefaultEndpoint is the default etcd endpoint.
	DefaultEndpoint = "localhost:2379"
)

Variables

View Source
var (
	// ErrKeyNotFound is the error returned when the key requested is not found.
	ErrKeyNotFound = errors.New("key not found")
	// ErrTxNotWritable is the error returned when an mutable operation is called during
	// a non-writable transaction.
	ErrTxNotWritable = errors.New("transaction is not writable")
)

Functions

func NewClient

func NewClient(ctx context.Context, opts ...Option) (*client, error)

NewClient creates an etcd client implementing the kv.Store interface.

Types

type Bucket

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

Bucket is a key value bucket.

func (*Bucket) Delete

func (b *Bucket) Delete(key []byte) error

Delete removes the key from the database.

func (*Bucket) ForEach

func (b *Bucket) ForEach(fn func(k, v []byte) error) error

ForEach loops over all bucket entries and applies fn to them.

func (*Bucket) Get

func (b *Bucket) Get(key []byte) ([]byte, error)

Get gets the value at the provided key.

func (*Bucket) NextSequence

func (b *Bucket) NextSequence() (uint64, error)

NextSequence generates a universally unique uint64.

func (*Bucket) Put

func (b *Bucket) Put(key []byte, value []byte) error

Put puts the provided key and value in the store.

type Option

type Option func(c *client) error

Option to change behavior of Open()

func WithDialTimeout

func WithDialTimeout(d time.Duration) Option

WithDialTimeout allows for setting the etcd dial timeout.

func WithEndpoints

func WithEndpoints(h []string) Option

WithEndpoints allows for setting the etcd hosts.

func WithLogger

func WithLogger(logger cloudhub.Logger) Option

WithLogger allows for setting this cloudhub's logger.

func WithLogin

func WithLogin(u, p string) Option

WithLogin allows for setting the username and password to connect to the etcd cluster.

func WithRequestTimeout

func WithRequestTimeout(d time.Duration) Option

WithRequestTimeout allows for setting the etcd request timeout.

type Pair

type Pair struct {
	Key   []byte
	Value []byte
}

Pair is a struct for key value pairs.

type Tx

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

Tx is a etcd transaction.

func (*Tx) Bucket

func (t *Tx) Bucket(b []byte) kv.Bucket

Bucket creates a bucket struct with the provided bucket.

func (*Tx) CreateBucketIfNotExists

func (t *Tx) CreateBucketIfNotExists(b []byte) (kv.Bucket, error)

CreateBucketIfNotExists creates a bucket with the provided byte slice.

Jump to

Keyboard shortcuts

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