pub struct JobRegistry { /* private fields */ }Expand description
Map of in-flight jobs, keyed by JobId.
Cheap to clone; internally Arc<DashMap<JobId, _>>. The runtime’s
dispatcher stores the spawned task’s JoinHandle here so the runtime
can issue a hard kill (Phase 4+ surface) and cancellation can be
driven from outside the task.
Implementations§
Source§impl JobRegistry
impl JobRegistry
Sourcepub fn insert(&self, entry: JobEntry, join: JoinHandle<()>)
pub fn insert(&self, entry: JobEntry, join: JoinHandle<()>)
Insert a new job; the registry takes ownership of the
JoinHandle so it can be aborted (Phase 4+).
Sourcepub fn cancel(&self, job_id: &JobId) -> bool
pub fn cancel(&self, job_id: &JobId) -> bool
Trigger cooperative cancellation for job_id. Returns true if
the job was found and the token was triggered.
Sourcepub fn sweep_terminals(&self)
pub fn sweep_terminals(&self)
Drop terminal jobs from the registry. Should be called periodically (Phase 5+) to cap memory.
Sourcepub fn list_for_session(
&self,
session_id: &SessionId,
filter: Option<&SessionListJobsFilter>,
) -> Vec<JobListEntry>
pub fn list_for_session( &self, session_id: &SessionId, filter: Option<&SessionListJobsFilter>, ) -> Vec<JobListEntry>
Snapshot of all jobs scoped to session_id, applying an optional
filter (ARCP v1.1 §6.6). Results are sorted by created_at
ascending so pagination cursors are stable.
Sourcepub fn bump_event_seq(&self, job_id: &JobId) -> Option<u64>
pub fn bump_event_seq(&self, job_id: &JobId) -> Option<u64>
Increment and return the new last_event_seq for job_id.
Returns None if the job is not registered.
Sourcepub fn record_event_seq(&self, job_id: &JobId, seq: u64)
pub fn record_event_seq(&self, job_id: &JobId, seq: u64)
Record the session-scoped sequence number of the most recent
event the runtime emitted for job_id. Used by the connection
writer to keep JobRegistry’s high-water mark in lockstep with
the session sequence so job.subscribed.subscribed_from reflects
what the subscriber can actually ack from.
Sourcepub fn snapshot(&self, job_id: &JobId) -> Option<JobSnapshot>
pub fn snapshot(&self, job_id: &JobId) -> Option<JobSnapshot>
Snapshot the public-facing fields of a job, if registered.
Used by job.subscribe (ARCP v1.1 §7.6) to populate the
acknowledgement.
Trait Implementations§
Source§impl Clone for JobRegistry
impl Clone for JobRegistry
Source§fn clone(&self) -> JobRegistry
fn clone(&self) -> JobRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more