pub struct DaemonState {
pub queue: Mutex<VecDeque<QueuedJob>>,
pub active: Mutex<Option<RunningJob>>,
pub recent: Mutex<RingBuffer<JobRecord>>,
pub replay: Mutex<ReplayBuffer>,
pub events: Sender<Event>,
pub next_job_id: AtomicU64,
pub accepting: CancellationToken,
pub shutdown: CancellationToken,
pub started_at: u64,
pub daemon_pid: u32,
pub account: Option<String>,
pub queue_notify: Notify,
}Fields§
§queue: Mutex<VecDeque<QueuedJob>>§active: Mutex<Option<RunningJob>>§recent: Mutex<RingBuffer<JobRecord>>§replay: Mutex<ReplayBuffer>Per-job event history for attach <id> to a finished job. The
collector task (spawned in serve_resumed) populates this from
the broadcast channel; the Attach handler dumps it before
EndOfStream. Bounded per-job and across jobs so a runaway
process can’t OOM the daemon.
events: Sender<Event>§next_job_id: AtomicU64§accepting: CancellationTokenSet when Stop is received. The accept loop and worker_loop check this to refuse new jobs and exit when idle. Active connections keep streaming until their job completes.
shutdown: CancellationTokenSet for a hard stop (force=true) or when the queue drains after a graceful stop. Signals all subscribers and the accept loop to exit.
started_at: u64§daemon_pid: u32§account: Option<String>§queue_notify: NotifyImplementations§
Source§impl DaemonState
impl DaemonState
pub fn new( account: Option<String>, daemon_pid: u32, started_at: u64, ) -> Arc<Self>
pub fn allocate_job_id(&self) -> JobId
Sourcepub async fn enqueue(&self, job: QueuedJob) -> u32
pub async fn enqueue(&self, job: QueuedJob) -> u32
Insert a job. Priority items sit at the boundary between existing priority items and non-priority items; non-priority items append. Returns the queue position the caller should report: 0 if it will run next (queue empty and no active), 1+ otherwise. The “active” job is NOT counted because it is already running.
pub async fn toggle_priority(&self, job_id: JobId) -> Result<(), JobNotFound>
pub async fn cancel(&self, job_id: JobId) -> Result<(), JobNotFound>
pub async fn snapshot(&self) -> StatusSnapshot
Sourcepub async fn broadcast_snapshot(&self)
pub async fn broadcast_snapshot(&self)
Snapshot + broadcast on the events channel. Called whenever the queue, active job, or recent ring changes so Subscribe stream clients (the TUI, daemon status) refresh without re-polling.
Sourcepub async fn recent_exit_code(&self, job_id: JobId) -> Option<i32>
pub async fn recent_exit_code(&self, job_id: JobId) -> Option<i32>
Look up a recently-finished job by id. Used by stream_events to
recover the terminal exit code after a broadcast lag.
Auto Trait Implementations§
impl !Freeze for DaemonState
impl !RefUnwindSafe for DaemonState
impl !UnwindSafe for DaemonState
impl Send for DaemonState
impl Sync for DaemonState
impl Unpin for DaemonState
impl UnsafeUnpin for DaemonState
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> 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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.