pub struct InMemoryAgentRuntime { /* private fields */ }Expand description
An AgentRuntime that tracks lifecycle state in a map without spawning
any processes.
A first-class adapter (hex rule 6 — not test-only): services like
ControlPlane are unit-tested against
it, and it serves as a dev substrate when real process isolation isn’t wanted.
start reports RuntimeHealth::Healthy immediately — there is no real
process or card to probe, so it models the happy path the composition needs.
Implementations§
Source§impl InMemoryAgentRuntime
impl InMemoryAgentRuntime
Sourcepub async fn push_log(&self, id: &AgentId, line: impl Into<String>)
pub async fn push_log(&self, id: &AgentId, line: impl Into<String>)
Record a line as though the agent had printed it.
The stand-in for a backend that captures output, so everything above the
port — ControlPlane::logs, the HTTP route,
the client — is exercisable without a container engine or a child
process. Lines are kept for unknown ids too, so a test can seed a log
before provisioning.
Trait Implementations§
Source§impl AgentRuntime for InMemoryAgentRuntime
impl AgentRuntime for InMemoryAgentRuntime
Source§fn recover<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Recovered<AgentId>, RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn recover<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Recovered<AgentId>, RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Reports everything it holds as Recovered::Adopted.
This fake stands in for a durable backend, so it answers like one: the
map plays the part the container engine plays for real. That is what lets
ControlPlane::recover — which has to
re-register cards, tolerate unreachable agents, and stay idempotent — be
tested without Docker or a network.
Source§fn logs<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 AgentId,
tail: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn logs<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 AgentId,
tail: Option<usize>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Serve back whatever push_log recorded.
Answers like a backend that does capture output — an empty list means
the agent printed nothing, never RuntimeError::Unsupported — for the
same reason recover answers Adopted: this fake
stands in for the durable case so the layers above it can be tested.
Source§fn provision<'life0, 'async_trait>(
&'life0 self,
spec: AgentSpec,
) -> Pin<Box<dyn Future<Output = Result<AgentId, RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn provision<'life0, 'async_trait>(
&'life0 self,
spec: AgentSpec,
) -> Pin<Box<dyn Future<Output = Result<AgentId, RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
AgentId.Source§fn start<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn start<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
RuntimeError::AlreadyRunning if it is
already live, RuntimeError::NotFound if it was never provisioned.Source§fn stop<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stop<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Ok. RuntimeError::NotFound if it was never provisioned.Source§fn health<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Result<RuntimeHealth, RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn health<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Result<RuntimeHealth, RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
RuntimeHealth.Source§impl Clone for InMemoryAgentRuntime
impl Clone for InMemoryAgentRuntime
Auto Trait Implementations§
impl !RefUnwindSafe for InMemoryAgentRuntime
impl !UnwindSafe for InMemoryAgentRuntime
impl Freeze for InMemoryAgentRuntime
impl Send for InMemoryAgentRuntime
impl Sync for InMemoryAgentRuntime
impl Unpin for InMemoryAgentRuntime
impl UnsafeUnpin for InMemoryAgentRuntime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more