etcd

package
v0.0.0-...-fad138e Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: AGPL-3.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func Connect

func Connect(c *Config) error

func Get

func Get(key string) ([]byte, error)

func GetJson

func GetJson(key string, j interface{}) error

func Prefix

func Prefix(key string) (map[string][]byte, error)

func Set

func Set(key string, val interface{}) error

func SetEx

func SetEx(key string, val interface{}, timeout time.Duration) error

func SetWithLock

func SetWithLock(key string, val interface{}) error

func Watch

func Watch(key string, wg *sync.WaitGroup, logic func(event *Event))

func WatchPrefix

func WatchPrefix(key string, wg *sync.WaitGroup, logic func(event *Event))

func WhenLocked

func WhenLocked(key string, logic func(client *Client, key string) error) error

Types

type Client

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

func NewClient

func NewClient(c *Config) (*Client, error)

func (*Client) Close

func (p *Client) Close() error

func (*Client) Del

func (p *Client) Del(key string) error

func (*Client) Exist

func (p *Client) Exist(key string) (bool, error)

func (*Client) Get

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

func (*Client) GetJson

func (p *Client) GetJson(key string, j interface{}) error

func (*Client) Prefix

func (p *Client) Prefix(key string) (map[string][]byte, error)

func (*Client) Set

func (p *Client) Set(key string, val interface{}) error

func (*Client) SetEx

func (p *Client) SetEx(key string, val interface{}, timeout time.Duration) error

func (*Client) SetWithLock

func (p *Client) SetWithLock(key string, val interface{}) error

func (*Client) Watch

func (p *Client) Watch(key string, wg *sync.WaitGroup, logic func(event *Event))

func (*Client) WatchPrefix

func (p *Client) WatchPrefix(key string, wg *sync.WaitGroup, logic func(event *Event))

func (*Client) WhenLocked

func (p *Client) WhenLocked(key string, logic func(client *Client, key string) error) error

type Config

type Config struct {
	Address []string `` /* 147-byte string literal not displayed */
}

type Event

type Event struct {
	Key     string
	Type    EventType
	Value   string
	Version int64
}

type EventType

type EventType uint8
const (
	Changed EventType = iota + 1
	Deleted
)

func (EventType) String

func (e EventType) String() string

type Mutex

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

func NewMutex

func NewMutex(key string) *Mutex

func NewMutexWithClient

func NewMutexWithClient(cli *Client, key string) *Mutex

func (*Mutex) Lock

func (p *Mutex) Lock() error

func (*Mutex) LockWithTimeout

func (p *Mutex) LockWithTimeout(timeout time.Duration) error

func (*Mutex) Unlock

func (p *Mutex) Unlock() error

func (*Mutex) WhenLocked

func (p *Mutex) WhenLocked(logic func() error) error

Jump to

Keyboard shortcuts

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