Partitioned route-state manager for deterministic session routing.
Route state is sharded by session key hash so updates and lookups avoid a singleton bottleneck. Each partition enforces TTL and bounded capacity.
Summary
Functions
Return manager config merged from defaults, global opts, and instance opts.
Fetch fresh route state for a session key.
Return configured partition count.
Return the PID for a partition worker, if running.
Trigger pruning across all partitions and return total expired deletions.
Resolve a route for a session key, using fallbacks when needed.
Resolve the partition index for a session key.
Store route state for a session key.
Types
@type fallback_reason() :: :stale | :miss | :thread_scope_miss | :session_unavailable
@type prune_result() :: %{pruned: non_neg_integer(), partitions: pos_integer()}
@type resolution() :: %{ :external_room_id => term(), :route => route(), :partition => non_neg_integer(), :session_key => session_key(), :source => :state_hit | :partition_fallback | :provided_fallback, :fallback => boolean(), :stale => boolean(), optional(:fallback_reason) => fallback_reason() }
@type session_key() :: Jido.Messaging.SessionKey.t()
Functions
Return manager config merged from defaults, global opts, and instance opts.
@spec get(module(), session_key()) :: {:ok, route_record()} | {:error, :not_found | :expired | :partition_unavailable}
Fetch fresh route state for a session key.
@spec partition_count(module()) :: pos_integer()
Return configured partition count.
@spec partition_pid(module(), session_key() | non_neg_integer()) :: pid() | nil
Return the PID for a partition worker, if running.
@spec prune(module()) :: prune_result()
Trigger pruning across all partitions and return total expired deletions.
@spec resolve(module(), session_key(), [route()] | route()) :: {:ok, resolution()} | {:error, term()}
Resolve a route for a session key, using fallbacks when needed.
@spec route_partition(module(), session_key()) :: non_neg_integer()
Resolve the partition index for a session key.
@spec set(module(), session_key(), route(), keyword()) :: :ok | {:error, term()}
Store route state for a session key.