Tinkex.SessionManager (Tinkex v0.3.4)
View SourceManages Tinkex sessions and heartbeats across multiple configs.
Summary
Functions
Returns a specification to start this module under a supervisor.
Start the SessionManager process.
Create a new session for the given config.
Stop tracking a session.
Types
@type session_entry() :: %{ config: Tinkex.Config.t(), last_success_ms: non_neg_integer(), last_error: term() | nil, failure_count: non_neg_integer() }
@type session_id() :: String.t()
@type state() :: %{ sessions: %{required(session_id()) => session_entry()}, sessions_table: atom(), heartbeat_interval_ms: non_neg_integer(), heartbeat_warning_after_ms: non_neg_integer(), max_failure_count: non_neg_integer() | :infinity, max_failure_duration_ms: non_neg_integer() | :infinity, session_api: module(), timer_ref: reference() | nil }
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Start the SessionManager process.
@spec start_session(Tinkex.Config.t(), GenServer.server()) :: {:ok, session_id()} | {:error, term()}
Create a new session for the given config.
@spec stop_session(session_id(), GenServer.server()) :: :ok
Stop tracking a session.
This is a synchronous call to ensure the session is removed from heartbeat tracking before returning. This prevents race conditions where a heartbeat fires after the caller has shut down but before the session was removed.