etcd

package
v4.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultVersion of etcd DB
	DefaultVersion = "3"

	// DefaultHost IP address
	DefaultHost = "127.0.0.1"

	// DefaultPort number for client
	DefaultPort = "2379"

	// DefaultDialTimeout in seconds
	DefaultDialTimeout = 30 * time.Second

	// DefaultRequestTimeout in seconds
	DefaultRequestTimeout = 5 * time.Second
)

Functions

func Delete

func Delete(key string) error

Delete the given key

func Get

func Get(key string) (*string, error)

Get value for the given key

func Put

func Put(key string, value string) error

Put value for the given key and value

Types

type DBClient

type DBClient struct {
	Version   string
	EndPoints []string
	Client    *v3.Client
}

DBClient is an implementor of the DBService interface

func NewClient

func NewClient(endPoints []string, version string) (*DBClient, error)

NewClient creates new client instance for list of endpoints to access the DB server

func NewClientV3

func NewClientV3(endPoints []string) (*DBClient, error)

NewClientV3 creates v3 client instance to access the DB server

func (*DBClient) AcquireLock

func (d *DBClient) AcquireLock(key string, ttl int) (lock.Lock, error)

AcquireLock for the given key

func (*DBClient) CloseClient

func (d *DBClient) CloseClient() error

CloseClient closes the DB client

func (*DBClient) Delete

func (d *DBClient) Delete(key string) error

Delete value from DB

func (*DBClient) Get

func (d *DBClient) Get(key string) (*string, error)

Get value from DB

func (*DBClient) IsLocked

func (d *DBClient) IsLocked(key string) (bool, error)

IsLocked checks if the given key is already locked

func (*DBClient) Put

func (d *DBClient) Put(key string, value string) error

Put value to DB

func (*DBClient) PutWithLeaseExpiry

func (d *DBClient) PutWithLeaseExpiry(key string, value string, seconds int64) error

PutWithLeaseExpiry value to DB

func (*DBClient) ReleaseLock

func (d *DBClient) ReleaseLock(lck lock.Lock) error

ReleaseLock for the given key

func (*DBClient) WaitAcquireLock

func (d *DBClient) WaitAcquireLock(key string, ttl int) (lock.Lock, error)

WaitAcquireLock for the given key

Jump to

Keyboard shortcuts

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