locus_database (locus v2.3.15)

Copy Markdown View Source

Launches the database loader and later shares the unpacked database, as well as any updates to it, through persistent_term.

Summary

Types

database_opt()

-type database_opt() :: {event_subscriber, atom() | pid()}.

event()

event_load_attempt_finished()

-type event_load_attempt_finished() ::
          {load_attempt_finished, locus_loader:source(), {ok, Version :: calendar:datetime()}} |
          {load_attempt_finished, locus_loader:source(), {error, term()}}.

opt()

-type opt() :: database_opt() | locus_loader:opt().

origin()

-type origin() :: locus_loader:origin().

state()

-opaque state()

static_child_spec()

-type static_child_spec() ::
          #{id := term(),
            start := {locus_database, start_link, [atom() | origin() | [opt()], ...]},
            restart := permanent,
            shutdown := non_neg_integer(),
            type := worker,
            modules := [locus_database, ...]}.

Functions

async_get_version_or_subscribe(Id)

-spec async_get_version_or_subscribe(atom()) -> {await, reference()}.

code_change/3

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

dynamic_child_spec(ChildId)

-spec dynamic_child_spec(term()) -> supervisor:child_spec().

find(Id)

-spec find(atom()) ->
              {ok, locus_mmdb:database(), locus_loader:source(), calendar:datetime()} |
              {error, database_not_loaded} |
              {error, database_unknown}.

handle_call(Call, From, State)

-spec handle_call(term(), {pid(), reference()}, state()) -> {stop, unexpected_call, state()}.

handle_cast/2

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

handle_info/2

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

init/1

-spec init([atom() | origin() | [opt()], ...]) -> {ok, state()} | {stop, {invalid_opt, term()}}.

start(Id, Origin, Opts)

-spec start(atom(), origin(), [opt()]) ->
               ok |
               {error, already_started} |
               {error, {invalid_opt, term()}} |
               {error, application_not_running}.

start_link(Id, Origin, Opts)

-spec start_link(atom(), origin(), [opt()]) -> {ok, pid()}.

static_child_spec(ChildId, DatabaseId, Origin, Opts)

-spec static_child_spec(term(), atom(), origin(), [opt()]) -> static_child_spec().

stop(Id, Reason)

-spec stop(atom(), term()) -> ok | {error, not_found}.

terminate(Reason, State)

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

version(BuildEpoch)

-spec version(BuildEpoch) -> Version
                 when BuildEpoch :: non_neg_integer(), Version :: calendar:datetime().

Returns the database version based on its build epoch (UNIX timestamp).