Module watts_session_mgr

This module runs as a single worker and serializes all needed session creations to ensure uniqueness of tokens.

Behaviours: gen_server.

Description

This module runs as a single worker and serializes all needed session creations to ensure uniqueness of tokens.

Data Types

state()

state() = #state{}

Function Index

add_new_session_entry/1*store a new session and return if succeeded.
close_all_sessions/0close all sessions, gracefully shutdown.
close_session/1*delete and trigger a close at the session.
code_change/3does nothting.
create_new_session/0*create a new session.
delete_session/1*delete the session with the given id.
delete_sessions/1*delete list of sessions.
do_delete_all_sessions/0*delete all sessions.
get_all_sessions/0*get all active sessions.
get_cookie_data/1get the max age and the content of the cookie for the session.
get_session/1get a session by the cookie data, just a simple ets lookup.
get_unique_token/0*generate a unique token that can be stored in a cookie.
handle_call/3handle the calls coming in from the plublic functions.
handle_cast/2handle the stop cast form the stop function.
handle_info/2ignore all other messages.
init/1init the session manager process.
lookup_session_pid/1*lookup a session by its id.
new_session/0create a new session.
repeat_token_gen_if_needed/1*repeat the generation of the token until it is unique.
session_terminating/1a session died purge it.
session_wants_to_close/1a session wants to close, remove it and send a close back.
set_token_for_session/2*set the token for the session.
start_link/0start link implementation of the gen_server.
start_session/1*start a session and set the token.
stop/0send a cast to stop the process.
terminate/2do nothing, just stop.

Function Details

add_new_session_entry/1 *

add_new_session_entry(Token::binary()) -> {ok, binary()} | {error, used}

store a new session and return if succeeded

close_all_sessions/0

close_all_sessions() -> ok

close all sessions, gracefully shutdown

close_session/1 *

close_session(ID::any()) -> ok

delete and trigger a close at the session

code_change/3

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

does nothting

create_new_session/0 *

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

create a new session

delete_session/1 *

delete_session(ID::any()) -> ok

delete the session with the given id

delete_sessions/1 *

delete_sessions(T::[#{id => Id::any(), pid => pid()}]) -> ok

delete list of sessions

do_delete_all_sessions/0 *

do_delete_all_sessions() -> ok

delete all sessions

get_all_sessions/0 *

get_all_sessions() -> [#{id => Id::any(), pid => pid()}]

get all active sessions

get_cookie_data/1

get_cookie_data(Session::pid()) -> {ok, MaxAge::pos_integer(), CookieData::binary()}

get the max age and the content of the cookie for the session.

get_session/1

get_session(Cookie::binary() | undefined) -> {ok, pid() | undefined}

get a session by the cookie data, just a simple ets lookup

get_unique_token/0 *

get_unique_token() -> binary()

generate a unique token that can be stored in a cookie

To do

handle_call/3

handle_call(Request::any(), From::any(), State::state()) -> {reply, atom() | tuple(), state()}

handle the calls coming in from the plublic functions

handle_cast/2

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

handle the stop cast form the stop function

handle_info/2

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

ignore all other messages

init/1

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

init the session manager process

lookup_session_pid/1 *

lookup_session_pid(ID::any()) -> {ok, pid() | undefined}

lookup a session by its id

new_session/0

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

create a new session

repeat_token_gen_if_needed/1 *

repeat_token_gen_if_needed(X1::{ok, binary()} | {error, atom()}) -> binary()

repeat the generation of the token until it is unique

session_terminating/1

session_terminating(ID::any()) -> ok

a session died purge it

session_wants_to_close/1

session_wants_to_close(Token::binary()) -> ok

a session wants to close, remove it and send a close back

set_token_for_session/2 *

set_token_for_session(Token::binary(), Pid::pid()) -> ok

set the token for the session

start_link/0

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

start link implementation of the gen_server

start_session/1 *

start_session(Token::binary()) -> pid()

start a session and set the token

stop/0

stop() -> ok

send a cast to stop the process

terminate/2

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

do nothing, just stop


Generated by EDoc