zoovisitor-0.2.1.1: A haskell binding to Apache Zookeeper C library(mt) using Haskell Z project.
Safe HaskellNone
LanguageHaskell2010

ZooKeeper.Recipe

Contents

Synopsis

Documentation

election Source #

Arguments

:: ZHandle

The zookeeper handle obtained by a call to zookeeperResInit

-> CBytes

The path to start the election from. Ephemeral znodes will be put on it

-> CBytes

The GUID for this zookeeper session. To handle recoverable execptions correctly, it should be distinct from different sessions.

-> IO ()

The action to be executed when an leader is elected.

-> (DataCompletion -> IO ())

The action to be executed when a watcher is set. It can be used to remind the user that one step is finished.

-> IO () 

Run a leader election process. IMPORTANT: This function may run endlessly until it is selected as the leader.

withLock Source #

Arguments

:: ZHandle

The zookeeper handle obtained by a call to zookeeperResInit

-> CBytes

The path to get the lock. Ephemeral znodes will be put on it.

-> CBytes

The GUID for this zookeeper session. To handle recoverable execptions correctly, it should be distinct from different sessions.

-> IO a

The action to be executed within the lock.

-> IO a 

To do an action with a distributed lock. Only one caller with the same lockPath can execute the action at the same time. If the action throws any exception during the locking period, the lock will be released and the exception will be thrown again.

Internal

lock Source #

Arguments

:: ZHandle

The zookeeper handle obtained by a call to zookeeperResInit

-> CBytes

The path to get the lock. Ephemeral znodes will be put on it

-> CBytes

The GUID for this zookeeper session. To handle recoverable execptions correctly, it should be distinct from different sessions

-> IO CBytes

The real path of the lock that acquired. It will be used when unlocking the same lock

To acquire a distributed lock. Warning: do not forget to unlock it! Use withLock instead if possible.

unlock Source #

Arguments

:: ZHandle

The zookeeper handle obtained by a call to zookeeperResInit

-> CBytes

The real lock path acquired by lock. An exception will be thrown if it is bad (for example, does not exist)

-> IO () 

To release a distributed lock. Note that the real lock path should be the one acquired by lock, otherwise, a ZooException will be thrown.