View Source cozodb_callback_monitor (cozodb v0.2.1)

A transient worker that is used to listen to certain plum_db events and allow watchers to wait (blocking the caller) for certain conditions. This is used by plum_db_app during the startup process to wait for the following conditions:

  • Partition initisalisation – the worker subscribes to plum_db notifications and keeps track of each partition initialisation until they are all initialised (or failed to initilised) and replies to all watchers with a ok' or{error, FailedPartitions}', where FailedPartitions is a map() which keys are the partition number and the value is the reason for the failure.
  • Partition hashtree build – the worker subscribes to plum_db notifications and keeps track of each partition hashtree until they are all built (or failed to build) and replies to all watchers with a ok' or{error, FailedHashtrees}', where FailedHashtrees is a map() which keys are the partition number and the value is the reason for the failure.

A watcher is any process which calls the functions wait_for_partitions/0,1 and/or wait_for_hashtrees/0,1. Both functions will block the caller until the above conditions are met.

Summary

Types

state()

-type state() :: #state{}.

Functions

code_change(OldVsn, State, Extra)

-spec code_change(term() | {down, term()}, state(), term()) -> {ok, state()}.

handle_call(Message, From, State)

-spec handle_call(term(), {pid(), term()}, state()) ->
                     {reply, term(), state()} |
                     {reply, term(), state(), non_neg_integer()} |
                     {reply, term(), state(), {continue, term()}} |
                     {noreply, state()} |
                     {noreply, state(), non_neg_integer()} |
                     {noreply, state(), {continue, term()}} |
                     {stop, term(), term(), state()} |
                     {stop, term(), state()}.

handle_cast(Msg, State)

-spec handle_cast(term(), state()) ->
                     {noreply, state()} |
                     {noreply, state(), non_neg_integer()} |
                     {noreply, state(), {continue, term()}} |
                     {stop, term(), state()}.

handle_continue/2

handle_info/2

-spec handle_info(term(), state()) ->
                     {noreply, state()} |
                     {noreply, state(), non_neg_integer()} |
                     {noreply, state(), {continue, term()}} |
                     {stop, term(), state()}.

init/1

-spec init([]) -> {ok, state()} | {ok, state(), non_neg_integer() | infinity} | ignore | {stop, term()}.

start_link()

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

stop()

-spec stop() -> ok.

terminate(Reason, State)

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