Skip to main content

Scheduler

Struct Scheduler 

Source
pub struct Scheduler { /* private fields */ }
Expand description

Concurrency-controlled agent scheduler. Held as Arc<Scheduler> and shared across orchestration coroutines.

Implementations§

Source§

impl Scheduler

Source

pub fn new( config: SchedulerConfig, registry: BackendRegistry, journal_callback: Option<Arc<dyn JournalCallback>>, ) -> Arc<Self>

Source

pub fn config(&self) -> &SchedulerConfig

Source

pub fn init_run( &self, run_id: RunId, event_capacity: usize, ) -> Receiver<AgentEvent>

Initialise per-run state. Must be called before any run_agent. Returns the broadcast receiver; further consumers use resubscribe().

Source

pub fn init_run_with(&self, run_id: RunId, events: EventSender)

Initialise per-run state using an externally-owned event sender.

This lets the orchestration layer share a single event bus between the scheduler (AgentStarted/AgentDone, plus the RunContext handed to backends) and the runtime SDK (phase/log/pipeline/RunDone).

Source

pub async fn run_agent( &self, run_id: RunId, task: AgentTask, backend_id: Option<&str>, ) -> Result<AgentResult, SchedulerError>

Schedule and run a single agent task: quota check → permit → retry loop → events. Cancellation flows via RunContext::cancel.

The agent span carries run_id/agent_id/phase_id/model so every log emitted on this task’s async path inherits them (see docs/design/program-logging.md).

Source

pub async fn run_parallel( &self, run_id: RunId, tasks: Vec<(AgentTask, Option<String>)>, ) -> Vec<Result<AgentResult, SchedulerError>>

Run a batch of tasks concurrently (the parallel() primitive). Bounded by the same global semaphore; does not short-circuit on failure — results preserve input order.

Source

pub fn cancel_agent(&self, run_id: RunId, agent_id: AgentId)

Cancel one agent (fires its token; the backend observes ctx.cancel).

Source

pub fn cancel_run(&self, run_id: RunId)

Cancel the whole run (all child agent tokens fire).

Source

pub fn active_concurrency(&self) -> usize

Current global active concurrency.

Source

pub fn quota_used(&self, run_id: RunId) -> Option<u32>

Quota consumed by a run, if initialised.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more