pub struct RunContext {
pub run_id: RunId,
pub run_store: Arc<dyn RunStore>,
pub replay_store: Option<Arc<dyn ReplayStore>>,
pub replay_cursor: Option<Arc<Mutex<ReplayCursor>>>,
}Expand description
Pairs a RunId with the RunStore used to persist its trace.
Threaded from the server entry points (POST /v1/tasks, POST /v1/tasks/:id/runs) down through TaskApplication::handle_with_run /
TaskLaunchService::launch / EngineDispatcher (issue #13 run_id
propagation) so every step the dispatcher runs can be appended to
RunRecord.step_entries and the run’s id exposed to workers via
Ctx.meta.runtime["run_id"]. Kept as a distinct type — rather than a
new field on TaskApplicationInput — so the pre-existing exhaustive
struct literal in mlua-swarm-cli’s MCP adapter (TaskApplicationInput { .. }, no run_ctx) keeps compiling unchanged: callers that don’t
care about run tracing keep calling TaskApplication::handle /
TaskLaunchService::launch, which pass None through internally.
Fields§
§run_id: RunIdThe Run this dispatch’s steps should be traced into.
run_store: Arc<dyn RunStore>Where to append StepEntry rows as steps are dispatched.
replay_store: Option<Arc<dyn ReplayStore>>Optional ReplayStore the engine will append a Ctx-snapshot +
step-output row to after every completed step (see
crate::store::replay for the primitive). None (the default)
disables logging entirely — pre-replay callers keep their behavior
byte-for-byte.
replay_cursor: Option<Arc<Mutex<ReplayCursor>>>Optional ReplayCursor the engine consults BEFORE dispatching
each step. When present and the cursor has a matching row for
(step_ref, input_hash, occurrence), the engine returns the
stored DispatchOutcome::Pass(value) verbatim and skips the
Adapter spawn — this is the replay-hit path. None (the default)
disables replay entirely.
Implementations§
Source§impl RunContext
impl RunContext
Sourcepub fn new(run_id: RunId, run_store: Arc<dyn RunStore>) -> Self
pub fn new(run_id: RunId, run_store: Arc<dyn RunStore>) -> Self
Construct a RunContext with just the RunStore wired — the same
shape all pre-replay callers use (replay_store / replay_cursor
both None). Preserved as a convenience so a caller that never
opts into replay can keep constructing RunContext positionally.
Sourcepub fn with_replay_store(self, store: Arc<dyn ReplayStore>) -> Self
pub fn with_replay_store(self, store: Arc<dyn ReplayStore>) -> Self
Builder-style setter: attach a ReplayStore to log every
completed step’s Ctx snapshot + output into.
Sourcepub fn with_replay_cursor(self, cursor: Arc<Mutex<ReplayCursor>>) -> Self
pub fn with_replay_cursor(self, cursor: Arc<Mutex<ReplayCursor>>) -> Self
Builder-style setter: attach a ReplayCursor the dispatcher
consults for a hit before dispatching each step.
Trait Implementations§
Source§impl Clone for RunContext
impl Clone for RunContext
Source§fn clone(&self) -> RunContext
fn clone(&self) -> RunContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for RunContext
impl !UnwindSafe for RunContext
impl Freeze for RunContext
impl Send for RunContext
impl Sync for RunContext
impl Unpin for RunContext
impl UnsafeUnpin for RunContext
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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