etcdbk

package
v11.3.3 Latest Latest
Warning

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

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

Documentation

Overview

Package etcdbk implements Etcd powered backend

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetName

func GetName() string

GetName returns the name of etcd backend as it appears in 'storage/type' section in Teleport YAML file. This function is a part of backend API

Types

type Config

type Config struct {
	// Nodes is a list of nodes
	Nodes []string `json:"peers,omitempty"`
	// Key is an optional prefix for etcd
	Key string `json:"prefix,omitempty"`
	// TLSKeyFile is a private key, implies mTLS client authentication
	TLSKeyFile string `json:"tls_key_file,omitempty"`
	// TLSCertFile is a client certificate implies mTLS client authentication
	TLSCertFile string `json:"tls_cert_file,omitempty"`
	// TLSCAFile is a trusted certificate authority certificate
	TLSCAFile string `json:"tls_ca_file,omitempty"`
	// Insecure turns off TLS
	Insecure bool `json:"insecure,omitempty"`
	// BufferSize is a default buffer size
	// used to pull events
	BufferSize int `json:"buffer_size,omitempty"`
	// DialTimeout specifies dial timeout
	DialTimeout time.Duration `json:"dial_timeout,omitempty"`
	// Username is an optional username for HTTPS basic authentication
	Username string `json:"username,omitempty"`
	// Password is initialized from password file, and is not read from the config
	Password string `json:"-"`
	// PasswordFile is an optional password file for HTTPS basic authentication,
	// expects path to a file
	PasswordFile string `json:"password_file,omitempty"`
	// MaxClientMsgSizeBytes optionally specifies the size limit on client send message size.
	// See https://github.com/etcd-io/etcd/blob/221f0cc107cb3497eeb20fb241e1bcafca2e9115/clientv3/config.go#L49
	MaxClientMsgSizeBytes int `json:"etcd_max_client_msg_size_bytes,omitempty"`
}

Config represents JSON config for etcd backend

func (*Config) Validate

func (cfg *Config) Validate() error

Validate checks if all the parameters are present/valid

type EtcdBackend

type EtcdBackend struct {
	*log.Entry
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, params backend.Params, opts ...Option) (*EtcdBackend, error)

New returns new instance of Etcd-powered backend

func (*EtcdBackend) Clock

func (b *EtcdBackend) Clock() clockwork.Clock

func (*EtcdBackend) Close

func (b *EtcdBackend) Close() error

func (*EtcdBackend) CloseWatchers

func (b *EtcdBackend) CloseWatchers()

CloseWatchers closes all the watchers without closing the backend

func (*EtcdBackend) CompareAndSwap

func (b *EtcdBackend) CompareAndSwap(ctx context.Context, expected backend.Item, replaceWith backend.Item) (*backend.Lease, error)

CompareAndSwap compares item with existing item and replaces is with replaceWith item

func (*EtcdBackend) Create

func (b *EtcdBackend) Create(ctx context.Context, item backend.Item) (*backend.Lease, error)

Create creates item if it does not exist

func (*EtcdBackend) Delete

func (b *EtcdBackend) Delete(ctx context.Context, key []byte) error

Delete deletes item by key

func (*EtcdBackend) DeleteRange

func (b *EtcdBackend) DeleteRange(ctx context.Context, startKey, endKey []byte) error

DeleteRange deletes range of items with keys between startKey and endKey

func (*EtcdBackend) Get

func (b *EtcdBackend) Get(ctx context.Context, key []byte) (*backend.Item, error)

Get returns a single item or not found error

func (*EtcdBackend) GetRange

func (b *EtcdBackend) GetRange(ctx context.Context, startKey, endKey []byte, limit int) (*backend.GetResult, error)

GetRange returns query range

func (*EtcdBackend) KeepAlive

func (b *EtcdBackend) KeepAlive(ctx context.Context, lease backend.Lease, expires time.Time) error

KeepAlive updates TTL on the lease ID

func (*EtcdBackend) NewWatcher

func (b *EtcdBackend) NewWatcher(ctx context.Context, watch backend.Watch) (backend.Watcher, error)

NewWatcher returns a new event watcher

func (*EtcdBackend) Put

func (b *EtcdBackend) Put(ctx context.Context, item backend.Item) (*backend.Lease, error)

Put puts value into backend (creates if it does not exists, updates it otherwise)

func (*EtcdBackend) Update

func (b *EtcdBackend) Update(ctx context.Context, item backend.Item) (*backend.Lease, error)

Update updates value in the backend

type Option

type Option func(*options)

Option is an etcd backend functional option (used in tests).

func Clock

func Clock(clock clockwork.Clock) Option

Clock overrides the default clockwork.Clock

func LeaseBucket

func LeaseBucket(d time.Duration) Option

LeaseBucket overrides the default lease bucketing size

Jump to

Keyboard shortcuts

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