zmq

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: Apache-2.0, CC-BY-SA-4.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultWatchWaitTime is how long we block for at a
	// time to check if the watched key has changed. This
	// affects the minimum time it takes to cancel a watch.
	DefaultWatchWaitTime = 15 * time.Second

	// RenewSessionRetryMax is the number of time we should try
	// to renew the session before giving up and throwing an error
	RenewSessionRetryMax = 5

	// MaxSessionDestroyAttempts is the maximum times we will try
	// to explicitely destroy the session attached to a lock after
	// the connectivity to the store has been lost
	MaxSessionDestroyAttempts = 5
)

Variables

View Source
var (
	// ErrMultipleEndpointsUnsupported is thrown when there are
	// multiple endpoints specified for Consul
	ErrMultipleEndpointsUnsupported = errors.New("consul does not support multiple endpoints")

	// ErrSessionRenew is thrown when the session can't be
	// renewed because the Consul version does not support sessions
	ErrSessionRenew = errors.New("cannot set or renew session for ttl, unable to operate on sessions")
)

Functions

func New

func New(endpoints []string, options *store.Config) (store.Store, error)

New creates a new Consul client given a list of endpoints and optional tls config

func Register

func Register()

Register registers consul to libkv

Types

type Zmq

type Zmq struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Consul is the receiver type for the Store interface

func (*Zmq) AtomicDelete

func (s *Zmq) AtomicDelete(key string, previous *store.KVPair) (bool, error)

Atomic delete of a single value

func (*Zmq) AtomicPut

func (s *Zmq) AtomicPut(key string, value []byte, previous *store.KVPair, options *store.WriteOptions) (bool, *store.KVPair, error)

Atomic CAS operation on a single value. Pass previous = nil to create a new key.

func (*Zmq) Close

func (s *Zmq) Close()

Close the store connection

func (*Zmq) Delete

func (s *Zmq) Delete(key string) error

Delete the value at the specified key

func (*Zmq) DeleteTree

func (s *Zmq) DeleteTree(directory string) error

DeleteTree deletes a range of keys under a given directory

func (*Zmq) Exists

func (s *Zmq) Exists(key string) (bool, error)

Verify if a Key exists in the store

func (*Zmq) Get

func (s *Zmq) Get(key string) (*store.KVPair, error)

Get the value at "key", returns the last modified index to use in conjunction to CAS calls

func (*Zmq) List

func (s *Zmq) List(directory string) ([]*store.KVPair, error)

List the content of a given prefix

func (*Zmq) NewLock

func (s *Zmq) NewLock(key string, options *store.LockOptions) (store.Locker, error)

NewLock creates a lock for a given key. The returned Locker is not held and must be acquired with `.Lock`. The Value is optional.

func (*Zmq) Put

func (s *Zmq) Put(key string, value []byte, options *store.WriteOptions) error

func (*Zmq) Watch

func (s *Zmq) Watch(key string, stopCh <-chan struct{}) (<-chan *store.KVPair, error)

Watch for changes on a key

func (*Zmq) WatchTree

func (s *Zmq) WatchTree(directory string, stopCh <-chan struct{}) (<-chan []*store.KVPair, error)

WatchTree watches for changes on child nodes under a given directory

Jump to

Keyboard shortcuts

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