pub struct DaemonState {Show 17 fields
pub host: Arc<EngineHost>,
pub paths: DaemonPaths,
pub profile: Option<String>,
pub started: Instant,
pub factory: SessionFactory,
pub connections: AtomicUsize,
pub shutdown: CancellationToken,
pub force_shutdown: AtomicBool,
pub generation: u64,
pub reloading: AtomicBool,
pub reload_generation: AtomicU64,
pub reload_announce: Mutex<CancellationToken>,
pub lock_fd: Mutex<Option<DaemonLock>>,
pub reload_aliases: Mutex<HashMap<String, String>>,
pub meta: Metadata,
pub pins: Arc<PinBook>,
pub restoring: AtomicBool,
}Expand description
Shared by the accept loop and every connection.
Fields§
§host: Arc<EngineHost>§paths: DaemonPaths§profile: Option<String>§started: Instant§factory: SessionFactory§connections: AtomicUsize§shutdown: CancellationToken§force_shutdown: AtomicBool§generation: u64Reload counter (Welcome.generation; starts at 1).
reloading: AtomicBoolDrain: refuse Attach::Create / new turns while set.
reload_generation: AtomicU64Generation announced in Reloading/Bye{Reloading}.
reload_announce: Mutex<CancellationToken>Cancelled once per reload attempt: every conn sends Reloading +
Bye. Replaced with a fresh token when the exec fails (M4) so the
surviving image accepts connections again — read via announce().
lock_fd: Mutex<Option<DaemonLock>>The flock, held here (not on Daemon) so reload can hand its fd
to the next image.
reload_aliases: Mutex<HashMap<String, String>>old id → new id for one generation (ids differ only if a
LinkedSuccessor compaction happened since boot).
meta: MetadataThe daemon.json record this image wrote, and its writes. A Ping
that finds the file missing or naming another pid puts it back
(Self::heal_daemon_json); reload takes its recorded exe from here.
pins: Arc<PinBook>The pin book: pinned journals that come back on the next cold start.
restoring: AtomicBoolA cold start’s pin restore is running (holds the idle exit).
Implementations§
Source§impl DaemonState
impl DaemonState
pub fn uptime_s(&self) -> u64
Sourcepub fn announce(&self) -> CancellationToken
pub fn announce(&self) -> CancellationToken
The current reload-announce token (clone; select on .cancelled()).
Sourcepub fn fire_announce(&self)
pub fn fire_announce(&self)
Fire the announce (every conn says Reloading + Bye).
Sourcepub fn reset_announce(&self)
pub fn reset_announce(&self)
Exec failed: arm a fresh token so new connections are served again.
Sourcepub fn daemon_info(&self) -> DaemonInfo
pub fn daemon_info(&self) -> DaemonInfo
The daemon.json record this image holds (a copy).
Sourcepub fn heal_daemon_json(&self)
pub fn heal_daemon_json(&self)
Ping: if daemon.json is missing or names another pid, write this
image’s record back. Only while this image holds the flock and has
not begun to shut down; the record comes from memory, never from
disk. One INFO line per [JSON_HEAL_LOG_EVERY].
The shutdown check runs under the lock_fd mutex: Daemon::wait
cancels shutdown before it takes that mutex to unlink the files, so
a Ping still in flight at shutdown can’t write the file back after
the unlink. During a reload’s hand-off the record already names the
new generation and exe, so a heal there writes what the reload wrote.
Sourcepub fn live_sessions(&self) -> Vec<SessionHandle>
pub fn live_sessions(&self) -> Vec<SessionHandle>
B4: ONE session map — EngineHost owns it; these delegate.
Sourcepub fn session_metas(&self) -> Vec<SessionMeta>
pub fn session_metas(&self) -> Vec<SessionMeta>
Listing metas with lifecycle / clients / input_owner / journal_id
(B4: EngineHost::sessions() fills the handle cells).
Sourcepub fn attach(&self, id: &SessionId) -> Option<SessionHandle>
pub fn attach(&self, id: &SessionId) -> Option<SessionHandle>
Live handle by id; falls back to the C3 reload alias
(old id → new id, set when a LinkedSuccessor compaction happened
since boot) so clients reconnecting after daemon reload find
their session under the id they last saw.
pub fn insert(&self, handle: SessionHandle)
pub fn remove(&self, id: &SessionId)
pub async fn create(&self, cfg: SessionConfig) -> Result<SessionHandle, String>
Sourcepub async fn retry_locked_placeholder(
&self,
placeholder: SessionHandle,
) -> SessionHandle
pub async fn retry_locked_placeholder( &self, placeholder: SessionHandle, ) -> SessionHandle
F23: a lock-held placeholder (meta.locked_by.is_some()) is retried on
every attach. Pull it out of the map first — otherwise the host’s
attach-if-live short-circuit hands the placeholder straight back —
and re-run the real create from the journal. Success replaces the
placeholder under the same id; still-held puts it back and the caller
attaches to it (→ AttachRefused naming the holder).
pub fn request_shutdown(&self, force: bool)
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> 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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.