Safe Haskell | None |
---|---|
Language | Haskell2010 |
Documentation
:: ZHandle | The zookeeper handle obtained by a call to |
-> 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 |
-> IO () |
Run a leader election process. IMPORTANT: This function may run endlessly until it is selected as the leader.
:: ZHandle | The zookeeper handle obtained by a call to |
-> 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
:: ZHandle | The zookeeper handle obtained by a call to |
-> 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.
:: ZHandle | The zookeeper handle obtained by a call to |
-> CBytes | The real lock path acquired by |
-> 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.