View Source partisan_plumtree_backend (partisan v5.0.0-rc.8)

This modules implements a server that realises the partisan_plumtree_broadcast_handler behaviour in order to diseminate heartbeat messages. Partisan uses these heartbeat messages to stimulate the Epidemic Broadcast Tree construction.

The server will schedule the sending of a hearbeat` message periodically using the `broadcast_heartbeat_interval` option. Notice that this handler does not perform AAE Exchanges, as we will always have a periodic heartbeat. For that reason, the implementation of the <a docgen-rel="seemfa" docgen-href="partisan_plumtree_broadcast_handler#exchange/1" href="partisan_plumtree_broadcast_handler.html#exchange-1"><code>partisan_plumtree_broadcast_handler:exchange/1</code></a> callback always returns `ignore.

Summary

Functions

Returns the channel to be used when broadcasting a message on behalf of this handler.
Returns from the broadcast message the identifier and the payload. In this case a tuple where both arguments have the broadcast message timestamp. These messages are used by Partisan as a stimulus for the Epidemic Broadcast Tree (Plumtree) construction.
Returns ignore`. This is because we dont need to worry about reliable delivery: we always know we'll have another heartbeat message to further repair during the next interval.
Given a message identifier and a clock, return a given message.
Use the clock on the object to determine if this message is stale or not.
Perform a merge of an incoming object with an object in the local datastore.
Same as start_link([]).
Start and link to calling process.

Types

-type broadcast_id() :: timestamp().
-type broadcast_message() :: #broadcast{}.
-type broadcast_payload() :: timestamp().
-type state() :: #state{}.
-type timestamp() :: {node(), non_neg_integer()}.

Functions

-spec broadcast_channel() -> partisan:channel().
Returns the channel to be used when broadcasting a message on behalf of this handler.
Link to this function

broadcast_data(Broadcast)

View Source
-spec broadcast_data(broadcast_message()) -> {broadcast_id(), broadcast_payload()}.
Returns from the broadcast message the identifier and the payload. In this case a tuple where both arguments have the broadcast message timestamp. These messages are used by Partisan as a stimulus for the Epidemic Broadcast Tree (Plumtree) construction.
Link to this function

code_change(OldVsn, State, Extra)

View Source
-spec code_change(term() | {down, term()}, state(), term()) -> {ok, state()}.
-spec exchange(node()) -> {ok, pid()} | {error, any()} | ignore.
Returns ignore`. This is because we dont need to worry about reliable delivery: we always know we'll have another heartbeat message to further repair during the next interval.
Link to this function

extract_log_type_and_payload(Message)

View Source
-spec graft(broadcast_id()) -> stale | {ok, broadcast_payload()} | {error, term()}.
Given a message identifier and a clock, return a given message.
Link to this function

handle_call(Event, From, State)

View Source
-spec handle_call(term(), {pid(), term()}, state()) -> {reply, term(), state()}.
Link to this function

handle_cast(Event, State)

View Source
-spec handle_cast(term(), state()) -> {noreply, state()}.
Link to this function

handle_info(Event, State)

View Source
-spec init([]) -> {ok, state()}.
-spec is_stale(broadcast_id()) -> boolean().
Use the clock on the object to determine if this message is stale or not.
-spec merge(broadcast_id(), broadcast_payload()) -> boolean().
Perform a merge of an incoming object with an object in the local datastore.
-spec start_link() -> {ok, pid()} | ignore | {error, term()}.
Same as start_link([]).
-spec start_link(list()) -> {ok, pid()} | ignore | {error, term()}.
Start and link to calling process.
Link to this function

terminate(Reason, State)

View Source
-spec terminate(term(), state()) -> term().