barrel_p2p_replica behaviour (barrel_p2p v0.1.0)

View Source

Summary

Types

config/0

-type config() :: #{name := atom(), callback := module()}.

Callbacks

replica_anti_entropy/0

(optional)
-callback replica_anti_entropy() -> boolean().

replica_apply_full_sync/2

-callback replica_apply_full_sync(Name :: atom(), Snapshot :: term()) -> ok.

replica_full_sync_snapshot/1

-callback replica_full_sync_snapshot(Name :: atom()) -> {sync, Snapshot :: term()} | empty.

replica_merge_custom/2

(optional)
-callback replica_merge_custom(Name :: atom(), Payload :: term()) -> ok.

replica_merge_delta/2

-callback replica_merge_delta(Name :: atom(), Delta :: barrel_p2p_ormap:ormap()) -> ok.

replica_remove_node/2

-callback replica_remove_node(Name :: atom(), node()) -> ok.

Functions

broadcast_custom(Name, Payload)

-spec broadcast_custom(atom(), term()) -> ok.

broadcast_update(Name, Update)

-spec broadcast_update(atom(), {add, term(), term()} | {remove, term()}) -> ok.

handle_call(Request, From, State)

handle_cast(Msg, State)

handle_info(Info, State)

init(_)

start_link(Config)

-spec start_link(config()) -> {ok, pid()} | {error, term()}.

terminate(Reason, State)