package recipe
import "github.com/coreos/etcd/contrib/recipes"
Copyright 2016 CoreOS, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 CoreOS, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func NewLocker(client *clientv3.Client, key string) sync.Locker
- func NewSTM(client *clientv3.Client, apply func(*STM) error) <-chan error
- func RevokeSessionLease(client *clientv3.Client) (err error)
- func SessionLease(client *clientv3.Client) (lease.LeaseID, error)
- func SessionLeaseTTL(client *clientv3.Client, ttl int64) (lease.LeaseID, error)
- func StopSessionLease(client *clientv3.Client)
- func WaitEvents(c *clientv3.Client, key string, rev int64, evs []storagepb.Event_EventType) (*storagepb.Event, error)
- func WaitPrefixEvents(c *clientv3.Client, prefix string, rev int64, evs []storagepb.Event_EventType) (*storagepb.Event, error)
- type Barrier
- func NewBarrier(client *clientv3.Client, key string) *Barrier
- func (b *Barrier) Hold() error
- func (b *Barrier) Release() error
- func (b *Barrier) Wait() error
- type DoubleBarrier
- func NewDoubleBarrier(client *clientv3.Client, key string, count int) *DoubleBarrier
- func (b *DoubleBarrier) Enter() error
- func (b *DoubleBarrier) Leave() error
- type Election
- func NewElection(client *clientv3.Client, keyPrefix string) *Election
- func (e *Election) Leader() (string, error)
- func (e *Election) Resign() (err error)
- func (e *Election) Volunteer(val string) error
- func (e *Election) Wait() (string, error)
- type EphemeralKV
- func NewEphemeralKV(client *clientv3.Client, key, val string) (*EphemeralKV, error)
- func NewUniqueEphemeralKV(client *clientv3.Client, prefix, val string) (ek *EphemeralKV, err error)
- func NewUniqueEphemeralKey(client *clientv3.Client, prefix string) (*EphemeralKV, error)
- type Mutex
- func NewMutex(client *clientv3.Client, key string) *Mutex
- func (m *Mutex) Lock() (err error)
- func (m *Mutex) Unlock() error
- type PriorityQueue
- func NewPriorityQueue(client *clientv3.Client, key string) *PriorityQueue
- func (q *PriorityQueue) Dequeue() (string, error)
- func (q *PriorityQueue) Enqueue(val string, pr uint16) error
- type Queue
- func NewQueue(client *clientv3.Client, keyPrefix string) *Queue
- func (q *Queue) Dequeue() (string, error)
- func (q *Queue) Enqueue(val string) error
- type RWMutex
- func NewRWMutex(client *clientv3.Client, key string) *RWMutex
- func (rwm *RWMutex) Lock() error
- func (rwm *RWMutex) RLock() error
- func (rwm *RWMutex) RUnlock() error
- func (rwm *RWMutex) Unlock() error
- type Range
- func NewRange(client *clientv3.Client, key string) *Range
- func NewRangeRev(client *clientv3.Client, key string, rev int64) *Range
- func (r *Range) FirstCreate() (*pb.RangeResponse, error)
- func (r *Range) FirstKey() (*pb.RangeResponse, error)
- func (r *Range) FirstRev() (*pb.RangeResponse, error)
- func (r *Range) LastCreate() (*pb.RangeResponse, error)
- func (r *Range) LastKey() (*pb.RangeResponse, error)
- func (r *Range) LastRev() (*pb.RangeResponse, error)
- func (r *Range) OpenInterval() (*pb.RangeResponse, error)
- func (r *Range) Prefix() (*pb.RangeResponse, error)
- type RemoteKV
- func GetRemoteKV(client *clientv3.Client, key string) (*RemoteKV, error)
- func NewKV(client *clientv3.Client, key, val string, leaseID lease.LeaseID) (*RemoteKV, error)
- func NewKey(client *clientv3.Client, key string, leaseID lease.LeaseID) (*RemoteKV, error)
- func NewSequentialKV(client *clientv3.Client, prefix, val string) (*RemoteKV, error)
- func NewUniqueKV(client *clientv3.Client, prefix string, val string, leaseID lease.LeaseID) (*RemoteKV, error)
- func NewUniqueKey(client *clientv3.Client, prefix string) (*RemoteKV, error)
- func (rk *RemoteKV) Delete() error
- func (rk *RemoteKV) Key() string
- func (rk *RemoteKV) Put(val string) error
- func (rk *RemoteKV) Revision() int64
- func (rk *RemoteKV) Value() string
- type STM
- func (s *STM) Abort()
- func (s *STM) Get(key string) (string, error)
- func (s *STM) Put(key string, val string)
- type Watcher
Variables ¶
var ( ErrKeyExists = errors.New("key already exists") ErrWaitMismatch = errors.New("unexpected wait result") ErrTooManyClients = errors.New("too many clients") )
Functions ¶
func NewLocker ¶
func NewSTM ¶
NewSTM creates new transaction loop for a given apply function.
func RevokeSessionLease ¶
RevokeSessionLease revokes the session lease.
func SessionLease ¶
func SessionLeaseTTL ¶
func StopSessionLease ¶
StopSessionLease ends the refresh for the session lease. This is useful in case the state of the client connection is indeterminate (revoke would fail) or if transferring lease ownership.
func WaitEvents ¶
func WaitEvents(c *clientv3.Client, 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 *clientv3.Client, 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 (*Barrier) Hold ¶
Hold creates the barrier key causing processes to block on Wait.
func (*Barrier) Release ¶
Release deletes the barrier key to unblock all waiting processes.
func (*Barrier) Wait ¶
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(client *clientv3.Client, 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 Election ¶
type Election struct {
// contains filtered or unexported fields
}
func NewElection ¶
NewElection returns a new election on a given key prefix.
func (*Election) Leader ¶
Leader returns the leader value for the current election.
func (*Election) Resign ¶
Resign lets a leader start a new election.
func (*Election) Volunteer ¶
Volunteer puts a value as eligible for the election. It blocks until it is elected or an error occurs (cannot withdraw candidacy)
func (*Election) Wait ¶
Wait waits for a leader to be elected, returning the leader value.
type EphemeralKV ¶
type EphemeralKV struct{ RemoteKV }
EphemeralKV is a new key associated with a session lease
func NewEphemeralKV ¶
func NewEphemeralKV(client *clientv3.Client, key, val string) (*EphemeralKV, error)
NewEphemeralKV creates a new key/value pair associated with a session lease
func NewUniqueEphemeralKV ¶
func NewUniqueEphemeralKV(client *clientv3.Client, prefix, val string) (ek *EphemeralKV, err error)
NewUniqueEphemeralKV creates a new unique key/value pair associated with a session lease
func NewUniqueEphemeralKey ¶
func NewUniqueEphemeralKey(client *clientv3.Client, prefix string) (*EphemeralKV, error)
NewUniqueEphemeralKey creates a new unique valueless key associated with a session lease
type Mutex ¶
type Mutex struct {
// contains filtered or unexported fields
}
Mutex implements the sync Locker interface with etcd
func NewMutex ¶
func (*Mutex) Lock ¶
func (*Mutex) Unlock ¶
type PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
PriorityQueue implements a multi-reader, multi-writer distributed queue.
func NewPriorityQueue ¶
func NewPriorityQueue(client *clientv3.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 (*Queue) Dequeue ¶
Dequeue returns Enqueue()'d elements in FIFO order. If the queue is empty, Dequeue blocks until elements are available.
func (*Queue) Enqueue ¶
type RWMutex ¶
type RWMutex struct {
// contains filtered or unexported fields
}
func NewRWMutex ¶
func (*RWMutex) Lock ¶
func (*RWMutex) RLock ¶
func (*RWMutex) RUnlock ¶
func (*RWMutex) Unlock ¶
type Range ¶
type Range struct {
// contains filtered or unexported fields
}
func NewRange ¶
func NewRangeRev ¶
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 NewKV ¶
func NewKey ¶
func NewSequentialKV ¶
NewSequentialKV allocates a new sequential key-value pair at <prefix>/nnnnn
func NewUniqueKV ¶
func NewUniqueKV(client *clientv3.Client, prefix string, val string, leaseID lease.LeaseID) (*RemoteKV, error)
func NewUniqueKey ¶
func (*RemoteKV) Delete ¶
func (*RemoteKV) Key ¶
func (*RemoteKV) Put ¶
func (*RemoteKV) Revision ¶
func (*RemoteKV) Value ¶
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 ¶
Get returns the value for a given key, inserting the key into the txn's rset.
func (*STM) Put ¶
Put adds a value for a key to the write set.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
func NewPrefixWatcher ¶
func NewWatcher ¶
func (*Watcher) Chan ¶
func (*Watcher) Close ¶
Source Files ¶
barrier.go client.go double_barrier.go election.go key.go lease.go mutex.go priority_queue.go queue.go range.go rwmutex.go stm.go watch.go
- Version
- v2.3.0-alpha.1+incompatible
- Published
- Feb 17, 2016
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 2 hours ago –
Tools for package owners.