Module watts_rsp_keys

this module implements a gen_server that keeps the public keys of an RSP up to date.

Behaviours: gen_server.

Description

this module implements a gen_server that keeps the public keys of an RSP up to date. So the signed jwts can always be validated.

Data Types

config()

config() = #{id => binary(), key_location => binary(), term() => term()}

key()

key() = map()

keys()

keys() = [key()]

state()

state() = #state{id = undefined | binary(), keys = any(), key_location = undefined | binary(), location_type = none | file | url, http_req_id = any(), http_result = any(), reading_keys = any(), last_error = any(), next_try = any()}

Function Index

code_change/3do nothing.
deadline_in/1*calculate the next deadline.
extract_rsp_keys/1*extract the keys from the data (either file or http response).
fetch_rsp_keys/2*trigger the async http request.
get_keys/1return the chached keys.
get_last_error/1return the last error.
get_location_type/1*get the location type, either file or url of the keys.
get_rsp_keys/1*get the keys by reading the file or triggering the http request.
handle_call/3handle the get error/keys calls.
handle_cast/2handle the request to reread keys or stop.
handle_decode_result/1*handle the decode result.
handle_http_client_crash/2*handle crashing of the http client.
handle_http_result/1*handle the http response.
handle_http_result/4*handle a http result and extract rsp keys.
handle_info/2handle the async incoming http responses when fetching keys.
handle_key_result/1*handle the decoding result, either store the keys in stat or skip.
init/1initilize the process.
maybe_cancel_request/2*maybe cancel a current running http request.
maybe_trigger_key_read/1*maybe trigger reading the keys again.
new/1start a new rsp gen_server process.
reread/1triger a reading of the keys.
reread_keys_if_needed/1*rereadkeys if deadline reached.
result_or_default/2*return either value if present, if not default.
safe_decode/2*safely decode any data by returning on success or default on failure.
start_link/1start the gen_server linked to the supervisor.
stop/1stop the process.
terminate/2do nothing.

Function Details

code_change/3

code_change(X1::any(), State::state(), X3::any()) -> {ok, state()}

do nothing

deadline_in/1 *

deadline_in(Seconds::non_neg_integer()) -> non_neg_integer()

calculate the next deadline

extract_rsp_keys/1 *

extract_rsp_keys(X1::{ok | integer(), string() | binary()} | {error, any()}) -> {ok, keys()} | {error, any()}

extract the keys from the data (either file or http response)

fetch_rsp_keys/2 *

fetch_rsp_keys(Url::binary(), State::state()) -> state()

trigger the async http request

get_keys/1

get_keys(Pid::pid() | undefined) -> {ok, keys()}

return the chached keys

get_last_error/1

get_last_error(Pid::pid()) -> {ok, any()}

return the last error

get_location_type/1 *

get_location_type(Url::binary()) -> {binary(), file | url} | {none, unknown}

get the location type, either file or url of the keys

get_rsp_keys/1 *

get_rsp_keys(State::state()) -> {{ok, keys()} | {error, any()}, state()}

get the keys by reading the file or triggering the http request

handle_call/3

handle_call(Request::any(), From::any(), State::state()) -> {reply, any(), state(), non_neg_integer()}

handle the get error/keys calls

handle_cast/2

handle_cast(Request::any(), State::state()) -> {noreply, state(), non_neg_integer()} | {stop, normal, state()}

handle the request to reread keys or stop

handle_decode_result/1 *

handle_decode_result(X1::map() | any()) -> {ok, keys()} | {error, bad_data}

handle the decode result

handle_http_client_crash/2 *

handle_http_client_crash(Reason::any(), State::state()) -> state()

handle crashing of the http client

handle_http_result/1 *

handle_http_result(State::state()) -> state()

handle the http response.

handle_http_result/4 *

handle_http_result(X1::boolean(), Status::integer(), Body::binary(), State::state()) -> state()

handle a http result and extract rsp keys

handle_info/2

handle_info(Request::any(), State::state()) -> {noreply, state(), non_neg_integer()}

handle the async incoming http responses when fetching keys

handle_key_result/1 *

handle_key_result(X1::{{ok, keys()} | {error, any()}, state()}) -> state()

handle the decoding result, either store the keys in stat or skip

init/1

init(X1::config()) -> {ok, state()}

initilize the process

maybe_cancel_request/2 *

maybe_cancel_request(X1::boolean(), Id::any()) -> ok

maybe cancel a current running http request

maybe_trigger_key_read/1 *

maybe_trigger_key_read(X1::boolean()) -> ok

maybe trigger reading the keys again

new/1

new(Map::config()) -> {ok, pid()}

start a new rsp gen_server process

reread/1

reread(Pid::pid()) -> ok

triger a reading of the keys

reread_keys_if_needed/1 *

reread_keys_if_needed(State::state()) -> ok

rereadkeys if deadline reached

result_or_default/2 *

result_or_default(X1::{ok, any()} | any(), Default::any()) -> any()

return either value if present, if not default

safe_decode/2 *

safe_decode(Data::binary(), Default::any()) -> any()

safely decode any data by returning on success or default on failure

start_link/1

start_link(Map::config()) -> {ok, pid()}

start the gen_server linked to the supervisor

stop/1

stop(Pid::pid()) -> ok

stop the process

terminate/2

terminate(Reason::any(), State::state()) -> ok

do nothing


Generated by EDoc