View Source locus_custom_fetcher behaviour (locus v2.3.11)

Callbacks for providing your own database fetcher

Summary

Types

-type description() :: #{database_is_stored_remotely := boolean(), database_is_fetched_from := term()}.
Link to this type

event_load_attempt_dismissed/0

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

event_load_attempt_started/0

View Source
-type event_load_attempt_started() :: {load_attempt_started, source()}.
-type msg() ::
    {event, event()} |
    {finished, {success, success()}} |
    {finished, dismissed} |
    {finished, {error, term()}}.
-type source() :: {local | remote, {custom, term()}}.
-opaque state()
-type success() ::
    #{format := locus_loader:blob_format(),
      content := binary(),
      metadata := successful_fetch_metadata()}.
Link to this type

successful_fetch_metadata/0

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

Callbacks

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