etcd

package
v0.0.0-...-e89c278 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MPL-2.0 Imports: 10 Imported by: 0

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 Set

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

func SetEx

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

func Watch

func Watch(key string, logic func(event Event))

func WatchPrefix

func WatchPrefix(key string, logic func(event Event))

Types

type Config

type Config struct {
	Addrs []string `json:"addrs,omitempty"`
}

type Event

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

type EventType

type EventType string
const (
	Changed EventType = "changed"
	Deleted EventType = "delete"
)

type Mutex

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

func NewMutex

func NewMutex(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