Documentation ¶
Index ¶
- Constants
- type AfterConnectionEstablished
- type AtomicStats
- type AtomicValue
- type CacheEvent
- type CacheEventType
- type ChildData
- type ChildrenSorter
- type DistributedAtomicNumber
- type DistributedAtomicValue
- type InterProcessLock
- type InterProcessMutex
- type LockInternalsDriver
- type LockInternalsSorter
- type NodeCache
- type NodeCacheListenable
- type NodeCacheListener
- type NodeCacheListenerContainer
- type PathChildrenCache
- type PathChildrenCacheEvent
- type PathChildrenCacheListener
- type PredicateResults
- type PromotedToLock
- type RefreshMode
- type Revocable
- type RevocationListener
- type StandardLockInternalsDriver
- func (d *StandardLockInternalsDriver) CreatesTheLock(client curator.CuratorFramework, path string, lockNodeBytes []byte) (string, error)
- func (d *StandardLockInternalsDriver) FixForSorting(str, lockName string) string
- func (d *StandardLockInternalsDriver) GetsTheLock(client curator.CuratorFramework, children []string, sequenceNodeName string, ...) (*PredicateResults, error)
- type TreeCacheEvent
- type TreeCacheListener
Constants ¶
const LockPrefix = "lock-"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AfterConnectionEstablished ¶
Utility class to allow execution of logic once a ZooKeeper connection becomes available.
func (*AfterConnectionEstablished) Future ¶
func (c *AfterConnectionEstablished) Future() *promise.Future
Spawns a new new background thread that will block until a connection is available and then execute the 'runAfterConnection' logic
type AtomicStats ¶
type AtomicStats struct { // the number of optimistic locks used to perform the operation OptimisticTries int // the number of mutex locks used to perform the operation PromotedTries int // the time spent trying the operation with optimistic locks OptimisticTime time.Duration // the time spent trying the operation with mutex locks PromotedTime time.Duration }
Debugging stats about operations
type AtomicValue ¶
type AtomicValue interface { // MUST be checked. // Returns true if the operation succeeded. If false is returned, // the operation failed and the atomic was not updated. Succeeded() bool // Returns the value of the counter prior to the operation PreValue() []byte // Returns the value of the counter after to the operation PostValue() []byte // Returns debugging stats about the operation Stats() *AtomicStats }
Abstracts a value returned from one of the Atomics
type CacheEvent ¶
type CacheEvent struct { Type CacheEventType Data ChildData }
type CacheEventType ¶
type CacheEventType int
const ( CHILD_ADDED CacheEventType = iota // A child was added to the path CHILD_UPDATED // A child's data was changed CHILD_REMOVED // A child was removed from the path CONNECTION_SUSPENDED // Called when the connection has changed to SUSPENDED CONNECTION_RECONNECTED // Called when the connection has changed to RECONNECTED CONNECTION_LOST // Called when the connection has changed to LOST INITIALIZED // Posted when PathChildrenCache.Start(StartMode) is called with POST_INITIALIZED_EVENT )
type ChildrenSorter ¶
type ChildrenSorter struct {
// contains filtered or unexported fields
}
func (ChildrenSorter) Len ¶
func (s ChildrenSorter) Len() int
func (ChildrenSorter) Less ¶
func (s ChildrenSorter) Less(i, j int) bool
func (ChildrenSorter) Swap ¶
func (s ChildrenSorter) Swap(i, j int)
type DistributedAtomicNumber ¶
type DistributedAtomicNumber interface { // Add 1 to the current value and return the new value information. // Remember to always check AtomicValue.Succeeded(). Increment() (AtomicValue, error) // Subtract 1 from the current value and return the new value information. // Remember to always check AtomicValue.Succeeded(). Decrement() (AtomicValue, error) // Add delta to the current value and return the new value information. // Remember to always check AtomicValue.Succeeded(). Add(delta []byte) (AtomicValue, error) // Subtract delta from the current value and return the new value information. // Remember to always check AtomicValue.Succeeded(). Subtract(delta []byte) (AtomicValue, error) }
type DistributedAtomicValue ¶
type DistributedAtomicValue interface { // Returns the current value of the counter. Get() (AtomicValue, error) // Atomically sets the value to the given updated value // if the current value == the expected value. // Remember to always check AtomicValue.Succeeded(). CompareAndSet(expectedValue, newValue []byte) (AtomicValue, error) // Attempt to atomically set the value to the given value. // Remember to always check AtomicValue.Succeeded(). TrySet(newValue []byte) (AtomicValue, error) // Forcibly sets the value of the counter without any guarantees of atomicity. ForceSet(newValue []byte) error // Atomic values are initially set to the equivalent of <code>NULL</code> in a database. // Use this method to initialize the value. // The value will be set if and only iff the node does not exist. Initialize(value []byte) (bool, error) }
func NewDistributedAtomicValue ¶
func NewDistributedAtomicValue(client curator.CuratorFramework, path string, retryPolicy curator.RetryPolicy) (DistributedAtomicValue, error)
func NewDistributedAtomicValueWithLock ¶
func NewDistributedAtomicValueWithLock(client curator.CuratorFramework, path string, retryPolicy curator.RetryPolicy, promotedToLock *PromotedToLock) (DistributedAtomicValue, error)
type InterProcessLock ¶
type InterProcessLock interface { // Acquire the mutex - blocking until it's available. // Each call to acquire must be balanced by a call to Release() Acquire() (bool, error) // Acquire the mutex - blocks until it's available or the given time expires. AcquireTimeout(expires time.Duration) (bool, error) // Perform one release of the mutex. Release() error // Returns true if the mutex is acquired by a go-routine in this process IsAcquiredInThisProcess() bool }
type InterProcessMutex ¶
type InterProcessMutex struct { LockNodeBytes []byte // contains filtered or unexported fields }
A re-entrant mutex that works across processes. Uses Zookeeper to hold the lock. All processes that use the same lock path will achieve an inter-process critical section. Further, this mutex is "fair" - each user will get the mutex in the order requested (from ZK's point of view)
func NewInterProcessMutex ¶
func NewInterProcessMutex(client curator.CuratorFramework, path string) (*InterProcessMutex, error)
func NewInterProcessMutexWithDriver ¶
func NewInterProcessMutexWithDriver(client curator.CuratorFramework, path string, driver LockInternalsDriver) (*InterProcessMutex, error)
func (*InterProcessMutex) Acquire ¶
func (m *InterProcessMutex) Acquire() (bool, error)
func (*InterProcessMutex) AcquireTimeout ¶
func (m *InterProcessMutex) AcquireTimeout(expires time.Duration) (bool, error)
func (*InterProcessMutex) IsAcquiredInThisProcess ¶
func (m *InterProcessMutex) IsAcquiredInThisProcess() bool
func (*InterProcessMutex) Release ¶
func (m *InterProcessMutex) Release() error
type LockInternalsDriver ¶
type LockInternalsDriver interface { LockInternalsSorter GetsTheLock(client curator.CuratorFramework, children []string, sequenceNodeName string, maxLeases int) (*PredicateResults, error) CreatesTheLock(client curator.CuratorFramework, path string, lockNodeBytes []byte) (string, error) }
type LockInternalsSorter ¶
type NodeCache ¶
type NodeCache struct {
// contains filtered or unexported fields
}
A utility that attempts to keep the data from a node locally cached. This class will watch the node, respond to update/create/delete events, pull down the data, etc. You can register a listener that will get notified when changes occur.
func NewNodeCache ¶
func (*NodeCache) NodeCacheListenable ¶
func (c *NodeCache) NodeCacheListenable() NodeCacheListenable
func (*NodeCache) Start ¶
Start the cache. The cache is not started automatically. You must call this method.
func (*NodeCache) StartAndInitalize ¶
Same as Start() but gives the option of doing an initial build
type NodeCacheListenable ¶
type NodeCacheListenable interface { curator.Listenable /* [T] */ AddListener(listener NodeCacheListener) RemoveListener(listener NodeCacheListener) }
type NodeCacheListener ¶
type NodeCacheListener interface { // Called when a change has occurred NodeChanged() error }
type NodeCacheListenerContainer ¶
type NodeCacheListenerContainer struct {
*curator.ListenerContainer
}
func (*NodeCacheListenerContainer) AddListener ¶
func (c *NodeCacheListenerContainer) AddListener(listener NodeCacheListener)
func (*NodeCacheListenerContainer) RemoveListener ¶
func (c *NodeCacheListenerContainer) RemoveListener(listener NodeCacheListener)
type PathChildrenCache ¶
type PathChildrenCache struct {
// contains filtered or unexported fields
}
A utility that attempts to keep all data from all children of a ZK path locally cached. This class will watch the ZK path, respond to update/create/delete events, pull down the data, etc. You can register a listener that will get notified when changes occur.
func NewPathChildrenCache ¶
func NewPathChildrenCache(client curator.CuratorFramework, path string, cacheData, dataIsCompressed bool) *PathChildrenCache
func (*PathChildrenCache) RefreshMode ¶
func (c *PathChildrenCache) RefreshMode(mode RefreshMode)
type PathChildrenCacheEvent ¶
type PathChildrenCacheEvent CacheEvent
type PathChildrenCacheListener ¶
type PathChildrenCacheListener interface { // Called when a change has occurred ChildEvent(client curator.CuratorFramework, event PathChildrenCacheEvent) error }
Listener for PathChildrenCache changes
type PredicateResults ¶
type PromotedToLock ¶
type PromotedToLock struct {
// contains filtered or unexported fields
}
type RefreshMode ¶
type RefreshMode int
const ( STANDARD RefreshMode = iota FORCE_GET_DATA_AND_STAT POST_INITIALIZED )
type Revocable ¶
type Revocable interface { // Make the lock revocable. // Your listener will get called when another process/thread wants you to release the lock. Revocation is cooperative. MakeRevocable(listener RevocationListener) }
Specifies locks that can be revoked
type RevocationListener ¶
type RevocationListener interface { // Called when a revocation request has been received. // You should release the lock as soon as possible. Revocation is cooperative. RevocationRequested(forLock InterProcessMutex) }
type StandardLockInternalsDriver ¶
type StandardLockInternalsDriver struct{}
func NewStandardLockInternalsDriver ¶
func NewStandardLockInternalsDriver() *StandardLockInternalsDriver
func (*StandardLockInternalsDriver) CreatesTheLock ¶
func (d *StandardLockInternalsDriver) CreatesTheLock(client curator.CuratorFramework, path string, lockNodeBytes []byte) (string, error)
func (*StandardLockInternalsDriver) FixForSorting ¶
func (d *StandardLockInternalsDriver) FixForSorting(str, lockName string) string
func (*StandardLockInternalsDriver) GetsTheLock ¶
func (d *StandardLockInternalsDriver) GetsTheLock(client curator.CuratorFramework, children []string, sequenceNodeName string, maxLeases int) (*PredicateResults, error)
type TreeCacheEvent ¶
type TreeCacheEvent CacheEvent
type TreeCacheListener ¶
type TreeCacheListener interface { // Called when a change has occurred ChildEvent(client curator.CuratorFramework, event TreeCacheEvent) error }
Listener for TreeCache changes