recipe

package
v3.1.0-alpha.0....-4ef44d1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2016 License: Apache-2.0 Imports: 8 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")
	ErrTooManyClients = errors.New("too many clients")
	ErrNoWatcher      = errors.New("no watcher channel")
)

Functions

func WaitEvents

func WaitEvents(c *clientv3.Client, key string, rev int64, evs []mvccpb.Event_EventType) (*clientv3.Event, error)

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

func WaitPrefixEvents

func WaitPrefixEvents(c *clientv3.Client, prefix string, rev int64, evs []mvccpb.Event_EventType) (*clientv3.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 *v3.Client, 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 DoubleBarrier

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

DoubleBarrier blocks processes on Enter until an expected count enters, then blocks again on Leave until all processes have left.

func NewDoubleBarrier

func NewDoubleBarrier(s *concurrency.Session, key string, count int) *DoubleBarrier

func (*DoubleBarrier) Enter

func (b *DoubleBarrier) Enter() error

Enter waits for "count" processes to enter the barrier then returns

func (*DoubleBarrier) Leave

func (b *DoubleBarrier) Leave() error

Leave waits for "count" processes to leave the barrier then returns

type EphemeralKV

type EphemeralKV struct{ RemoteKV }

EphemeralKV is a new key associated with a session lease

func NewEphemeralKV

func NewEphemeralKV(s *concurrency.Session, key, val string) (*EphemeralKV, error)

NewEphemeralKV creates a new key/value pair associated with a session lease

func NewUniqueEphemeralKV

func NewUniqueEphemeralKV(s *concurrency.Session, prefix, val string) (ek *EphemeralKV, err error)

NewUniqueEphemeralKV creates a new unique key/value pair associated with a session lease

func NewUniqueEphemeralKey

func NewUniqueEphemeralKey(s *concurrency.Session, prefix string) (*EphemeralKV, error)

NewUniqueEphemeralKey creates a new unique valueless key associated with a session lease

type PriorityQueue

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

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

func NewPriorityQueue

func NewPriorityQueue(client *v3.Client, key string) *PriorityQueue

NewPriorityQueue creates an etcd priority queue.

func (*PriorityQueue) Dequeue

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

Dequeue returns Enqueue()'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 *v3.Client, keyPrefix string) *Queue

func (*Queue) Dequeue

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

Dequeue returns Enqueue()'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(s *concurrency.Session, prefix 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 RemoteKV

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

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

func GetRemoteKV

func GetRemoteKV(kv v3.KV, key string) (*RemoteKV, error)

func NewKV

func NewKV(kv v3.KV, key, val string, leaseID v3.LeaseID) (*RemoteKV, error)

func NewKey

func NewKey(kv v3.KV, key string, leaseID v3.LeaseID) (*RemoteKV, error)

func NewSequentialKV

func NewSequentialKV(kv v3.KV, prefix, val string) (*RemoteKV, error)

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

func NewUniqueKV

func NewUniqueKV(kv v3.KV, prefix string, val string, leaseID v3.LeaseID) (*RemoteKV, error)

func NewUniqueKey

func NewUniqueKey(kv v3.KV, 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

Jump to

Keyboard shortcuts

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