Module watts_temp_cred

this is the management module for the temporary plugin result data storage.

Behaviours: gen_server.

See also: watts_temp_cred_data.

Description

this is the management module for the temporary plugin result data storage. The results (credentials or oidc_login request) are only stored in RAM and each in a separate process.

This module is running as a registered process so it can be reached without knowing its process id. It sets up the API to store and retrieve results.

Data Types

cred_record()

cred_record() = {Id::binary(), UserId::binary(), DataPid::pid(), MRef::reference()}

state()

state() = #state{creds = [cred_record()]}

API.

Function Index

add_cred/2add a credential, this creates a new temp_cred_data process.
add_credential/3*store a new credential, ensure to have a unique id.
code_change/3code_change implementation, does nothing.
credential_exists/3*check if a credential for the user exists.
exists/2check if a Credential of id exists for given user.
gen_random_id/1*generate a random unique credential id.
get_all_creds/0DO NOT USE!
get_cred/2retrieve the data if the userid is the same.
get_cred_pid/3*get the pid of the data process.
get_credential/3*get a crecential for a user.
handle_call/3handle the gen_server:call.
handle_cast/2only support the stop cast.
handle_info/2only support the Down info for a data process.
init/1initialize the gen_server with an empty state.
start_link/0start the gen_server linked.
stop/0stop the process.
terminate/2implementation of terminate, does nothing.

Function Details

add_cred/2

add_cred(Credential::watts:temp_cred(), UserId::binary()) -> {ok, Id::binary()}

add a credential, this creates a new temp_cred_data process.

add_credential/3 *

add_credential(Credential::watts:temp_cred(), UserId::binary(), State::state()) -> {ok, CredentialId::binary(), NewState::state()}

store a new credential, ensure to have a unique id.

code_change/3

code_change(OldVsn::any(), State::state(), Extra::any()) -> {ok, state()}

code_change implementation, does nothing

credential_exists/3 *

credential_exists(CredentiaId::binary(), UserId::binary(), State::state()) -> boolean()

check if a credential for the user exists

exists/2

exists(CredId::binary(), UserId::binary()) -> boolean()

check if a Credential of id exists for given user.

gen_random_id/1 *

gen_random_id(State::state()) -> binary()

generate a random unique credential id

get_all_creds/0

get_all_creds() -> {ok, Creds::list()}

DO NOT USE! get a list of all credentials *ONLY* for testing!

get_cred/2

get_cred(CredId::binary(), UserId::binary()) -> {ok, Credential::watts:temp_cred()} | {error, Reason::atom()}

retrieve the data if the userid is the same

get_cred_pid/3 *

get_cred_pid(CredentiaId::binary(), UserId::binary(), State::state()) -> {ok, Pid::pid()} | {error, not_found}

get the pid of the data process.

get_credential/3 *

get_credential(CredentiaId::binary(), UserId::binary(), State::state()) -> {ok, Credential::watts:temp_cred()} | {error, not_found}

get a crecential for a user.

handle_call/3

handle_call(Msg::any(), From::any(), State::state()) -> {reply, Result::any(), NewState::state()}

handle the gen_server:call

handle_cast/2

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

only support the stop cast

handle_info/2

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

only support the Down info for a data process

init/1

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

initialize the gen_server with an empty state.

start_link/0

start_link() -> {ok, pid()}

start the gen_server linked

stop/0

stop() -> ok

stop the process.

terminate/2

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

implementation of terminate, does nothing


Generated by EDoc