client

package
v0.4.14 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyNotFound = errors.New("key not found")

Functions

This section is empty.

Types

type Client

type Client struct {
	*clientv3.Client
	// contains filtered or unexported fields
}

func New

func New(cfg *Config) (*Client, error)

func (*Client) Count

func (c *Client) Count(key string) (int64, error)

func (*Client) Exists

func (c *Client) Exists(key string) (bool, error)

func (*Client) Get

func (c *Client) Get(key string) ([]byte, error)

func (*Client) GetN

func (c *Client) GetN(key string) (int64, error)

func (*Client) Incr

func (c *Client) Incr(key string, timeout time.Duration) (int64, error)

func (*Client) IsHealthy

func (c *Client) IsHealthy(ctx context.Context) error

func (*Client) Lock

func (c *Client) Lock(key string, timeout time.Duration) (context.CancelFunc, error)

func (*Client) MustGet

func (c *Client) MustGet(ctx context.Context, key string) ([]byte, error)

MustGet blocks until the context is cancelled, an error is received, or the key is present. Returns the value of the key once present.

func (*Client) Prefix

func (c *Client) Prefix(key string) ([]*mvccpb.KeyValue, error)

func (*Client) Set

func (c *Client) Set(key, value string) error

func (*Client) SetOnce

func (c *Client) SetOnce(ctx context.Context, key, value string) (bool, error)

type Config

type Config struct {
	ClientURLs     []string
	SecurityConfig SecurityConfig
	Timeout        time.Duration

	// NOTE: AutoSync sets client endpoints based upon the current members.
	// This can cause the endpoints to become unreachable if the members are
	// not directly accessible (e.g. a terminating load balancer). This is
	// disabled by default and can be enabled by passed a non-zero duration.
	AutoSyncInterval time.Duration
}

type SecurityConfig

type SecurityConfig struct {
	CertFile      string
	KeyFile       string
	CertAuth      bool
	TrustedCAFile string
	AutoTLS       bool
}

func (SecurityConfig) Enabled

func (sc SecurityConfig) Enabled() bool

func (SecurityConfig) Scheme

func (sc SecurityConfig) Scheme() string

func (SecurityConfig) TLSInfo

func (sc SecurityConfig) TLSInfo() transport.TLSInfo

Jump to

Keyboard shortcuts

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