View Source locus_custom_fetcher behaviour (locus v2.3.7)

Callbacks for providing your own database fetcher

Link to this section Summary

Link to this section Types

Specs

description() :: #{database_is_stored_remotely := boolean(), database_is_fetched_from := term()}.

Specs

Link to this type

event_load_attempt_dismissed/0

View Source

Specs

event_load_attempt_dismissed() :: {load_attempt_dismissed, source()}.
Link to this type

event_load_attempt_started/0

View Source

Specs

event_load_attempt_started() :: {load_attempt_started, source()}.

Specs

msg() ::
    {event, event()} |
    {finished, {success, success()}} |
    {finished, dismissed} |
    {finished, {error, term()}}.

Specs

source() :: {local | remote, {custom, term()}}.

Specs

state() :: #state{}.

Specs

success() ::
    #{format := locus_loader:blob_format(),
      content := binary(),
      metadata := successful_fetch_metadata()}.
Link to this type

successful_fetch_metadata/0

View Source

Specs

successful_fetch_metadata() ::
    #{fetched_from := term(), modified_on := calendar:datetime() | unknown}.

Link to this section Callbacks

Specs

conditionally_fetch(Args, {depending_on, PreviousFetchMetadata}) ->
                       {fetched, Success} | dismissed | {error, Reason}
                       when
                           Args :: term(),
                           PreviousFetchMetadata :: successful_fetch_metadata(),
                           Success :: success(),
                           Reason :: term().

Specs

description(Args) -> description() when Args :: term().

Specs

fetch(Args) -> {fetched, Success} | {error, Reason}
         when Args :: term(), Success :: success(), Reason :: term().

Link to this section Functions

Link to this function

code_change(OldVsn, State, Extra)

View Source

Specs

code_change(term(), state(), term()) -> {ok, state()}.
Link to this function

description(Module, Args)

View Source

Specs

description(module(), term()) -> description().
Link to this function

handle_call(Call, From, State)

View Source

Specs

handle_call(term(), {pid(), reference()}, state()) -> {stop, unexpected_call, state()}.
Link to this function

handle_cast(Cast, State)

View Source

Specs

handle_cast(term(), state()) -> {stop, unexpected_cast, state()}.
Link to this function

handle_continue(_, State)

View Source

Specs

handle_continue(fetch, state()) -> {stop, normal, state()}.
Link to this function

handle_info(Info, State)

View Source

Specs

handle_info(term(), state()) -> {stop, unexpected_info, state()}.

Specs

init([InitArg, ...]) -> {ok, state(), {continue, fetch}}
        when
            InitArg :: OwnerPid | Source | Module | Args | PreviousFetchMetadata,
            OwnerPid :: pid(),
            Source :: source(),
            Module :: module(),
            Args :: term(),
            PreviousFetchMetadata :: successful_fetch_metadata() | undefined.

Specs

source(module(), term()) -> source().
Link to this function

start_link(Source, Module, Args, PreviousFetchMetadata)

View Source

Specs

start_link(source(), module(), term(), successful_fetch_metadata() | undefined) -> {ok, pid()}.
Link to this function

terminate(Reason, State)

View Source

Specs

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