locus_maxmind_download (locus v2.3.15)

Copy Markdown View Source

Downloads an unpacked database edition from MaxMind, as well as its checksum (which it then verifies), without blocking the caller.

Summary

Types

event()

-type event() :: locus_http_download:event() | {checksum, locus_http_download:event()}.

msg()

-type msg() ::
          {event, event()} |
          {finished, {error, no_license_key_defined}} |
          {finished, {error, {checksum_download, term()}}} |
          {finished, {error, {bad_checksum, #{expected := binary(), actual := binary()}}}} |
          {finished, {error, {bad_checksum_format, binary()}}} |
          locus_http_download:msg().

opt()

-type opt() :: {license_key, binary() | string()} | {date, calendar:date()} | locus_http_download:opt().

state()

-opaque state()

success()

-type success() :: locus_http_download:success().

Functions

code_change/3

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

handle_call(Call, From, State)

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

handle_cast(Cast, State)

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

handle_info/2

-spec handle_info(term(), state()) ->
                     {noreply, state()} |
                     {stop, normal, state()} |
                     {stop, {database_download_stopped, pid(), term()}, state()} |
                     {stop, {checksum_download_stopped, pid(), term()}, state()} |
                     {stop, unexpected_info, state()}.

init(_)

-spec init(_) -> no_return().

proc_lib_init/1

-spec proc_lib_init([InitArg, ...]) -> no_return()
                       when
                           InitArg :: OwnerPid | Edition | RequestHeaders | Opts,
                           OwnerPid :: pid(),
                           Edition :: atom(),
                           RequestHeaders :: locus_http_download:headers(),
                           Opts :: [opt()].

start_link(Edition, RequestHeaders, Opts)

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

terminate(Reason, State)

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

validate_opts(MixedOpts)

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