Snakepit.Bridge.Session (Snakepit v0.6.10)
View SourceSession data structure for centralized session management.
Stores program metadata and session state for worker affinity.
Summary
Functions
Removes a program from the session.
Checks if a session has expired based on its TTL.
Gets metadata from the session.
Gets a program from the session.
Gets session statistics.
Creates a new session with the given ID and options.
Updates session metadata.
Adds or updates a program in the session.
Updates the last_accessed timestamp to the current time.
Validates that a session struct has all required fields and valid data.
Types
Functions
Removes a program from the session.
Parameters
session- The session to updateprogram_id- The program identifier to remove
Returns
Updated session with the program removed.
Checks if a session has expired based on its TTL.
Parameters
session- The session to checkcurrent_time- Optional current time (defaults to current monotonic time)
Returns
true if the session has expired, false otherwise.
Gets metadata from the session.
Parameters
session- The session to querykey- The metadata keydefault- Default value if key not found
Returns
The metadata value or the default.
Gets a program from the session.
Parameters
session- The session to queryprogram_id- The program identifier
Returns
{:ok, program_data} if found, {:error, :not_found} if not found.
Gets session statistics.
Creates a new session with the given ID and options.
Updates session metadata.
Parameters
session- The session to updatekey- The metadata keyvalue- The metadata value
Returns
Updated session with the metadata updated.
Adds or updates a program in the session.
Parameters
session- The session to updateprogram_id- The program identifierprogram_data- The program data to store
Returns
Updated session with the program added/updated.
Updates the last_accessed timestamp to the current time.
Parameters
session- The session to touch
Returns
Updated session with current last_accessed timestamp.
Validates that a session struct has all required fields and valid data.
Parameters
session- The session to validate
Returns
:ok if valid, {:error, reason} if invalid.