Module: Phronomy::Agent::SuspendedSessionRegistry Private
- Defined in:
- lib/phronomy/agent/suspended_session_registry.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
In-process registry for Agent invocations suspended at :awaiting_approval.
When an agent invocation halts waiting for human approval, the InvocationContext is stored here keyed by session_id. Agent::Base.approve / Agent::Base.reject look up and remove the context to build a resume session.
Thread-safe. Each process has one shared instance via module methods. Cross-process persistence is out of scope (future SessionStore feature).
Class Method Summary collapse
-
.clear! ⇒ void
private
Clears all suspended sessions.
-
.exists?(session_id) ⇒ Boolean
private
Returns true when a session is suspended under the given id.
-
.fetch(session_id) ⇒ Phronomy::Agent::InvocationContext?
private
Retrieves and removes the suspended context for session_id.
-
.store(session_id, ctx) ⇒ void
private
Stores a suspended context under the given session_id.
Class Method Details
.clear! ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Clears all suspended sessions. Intended for test teardown only.
49 50 51 |
# File 'lib/phronomy/agent/suspended_session_registry.rb', line 49 def self.clear! @mutex.synchronize { @sessions.clear } end |
.exists?(session_id) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns true when a session is suspended under the given id.
42 43 44 |
# File 'lib/phronomy/agent/suspended_session_registry.rb', line 42 def self.exists?(session_id) @mutex.synchronize { @sessions.key?(session_id) } end |
.fetch(session_id) ⇒ Phronomy::Agent::InvocationContext?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Retrieves and removes the suspended context for session_id. Returns nil when no matching session exists.
34 35 36 |
# File 'lib/phronomy/agent/suspended_session_registry.rb', line 34 def self.fetch(session_id) @mutex.synchronize { @sessions.delete(session_id) } end |
.store(session_id, ctx) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Stores a suspended context under the given session_id.
25 26 27 |
# File 'lib/phronomy/agent/suspended_session_registry.rb', line 25 def self.store(session_id, ctx) @mutex.synchronize { @sessions[session_id] = ctx } end |