View Source locus_loader (locus v2.3.7)

Loads and unpacks databases while managing any associated assets (e.g. reading from and writing to cache)

Link to this section Summary

Link to this section Types

Specs

blob_format() :: tgz | tarball | gzip | gzipped_mmdb | mmdb | unknown.

Specs

cacher_msg() :: locus_filesystem_store:msg().
Link to this type

error_retry_behaviour/0

View Source

Specs

error_retry_behaviour() ::
    {backoff, milliseconds_interval()} | {exponential_backoff, exponential_backoff_params()}.

Specs

Link to this type

event_cache_attempt_finished/0

View Source

Specs

event_cache_attempt_finished() ::
    {cache_attempt_finished, locus_filesystem_store:path(), ok} |
    {cache_attempt_finished, locus_filesystem_store:path(), {error, term()}}.
Link to this type

exponential_backoff_params/0

View Source

Specs

exponential_backoff_params() ::
    #{min_interval := milliseconds_interval(),
      max_interval := milliseconds_interval(),
      growth_base := milliseconds_interval(),
      growth_exponent := number()}.

Specs

Specs

Specs

Specs

loader_opt() ::
    {update_period, milliseconds_interval()} |
    {error_retries, error_retry_behaviour()} |
    no_cache |
    {database_cache_file, file:filename()}.
Link to this type

maxmind_origin_params/0

View Source

Specs

maxmind_origin_params() :: #{license_key := unicode:unicode_binary(), date => calendar:date()}.
Link to this type

milliseconds_interval/0

View Source

Specs

milliseconds_interval() :: pos_integer().

Specs

msg() ::
    {event, event()} |
    {load_success, source(), calendar:datetime(), locus_mmdb:database()} |
    {load_failure, source(), Reason :: term()}.

Specs

opt() :: loader_opt() | fetcher_opt().

Specs

origin() ::
    {maxmind, atom()} |
    {http, locus_http_download:url()} |
    {filesystem, locus_filesystem_load:path()} |
    locus:custom_fetcher().

Specs

provider_source() :: {maxmind, atom()}.

Specs

settings() :: #settings{}.

Specs

Specs

state() :: #state{}.
Link to this type

uniformly_distributed_update_period/0

View Source

Specs

uniformly_distributed_update_period() :: #{min := pos_integer(), max := pos_integer()}.

Specs

update_period() :: pos_integer() | uniformly_distributed_update_period().

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

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_info(Info, State)

View Source

Specs

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

Specs

init([pid() | atom() | origin() | [loader_opt()] | [fetcher_opt()], ...]) -> {ok, state()}.
Link to this function

start_link(DatabaseId, Origin, LoaderOpts, FetcherOpts)

View Source

Specs

start_link(atom(), origin(), [loader_opt()], [fetcher_opt()]) -> {ok, pid()}.
Link to this function

terminate(Reason, State)

View Source

Specs

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

Specs

valid_blob_formats() -> [tgz | tarball | gzip | gzipped_mmdb | mmdb | unknown, ...].
Link to this function

validate_opts(Origin, MixedOpts)

View Source

Specs

validate_opts(origin(), proplists:proplist()) ->
                 {ok, {[opt()], [fetcher_opt()], proplists:proplist()}} |
                 {error, BadOpt :: term()}.