misha_cafex v0.0.5 Cafex.ZK.Leader

Leader Election implementation with ZooKeeper

Visit Zookeeper Recipes to read more.

TODO

Handle zookeeper event missed problem.

Summary

Functions

Leader election function

Leader election function

Types

zk :: pid

Functions

election(zk, path)

Specs

election(zk, path) :: {true, seq} | {false, seq}

Leader election function.

If you haven’t got a sequence, call this function first, or else call election/3 with your seq instead.

It will return {true, seq} if the node is a leader.

If it’s not a leader, {false, seq} will return. And the current process will watch for leader changes. If the leader node was deleted, the process will receive a message {:leader_election, seq} and you must call election/3 again to volunteer to be a leader.

election(zk, path, seq)

Specs

election(zk, path, seq) ::
  {true, seq} |
  {false, seq}

Leader election function.

See election/2.