(add-leader-watch raft key fn)
(add-leader-watch raft key fn event-type)
Registers a function to be called with each leader change. Specify any key which can be used to unregister function later.
Function will be called with one four args: key, event-type, raft-state before the leader change and raft-state after the leader change.
Important! Function is called synchronously, and therefore RAFT is stopped while processing. If function requires raft calls, it must be run asynchronously. Good to run asynchronously for anything that might be slow.
If key is already in use, overwrites existing watch function with fn.
Optionally register for a specific event-type. When no event-type is specified, triggers for all leader change events.
event-types are:
Registers a function to be called with each leader change. Specify any key which can be used to unregister function later. Function will be called with one four args: key, event-type, raft-state before the leader change and raft-state after the leader change. Important! Function is called synchronously, and therefore RAFT is stopped while processing. If function requires raft calls, it *must* be run asynchronously. Good to run asynchronously for anything that might be slow. If key is already in use, overwrites existing watch function with fn. Optionally register for a specific event-type. When no event-type is specified, triggers for all leader change events. event-types are: - :become-leader - triggered when this server becomes leader - :become-follower - triggered when this server becomes a follower (was leader)
(call-leader-watch change-map)
Used internally to call registered leader watch functions.
Used internally to call registered leader watch functions.
(remove-leader-watch raft key)
Removes watch function with specified key.
Removes watch function with specified key.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close