pub struct DaemonState {
pub config: DaemonConfig,
pub audit: Arc<dyn AuditStore>,
pub policy: PolicyTable,
pub host_distro: Option<DistroId>,
pub forwarder: Option<AuditForwarder>,
pub running_high_risk_reboot: Arc<Mutex<Option<String>>>,
}Fields§
§config: DaemonConfig§audit: Arc<dyn AuditStore>Polymorphic audit store. Concrete impls: SqliteStore (default) and
PostgresStore (selected via [storage] backend = "postgres").
Both implement AuditStore async trait.
policy: PolicyTable§host_distro: Option<DistroId>Strict host identity used to enforce the documented support matrix at preview and execution boundaries.
forwarder: Option<AuditForwarder>Optional external audit-log forwarder. None when no [audit.forward]
sink is configured; events recorded by the dispatcher are then only
written to the local hash-chained store.
running_high_risk_reboot: Arc<Mutex<Option<String>>>Coarse concurrency guard for High-risk reboot-required actions (ME4).
Holds the request_hash of any currently executing action whose
ActionSpec has risk_level == High && reboot_required == true (e.g.
UbuntuReleaseUpgrade, AddLayeredPackage, RebaseSystem). None
when no such action is in flight.
The guard is one-directional, not mutual exclusion between all
mutating actions: every mutating action checks this slot before it is
allowed to start, but only a High-risk + reboot-required action ever
claims it (sets it to Some). So while a High-risk +
reboot-required action is in flight, every other mutating action —
including another High-risk + reboot-required one — is rejected with
a ConflictResponse rather than racing the in-flight upgrade and
causing dpkg/rpm-ostree lock contention. An ordinary mutating action
(e.g. StartService) never claims the slot itself, so it neither
blocks other ordinary mutating actions nor blocks a High-risk +
reboot-required action that starts while it is still running.
The slot is Arc<Mutex<…>> so cloned DaemonState values — one per
IPC connection — all share the same underlying guard. Mutex::lock
is held for at most a few microseconds; this does not become a
hot-path bottleneck because read-only actions skip the check entirely.
On daemon crash the in-memory guard is lost. That is correct: the
daemon’s SQLite store will show the orphaned Running row; the
operator can inspect it via ListJobHistory.
Implementations§
Source§impl DaemonState
impl DaemonState
Sourcepub fn open(config: DaemonConfig) -> Result<Self, DaemonStateError>
pub fn open(config: DaemonConfig) -> Result<Self, DaemonStateError>
Open the daemon state with no policy overrides and no forwarding. Suitable for tests and dev runs.
Sourcepub fn open_with_policy(
config: DaemonConfig,
policy: PolicyTable,
) -> Result<Self, DaemonStateError>
pub fn open_with_policy( config: DaemonConfig, policy: PolicyTable, ) -> Result<Self, DaemonStateError>
Open the daemon state with an explicit policy table and no forwarding.
Sourcepub fn open_full(
config: DaemonConfig,
policy: PolicyTable,
forwarder: Option<AuditForwarder>,
) -> Result<Self, DaemonStateError>
pub fn open_full( config: DaemonConfig, policy: PolicyTable, forwarder: Option<AuditForwarder>, ) -> Result<Self, DaemonStateError>
Open the daemon state with full configuration. Production callers
(main.rs) build the policy table from [policy.risk_overrides] and
the forwarder from [audit.forward]. The audit store defaults to
SQLite at config.database_path; pass an explicit audit to use
Postgres or any other AuditStore impl.
Sourcepub fn open_with_audit(
config: DaemonConfig,
policy: PolicyTable,
forwarder: Option<AuditForwarder>,
audit: Arc<dyn AuditStore>,
) -> Self
pub fn open_with_audit( config: DaemonConfig, policy: PolicyTable, forwarder: Option<AuditForwarder>, audit: Arc<dyn AuditStore>, ) -> Self
Open the daemon state with an explicit audit store. Used by main.rs
when [storage] backend = "postgres" is configured: the Postgres
AuditStore is constructed via PostgresStore::connect and passed
here as the audit argument.
pub fn bootstrap( config: DaemonConfig, ) -> Result<DaemonRuntime, DaemonStateError>
Trait Implementations§
Source§impl Clone for DaemonState
impl Clone for DaemonState
Source§fn clone(&self) -> DaemonState
fn clone(&self) -> DaemonState
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 DaemonState
impl !UnwindSafe for DaemonState
impl Freeze 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> 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