pub struct RuntimeSessionAdapter { /* private fields */ }Expand description
Wraps a SessionService to provide v9 runtime capabilities.
Maintains a per-session RuntimeDriver registry. When sessions are registered
with a CoreExecutor, a RuntimeLoop task is spawned that processes queued
inputs by calling CoreExecutor::apply() (which triggers
SessionService::start_turn() under the hood).
Implementations§
Source§impl RuntimeSessionAdapter
impl RuntimeSessionAdapter
Sourcepub fn ephemeral() -> Self
pub fn ephemeral() -> Self
Create an ephemeral adapter (all sessions use EphemeralRuntimeDriver).
Sourcepub fn persistent(store: Arc<dyn RuntimeStore>) -> Self
pub fn persistent(store: Arc<dyn RuntimeStore>) -> Self
Create a persistent adapter with a RuntimeStore.
Sourcepub async fn register_session(&self, session_id: SessionId)
pub async fn register_session(&self, session_id: SessionId)
Register a runtime driver for a session (no RuntimeLoop — inputs queue but nothing processes them automatically). Useful for tests and legacy mode.
Sourcepub async fn register_session_with_executor(
&self,
session_id: SessionId,
executor: Box<dyn CoreExecutor>,
)
pub async fn register_session_with_executor( &self, session_id: SessionId, executor: Box<dyn CoreExecutor>, )
Register a runtime driver for a session WITH a RuntimeLoop backed by a
CoreExecutor. When accept_input() queues an input and requests wake,
the loop dequeues it and calls executor.apply() (which triggers
SessionService::start_turn()).
Sourcepub async fn ensure_session_with_executor(
&self,
session_id: SessionId,
executor: Box<dyn CoreExecutor>,
)
pub async fn ensure_session_with_executor( &self, session_id: SessionId, executor: Box<dyn CoreExecutor>, )
Ensure a runtime driver with executor exists for the session.
If a session was already registered without a loop, upgrade the existing driver in place so queued inputs remain attached to the same runtime ledger and can start draining immediately.
Sourcepub async fn unregister_session(&self, session_id: &SessionId)
pub async fn unregister_session(&self, session_id: &SessionId)
Unregister a session’s runtime driver.
Drops the wake channel sender, which causes the RuntimeLoop to exit.
Sourcepub async fn contains_session(&self, session_id: &SessionId) -> bool
pub async fn contains_session(&self, session_id: &SessionId) -> bool
Check whether a runtime driver is already registered for a session.
Sourcepub async fn interrupt_current_run(
&self,
session_id: &SessionId,
) -> Result<(), RuntimeDriverError>
pub async fn interrupt_current_run( &self, session_id: &SessionId, ) -> Result<(), RuntimeDriverError>
Cancel the currently-running turn for a registered session.
Sourcepub async fn accept_input_and_run<T, F, Fut>(
&self,
session_id: &SessionId,
input: Input,
op: F,
) -> Result<T, RuntimeDriverError>where
F: FnOnce(RunId, RunPrimitive) -> Fut,
Fut: Future<Output = Result<(T, CoreApplyOutput), RuntimeDriverError>>,
pub async fn accept_input_and_run<T, F, Fut>(
&self,
session_id: &SessionId,
input: Input,
op: F,
) -> Result<T, RuntimeDriverError>where
F: FnOnce(RunId, RunPrimitive) -> Fut,
Fut: Future<Output = Result<(T, CoreApplyOutput), RuntimeDriverError>>,
Accept an input and execute it synchronously through the runtime driver.
This is useful for surfaces that need the legacy request/response shape while still preserving v9 input lifecycle semantics.
Sourcepub async fn accept_input_with_completion(
&self,
session_id: &SessionId,
input: Input,
) -> Result<(AcceptOutcome, Option<CompletionHandle>), RuntimeDriverError>
pub async fn accept_input_with_completion( &self, session_id: &SessionId, input: Input, ) -> Result<(AcceptOutcome, Option<CompletionHandle>), RuntimeDriverError>
Accept an input and return a completion handle that resolves when the input reaches a terminal state (Consumed or Abandoned).
Returns (AcceptOutcome, Option<CompletionHandle>):
(Accepted, Some(handle))— await handle for result(Deduplicated, Some(handle))— joined in-flight waiter(Deduplicated, None)— input already terminal; no waiter needed(Rejected, _)— returned asErr(ValidationFailed)