etcd

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2019 License: Apache-2.0 Imports: 14 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) Get

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

Get 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"`
}

Config for a new etcd.Client.

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