Documentation
¶
Index ¶
- Variables
- type CatMan
- func (cm *CatMan) CMChildren(parent string, watcher Watcher) ([]string, error)
- func (cm *CatMan) CMCreate(path string, data []byte, opts ...CreateConfigOption) (string, error)
- func (cm *CatMan) CMCreateEphemeralSequential(pathPrefix string, data []byte, opts ...CreateConfigOption) (string, int64, error)
- func (cm *CatMan) CMCreateProtectedEphemeralSequential(path string, data []byte, opts ...CreateConfigOption) (string, int64, error)
- func (cm *CatMan) CMCreateSequential(pathPrefix string, data []byte, opts ...CreateConfigOption) (string, error)
- func (cm *CatMan) CMDelete(path string, version int32) error
- func (cm *CatMan) CMExists(path string, watcher Watcher) (*zk.Stat, error)
- func (cm *CatMan) CMGet(path string) ([]byte, error)
- func (cm *CatMan) Close()
- func (cm *CatMan) NewDistributedQueue(dir string) *DistributedQueue
- func (cm *CatMan) NewLeaderElectionSupport(hostName, rootNodeName string) *LeaderElectionSupport
- func (cm *CatMan) NewLock(dir string, acl []zk.ACL, callback LockListener) *Lock
- type CatManConfig
- type CatManConfigOption
- type CreateConfig
- type CreateConfigOption
- type DistributedQueue
- func (q *DistributedQueue) Element() ([]byte, error)
- func (q *DistributedQueue) Offer(data []byte) (bool, error)
- func (q *DistributedQueue) Peek() ([]byte, error)
- func (q *DistributedQueue) Poll() ([]byte, error)
- func (q *DistributedQueue) Remove() ([]byte, error)
- func (q *DistributedQueue) Take() ([]byte, error)
- type ElectionEvent
- type ElectionState
- type ErrUnexpectedEvent
- type LeaderElectionAware
- type LeaderElectionAwareFunc
- type LeaderElectionSupport
- func (l *LeaderElectionSupport) AddListener(listener LeaderElectionAware)
- func (l *LeaderElectionSupport) HostName() string
- func (l *LeaderElectionSupport) LeaderHostName() (string, error)
- func (l *LeaderElectionSupport) LeaderOffer() *LeaderOffer
- func (l *LeaderElectionSupport) Process(event zk.Event)
- func (l *LeaderElectionSupport) RemoveListener(listener LeaderElectionAware)
- func (l *LeaderElectionSupport) RootNodeName() string
- func (l *LeaderElectionSupport) SetHostName(hostName string)
- func (l *LeaderElectionSupport) SetRootNodeName(rootNodeName string)
- func (l *LeaderElectionSupport) Start() error
- func (l *LeaderElectionSupport) Stop() error
- type LeaderOffer
- type Lock
- func (l *Lock) Acl() []zk.ACL
- func (l *Lock) CatMan() *CatMan
- func (l *Lock) Close()
- func (l *Lock) Closed() bool
- func (l *Lock) IsOwner() bool
- func (l *Lock) Lock() (bool, error)
- func (l *Lock) LockListener() LockListener
- func (l *Lock) RetryDelay() time.Duration
- func (l *Lock) SetAcl(acl []zk.ACL)
- func (l *Lock) SetLockListener(callback LockListener)
- func (l *Lock) SetRetryDelay(retryDelay time.Duration)
- func (l *Lock) Unlock() error
- type LockListener
- type Watcher
- type WatcherFunc
- type ZNodeName
- type ZooKeeperOperation
- type ZooKeeperOperationFunc
Constants ¶
This section is empty.
Variables ¶
var ( OpenAclUnsafe = zk.WorldACL(zk.PermAll) CreatorAllAcl = zk.AuthACL(zk.PermAll) ReadAclUnsafe = zk.WorldACL(zk.PermRead) )
var (
ErrBadPath = errors.New("bad path")
)
var (
ErrNoSuchElement = errors.New("no such element")
)
var LeaderOfferComparator = utils.Comparator(func(a interface{}, b interface{}) int { aAsserted := a.(*LeaderOffer) bAsserted := b.(*LeaderOffer) return utils.IntComparator(aAsserted.id, bAsserted.id) })
var ZNodeNameComparator = utils.Comparator(func(a interface{}, b interface{}) int { aAsserted := a.(*ZNodeName) bAsserted := b.(*ZNodeName) answer := aAsserted.sequence - bAsserted.sequence if answer != 0 { return answer } return utils.StringComparator(aAsserted.prefix, bAsserted.prefix) })
Functions ¶
This section is empty.
Types ¶
type CatMan ¶
func (*CatMan) CMChildren ¶
func (*CatMan) CMCreateEphemeralSequential ¶
func (*CatMan) CMCreateProtectedEphemeralSequential ¶
func (*CatMan) CMCreateSequential ¶
func (*CatMan) NewDistributedQueue ¶
func (cm *CatMan) NewDistributedQueue(dir string) *DistributedQueue
func (*CatMan) NewLeaderElectionSupport ¶
func (cm *CatMan) NewLeaderElectionSupport(hostName, rootNodeName string) *LeaderElectionSupport
type CatManConfigOption ¶
type CatManConfigOption func(*CatManConfig)
type CreateConfig ¶
type CreateConfigOption ¶
type CreateConfigOption func(*CreateConfig)
type DistributedQueue ¶
type DistributedQueue struct {
// contains filtered or unexported fields
}
func (*DistributedQueue) Element ¶
func (q *DistributedQueue) Element() ([]byte, error)
Return the head of the queue without modifying the queue.
func (*DistributedQueue) Offer ¶
func (q *DistributedQueue) Offer(data []byte) (bool, error)
Inserts data into queue.
func (*DistributedQueue) Peek ¶
func (q *DistributedQueue) Peek() ([]byte, error)
Returns the data at the first element of the queue, or null if the queue is empty.
func (*DistributedQueue) Poll ¶
func (q *DistributedQueue) Poll() ([]byte, error)
Attempts to remove the head of the queue and return it. Returns null if the queue is empty.
func (*DistributedQueue) Remove ¶
func (q *DistributedQueue) Remove() ([]byte, error)
Attempts to remove the head of the queue and return it.
func (*DistributedQueue) Take ¶
func (q *DistributedQueue) Take() ([]byte, error)
Removes the head of the queue and returns it, blocks until it succeeds.
type ElectionEvent ¶
type ElectionEvent int
const ( ElectionEventStart ElectionEvent = iota ElectionEventOfferStart ElectionEventOfferComplete ElectionEventDetermineStart ElectionEventDetermineComplete ElectionEventElectedStart ElectionEventElectedComplete ElectionEventReadyStart ElectionEventReadyComplete ElectionEventFailed ElectionEventStopStart ElectionEventStopComplete )
func (ElectionEvent) String ¶
func (i ElectionEvent) String() string
type ElectionState ¶
type ElectionState int
const ( ElectionStateStart ElectionState = iota ElectionStateOffer ElectionStateDetermine ElectionStateElected ElectionStateReady ElectionStateFailed ElectionStateStop )
func (ElectionState) String ¶
func (i ElectionState) String() string
type ErrUnexpectedEvent ¶
func (*ErrUnexpectedEvent) Error ¶
func (ue *ErrUnexpectedEvent) Error() string
type LeaderElectionAware ¶
type LeaderElectionAware interface {
OnElectionEvent(event ElectionEvent)
}
Called during each state transition. Current, low level events are provided at the beginning and end of each state. For instance, START may be followed by OFFER_START, OFFER_COMPLETE, DETERMINE_START, DETERMINE_COMPLETE, and so on
type LeaderElectionAwareFunc ¶
type LeaderElectionAwareFunc func(event ElectionEvent)
func (LeaderElectionAwareFunc) OnElectionEvent ¶
func (l LeaderElectionAwareFunc) OnElectionEvent(event ElectionEvent)
type LeaderElectionSupport ¶
type LeaderElectionSupport struct {
// contains filtered or unexported fields
}
func (*LeaderElectionSupport) AddListener ¶
func (l *LeaderElectionSupport) AddListener(listener LeaderElectionAware)
func (*LeaderElectionSupport) HostName ¶
func (l *LeaderElectionSupport) HostName() string
func (*LeaderElectionSupport) LeaderHostName ¶
func (l *LeaderElectionSupport) LeaderHostName() (string, error)
func (*LeaderElectionSupport) LeaderOffer ¶
func (l *LeaderElectionSupport) LeaderOffer() *LeaderOffer
func (*LeaderElectionSupport) Process ¶
func (l *LeaderElectionSupport) Process(event zk.Event)
func (*LeaderElectionSupport) RemoveListener ¶
func (l *LeaderElectionSupport) RemoveListener(listener LeaderElectionAware)
func (*LeaderElectionSupport) RootNodeName ¶
func (l *LeaderElectionSupport) RootNodeName() string
func (*LeaderElectionSupport) SetHostName ¶
func (l *LeaderElectionSupport) SetHostName(hostName string)
func (*LeaderElectionSupport) SetRootNodeName ¶
func (l *LeaderElectionSupport) SetRootNodeName(rootNodeName string)
func (*LeaderElectionSupport) Start ¶
func (l *LeaderElectionSupport) Start() error
start the election process. This method will create a leader offer, determine its status, and either become the leader or become ready.
func (*LeaderElectionSupport) Stop ¶
func (l *LeaderElectionSupport) Stop() error
stops all election services, revokes any outstanding leader offers, and disconnects from ZooKeeper.
type LeaderOffer ¶
type LeaderOffer struct {
// contains filtered or unexported fields
}
func NewLeaderOffer ¶
func NewLeaderOffer(id int, nodePath string, hostName string) *LeaderOffer
func (*LeaderOffer) HostName ¶
func (l *LeaderOffer) HostName() string
func (*LeaderOffer) Id ¶
func (l *LeaderOffer) Id() int
func (*LeaderOffer) NodePath ¶
func (l *LeaderOffer) NodePath() string
func (*LeaderOffer) SetHostName ¶
func (l *LeaderOffer) SetHostName(hostName string)
func (*LeaderOffer) SetId ¶
func (l *LeaderOffer) SetId(id int)
func (*LeaderOffer) SetNodePath ¶
func (l *LeaderOffer) SetNodePath(nodePath string)
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
func (*Lock) Close ¶
func (l *Lock) Close()
Closes this strategy and releases any ZooKeeper resources; but keeps the ZooKeeper instance open.
func (*Lock) LockListener ¶
func (l *Lock) LockListener() LockListener
return the current locklistener.
func (*Lock) SetLockListener ¶
func (l *Lock) SetLockListener(callback LockListener)
register a different call back listener.
func (*Lock) SetRetryDelay ¶
Sets the time waited between retry delays.
type LockListener ¶
type LockListener interface { LockAcquired() LockReleased() }
type WatcherFunc ¶
func (WatcherFunc) Process ¶
func (f WatcherFunc) Process(event zk.Event)
type ZNodeName ¶
type ZNodeName struct {
// contains filtered or unexported fields
}
func NewZNodeName ¶
type ZooKeeperOperation ¶
type ZooKeeperOperationFunc ¶
Performs the operation - which may be involved multiple times if the connection to ZooKeeper closes during this operation.
func (ZooKeeperOperationFunc) Execute ¶
func (f ZooKeeperOperationFunc) Execute() (bool, error)