recipe

package
v2.3.0-alpha.0....-5099bf6 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyExists    = errors.New("key already exists")
	ErrWaitMismatch = errors.New("unexpected wait result")
)

Functions

func NewLocker

func NewLocker(client *EtcdClient, key string) sync.Locker

func NewSTM

func NewSTM(client *EtcdClient, apply func(*STM) error) <-chan error

NewSTM creates new transaction loop for a given apply function.

func WaitEvents

func WaitEvents(c *EtcdClient, key string, rev int64, evs []storagepb.Event_EventType) (*storagepb.Event, error)

WaitEvents waits on a key until it observes the given events and returns the final one.

func WaitPrefixEvents

func WaitPrefixEvents(c *EtcdClient, prefix string, rev int64, evs []storagepb.Event_EventType) (*storagepb.Event, error)

Types

type Barrier

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

Barrier creates a key in etcd to block processes, then deletes the key to release all blocked processes.

func NewBarrier

func NewBarrier(client *EtcdClient, key string) *Barrier

func (*Barrier) Hold

func (b *Barrier) Hold() error

Hold creates the barrier key causing processes to block on Wait.

func (*Barrier) Release

func (b *Barrier) Release() error

Release deletes the barrier key to unblock all waiting processes.

func (*Barrier) Wait

func (b *Barrier) Wait() error

Wait blocks on the barrier key until it is deleted. If there is no key, Wait assumes Release has already been called and returns immediately.

type EtcdClient

type EtcdClient struct {
	KV    pb.KVClient
	Lease pb.LeaseClient
	Watch pb.WatchClient
	// contains filtered or unexported fields
}

func NewEtcdClient

func NewEtcdClient(conn *grpc.ClientConn) *EtcdClient

type Mutex

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

Mutex implements the sync Locker interface with etcd

func NewMutex

func NewMutex(client *EtcdClient, key string) *Mutex

func (*Mutex) Lock

func (m *Mutex) Lock() (err error)

func (*Mutex) Unlock

func (m *Mutex) Unlock() error

type PriorityQueue

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

PriorityQueue implements a multi-reader, multi-writer distributed queue.

func NewPriorityQueue

func NewPriorityQueue(client *EtcdClient, key string) *PriorityQueue

NewPriorityQueue creates an etcd priority queue.

func (*PriorityQueue) Dequeue

func (q *PriorityQueue) Dequeue() (string, error)

Dequeue returns Enqueued()'d items in FIFO order. If the queue is empty, Dequeue blocks until items are available.

func (*PriorityQueue) Enqueue

func (q *PriorityQueue) Enqueue(val string, pr uint16) error

Enqueue puts a value into a queue with a given priority.

type Queue

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

Queue implements a multi-reader, multi-writer distributed queue.

func NewQueue

func NewQueue(client *EtcdClient, keyPrefix string) *Queue

func (*Queue) Dequeue

func (q *Queue) Dequeue() (string, error)

Dequeue returns Enqueued()'d elements in FIFO order. If the queue is empty, Dequeue blocks until elements are available.

func (*Queue) Enqueue

func (q *Queue) Enqueue(val string) error

type RWMutex

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

func NewRWMutex

func NewRWMutex(client *EtcdClient, key string) *RWMutex

func (*RWMutex) Lock

func (rwm *RWMutex) Lock() error

func (*RWMutex) RLock

func (rwm *RWMutex) RLock() error

func (*RWMutex) RUnlock

func (rwm *RWMutex) RUnlock() error

func (*RWMutex) Unlock

func (rwm *RWMutex) Unlock() error

type Range

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

func NewRange

func NewRange(client *EtcdClient, key string) *Range

func NewRangeRev

func NewRangeRev(client *EtcdClient, key string, rev int64) *Range

func (*Range) FirstCreate

func (r *Range) FirstCreate() (*pb.RangeResponse, error)

func (*Range) FirstKey

func (r *Range) FirstKey() (*pb.RangeResponse, error)

func (*Range) FirstRev

func (r *Range) FirstRev() (*pb.RangeResponse, error)

func (*Range) LastCreate

func (r *Range) LastCreate() (*pb.RangeResponse, error)

func (*Range) LastKey

func (r *Range) LastKey() (*pb.RangeResponse, error)

func (*Range) LastRev

func (r *Range) LastRev() (*pb.RangeResponse, error)

func (*Range) OpenInterval

func (r *Range) OpenInterval() (*pb.RangeResponse, error)

OpenInterval gets the keys in the set <key>* - <key>

func (*Range) Prefix

func (r *Range) Prefix() (*pb.RangeResponse, error)

Prefix performs a RangeRequest to get keys matching <key>*

type RemoteKV

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

Key is a key/revision pair created by the client and stored on etcd

func GetRemoteKV

func GetRemoteKV(client *EtcdClient, key string) (*RemoteKV, error)

func NewKV

func NewKV(client *EtcdClient, key, val string, leaseID lease.LeaseID) (*RemoteKV, error)

func NewKey

func NewKey(client *EtcdClient, key string, leaseID lease.LeaseID) (*RemoteKV, error)

func NewSequentialKV

func NewSequentialKV(client *EtcdClient, prefix, val string) (*RemoteKV, error)

NewSequentialKV allocates a new sequential key-value pair at <prefix>/nnnnn

func NewUniqueKV

func NewUniqueKV(client *EtcdClient, prefix string, val string, leaseID lease.LeaseID) (*RemoteKV, error)

func NewUniqueKey

func NewUniqueKey(client *EtcdClient, prefix string) (*RemoteKV, error)

func (*RemoteKV) Delete

func (rk *RemoteKV) Delete() error

func (*RemoteKV) Key

func (rk *RemoteKV) Key() string

func (*RemoteKV) Put

func (rk *RemoteKV) Put(val string) error

func (*RemoteKV) Revision

func (rk *RemoteKV) Revision() int64

func (*RemoteKV) Value

func (rk *RemoteKV) Value() string

type STM

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

STM implements software transactional memory over etcd

func (*STM) Abort

func (s *STM) Abort()

Abort abandons the apply loop, letting the transaction close without a commit.

func (*STM) Get

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

Get returns the value for a given key, inserting the key into the txn's readset.

func (*STM) Put

func (s *STM) Put(key string, val string)

Put adds a value for a key to the write set.

type Watcher

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

func NewPrefixWatcher

func NewPrefixWatcher(c *EtcdClient, prefix string, rev int64) (*Watcher, error)

func NewWatcher

func NewWatcher(c *EtcdClient, key string, rev int64) (*Watcher, error)

func (*Watcher) Chan

func (w *Watcher) Chan() <-chan *storagepb.Event

func (*Watcher) Close

func (w *Watcher) Close() error

Jump to

Keyboard shortcuts

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