etcd

package
v1.3.0-rc.1.0...-65594da Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NopCloser = CloserFunc(func() error {
	return nil
})

NopCloser does nothing.

Functions

This section is empty.

Types

type Client

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

Client implements ring.KVClient for etcd.

func Mock

func Mock(codec codec.Codec) (*Client, io.Closer, error)

Mock returns a Mock Etcd client. Inspired by https://github.com/ligato/cn-infra/blob/master/db/keyval/etcd/mocks/embeded_etcd.go.

func New

func New(cfg Config, codec codec.Codec) (*Client, error)

New makes a new Client.

func (*Client) CAS

func (c *Client) CAS(ctx context.Context, key string, f func(in interface{}) (out interface{}, retry bool, err error)) error

CAS implements kv.Client.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, key string) error

Delete implements kv.Client.

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string) (interface{}, error)

Get implements kv.Client.

func (*Client) List

func (c *Client) List(ctx context.Context, prefix string) ([]string, error)

List implements kv.Client.

func (*Client) WatchKey

func (c *Client) WatchKey(ctx context.Context, key string, f func(interface{}) bool)

WatchKey implements kv.Client.

func (*Client) WatchPrefix

func (c *Client) WatchPrefix(ctx context.Context, key string, f func(string, interface{}) bool)

WatchPrefix implements kv.Client.

type CloserFunc

type CloserFunc func() error

CloserFunc is like http.HandlerFunc but for io.Closers.

func (CloserFunc) Close

func (f CloserFunc) Close() error

Close implements io.Closer.

type Config

type Config struct {
	Endpoints          []string      `yaml:"endpoints"`
	DialTimeout        time.Duration `yaml:"dial_timeout"`
	MaxRetries         int           `yaml:"max_retries"`
	EnableTLS          bool          `yaml:"tls_enabled"`
	CertFile           string        `yaml:"tls_cert_path"`
	KeyFile            string        `yaml:"tls_key_path"`
	TrustedCAFile      string        `yaml:"tls_ca_path"`
	InsecureSkipVerify bool          `yaml:"tls_insecure_skip_verify"`
}

Config for a new etcd.Client.

func (*Config) GetTLS

func (cfg *Config) GetTLS() (*tls.Config, error)

GetTLS sets the TLS config field with certs

func (*Config) RegisterFlags

func (cfg *Config) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet.

func (*Config) RegisterFlagsWithPrefix

func (cfg *Config) RegisterFlagsWithPrefix(f *flag.FlagSet, prefix string)

RegisterFlagsWithPrefix adds the flags required to config this to the given FlagSet.

Jump to

Keyboard shortcuts

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