pub struct Fake {
pub world: Arc<Mutex<World>>,
pub store: MemStore,
}Expand description
The handle every backend trait is implemented on. Cheap to clone; all clones share one world and one journal store.
Fields§
§world: Arc<Mutex<World>>§store: MemStoreImplementations§
Source§impl Fake
impl Fake
Sourcepub fn footprint_view(&self, tools: &[UnitId]) -> FootprintView
pub fn footprint_view(&self, tools: &[UnitId]) -> FootprintView
§12d: the footprints as /run/planarian/footprint/ would hold them
for the network tools tools, on the boot clock (seconds): the same
planarian_backend_netwatch::FootprintView the Linux side reads.
pub fn new(world: World, store: MemStore) -> Fake
pub fn w(&self) -> MutexGuard<'_, World>
Sourcepub(crate) fn hung(
&self,
verb: &str,
unit: &UnitId,
wait: Millis,
) -> Option<Outcome>
pub(crate) fn hung( &self, verb: &str, unit: &UnitId, wait: Millis, ) -> Option<Outcome>
hold_hangs: a hold call (systemctl start/stop, nft) that
takes that long. Past wait the client gives up (Unknown, the
fake clock advanced by wait) and nothing lands; within it, the
call takes its time and goes on.
pub fn advance(&self, d: Millis)
pub(crate) fn admit(&self, w: &mut World, op: &OpId, call: String) -> bool
Sourcepub(crate) fn run(
&self,
op: &OpId,
call: String,
f: impl FnOnce(&mut World) -> Outcome,
) -> Outcome
pub(crate) fn run( &self, op: &OpId, call: String, f: impl FnOnce(&mut World) -> Outcome, ) -> Outcome
One mutating backend call: fenced on a stale epoch before any effect
(docs/assumptions.md), and subject to an injected outcome
(World::inject, keyed by the call’s name before its parenthesis).
Trait Implementations§
Source§impl Backends for Fake
impl Backends for Fake
type Units = Fake
type Inv = Fake
type Probes = Fake
type Sessions = Fake
type Runtime = Fake
type Procs = Fake
type Clock = Fake
fn units(&self) -> &Fake
fn generations(&self) -> &Fake
fn inventory(&self) -> &Fake
fn probes(&self) -> &Fake
fn sessions(&self) -> &Fake
fn runtime(&self) -> &Fake
fn processes(&self) -> &Fake
fn clock(&self) -> &Fake
Source§impl Clock for Fake
impl Clock for Fake
Source§fn now(&self) -> Timestamp
fn now(&self) -> Timestamp
The world’s now is elapsed time (boot time); the wall clock is it
plus wall_skew, which only set_wall_clock moves (§12h).
Source§fn boot_now(&self) -> Timestamp
fn boot_now(&self) -> Timestamp
CLOCK_BOOTTIME: for everything that does not survive
a reboot (approval tokens, leases, cooldowns, windows; §12h). Moving
the wall clock never moves it.fn sleep(&self, d: Millis)
Source§impl GenerationBackend for Fake
impl GenerationBackend for Fake
fn current(&self) -> Result<GenerationId, Outcome>
fn boot_entries(&self) -> Result<Vec<GenerationId>, Outcome>
fn boot_default(&self) -> Result<GenerationId, Outcome>
fn last_booted(&self) -> Result<GenerationId, Outcome>
Source§fn created_by(&self, g: GenerationId) -> Option<(u32, Timestamp)>
fn created_by(&self, g: GenerationId) -> Option<(u32, Timestamp)>
g and when (its profile link’s owner and
time): the provenance of a rebuild made outside Planarian (§15).fn stage( &self, _owner: &PinnedSource, overrides: &OverrideSet, ) -> Result<StagedSource, Outcome>
Source§fn source_hash(&self, _owner: &PinnedSource) -> Result<Hash, Outcome>
fn source_hash(&self, _owner: &PinnedSource) -> Result<Hash, Outcome>
Source§fn untracked(&self, _owner: &PinnedSource) -> Vec<String>
fn untracked(&self, _owner: &PinnedSource) -> Vec<String>
fn evaluate(&self, src: &StagedSource) -> Result<EvaluatedGeneration, Outcome>
Source§fn build(&self, eval: &EvaluatedGeneration) -> Result<Built, Outcome>
fn build(&self, eval: &EvaluatedGeneration) -> Result<Built, Outcome>
Source§fn dry_activation(&self, path: &StorePath) -> Result<ActivationPlan, Outcome>
fn dry_activation(&self, path: &StorePath) -> Result<ActivationPlan, Outcome>
Source§fn override_content(&self, h: &Hash) -> Result<OverrideSet, Outcome>
fn override_content(&self, h: &Hash) -> Result<OverrideSet, Outcome>
remember_override kept under this hash.Source§fn verify_candidate(
&self,
path: &StorePath,
nar: Option<&Hash>,
) -> Result<bool, Outcome>
fn verify_candidate( &self, path: &StorePath, nar: Option<&Hash>, ) -> Result<bool, Outcome>
nar is given (the transaction built it), that is
the NAR hash recorded at build (§9 step 3, C6).fn pending_jobs(&self) -> Result<Vec<JobId>, Outcome>
Source§fn jobs_tagged(&self, op: &OpId) -> Result<Option<Vec<JobId>>, Outcome>
fn jobs_tagged(&self, op: &OpId) -> Result<Option<Vec<JobId>>, Outcome>
None: the backend cannot say whether work tagged with op exists.Source§fn override_hash(&self) -> Result<Hash, Outcome>
fn override_hash(&self) -> Result<Hash, Outcome>
Source§fn activate_live(&self, g: GenerationId, op: &OpId) -> Outcome
fn activate_live(&self, g: GenerationId, op: &OpId) -> Outcome
switch-to-configuration test.Source§fn publish_boot(&self, g: GenerationId, op: &OpId) -> Outcome
fn publish_boot(&self, g: GenerationId, op: &OpId) -> Outcome
Source§fn publish_boot_once(
&self,
g: GenerationId,
keep: GenerationId,
op: &OpId,
) -> Outcome
fn publish_boot_once( &self, g: GenerationId, keep: GenerationId, op: &OpId, ) -> Outcome
g boots once, at the next
boot; keep stays the default. All or nothing.Source§fn one_shot_pending(&self) -> Result<Option<GenerationId>, Outcome>
fn one_shot_pending(&self) -> Result<Option<GenerationId>, Outcome>
fn protect(&self, g: GenerationId, op: &OpId) -> Outcome
fn cancel(&self, job: &JobId, op: &OpId) -> Outcome
Source§fn swap_override(&self, from: &Hash, to: &Hash, op: &OpId) -> Outcome
fn swap_override(&self, from: &Hash, to: &Hash, op: &OpId) -> Outcome
to, but only if its current hash is from. Idempotent: if it already
hashes to to, succeed without writing.Source§fn path_of(&self, g: GenerationId) -> Result<StorePath, Outcome>
fn path_of(&self, g: GenerationId) -> Result<StorePath, Outcome>
Source§fn evaluate_built(
&self,
path: &StorePath,
) -> Result<EvaluatedGeneration, Outcome>
fn evaluate_built( &self, path: &StorePath, ) -> Result<EvaluatedGeneration, Outcome>
Source§fn read_overrides(&self) -> Result<(OverrideSet, Hash), Outcome>
fn read_overrides(&self) -> Result<(OverrideSet, Hash), Outcome>
Source§fn remember_override(&self, set: &OverrideSet) -> Result<Hash, Outcome>
fn remember_override(&self, set: &OverrideSet) -> Result<Hash, Outcome>
swap_override can write it.Source§fn override_for(&self, g: GenerationId) -> Result<Option<Hash>, Outcome>
fn override_for(&self, g: GenerationId) -> Result<Option<Hash>, Outcome>
fn record_override(&self, g: GenerationId, hash: &Hash) -> Result<(), Outcome>
Source§fn release_root(&self, root: &str) -> bool
fn release_root(&self, root: &str) -> bool
Source§fn collect_garbage(
&self,
protect: &[GenerationId],
emergency: bool,
op: &OpId,
) -> Outcome
fn collect_garbage( &self, protect: &[GenerationId], emergency: bool, op: &OpId, ) -> Outcome
gc::plan), never touching
protect (I3), then collect store garbage. Mutating.Source§fn gc_plan(
&self,
protect: &[GenerationId],
emergency: bool,
) -> Result<GcPlan, Outcome>
fn gc_plan( &self, protect: &[GenerationId], emergency: bool, ) -> Result<GcPlan, Outcome>
collect_garbage would delete now. Read-only.Source§fn space_report(&self) -> Option<SpaceReport>
fn space_report(&self) -> Option<SpaceReport>
Source§fn age_out_build_roots(&self) -> Vec<String>
fn age_out_build_roots(&self) -> Vec<String>
Source§impl InventoryBackend for Fake
impl InventoryBackend for Fake
fn devices(&self) -> Result<Vec<DeviceInfo>, Outcome>
fn resources(&self) -> Result<Resources, Outcome>
fn bound_driver(&self, device: &UnitId) -> Result<Option<DriverRef>, Outcome>
fn bind(&self, device: &UnitId, driver: &DriverRef, op: &OpId) -> Outcome
fn unbind(&self, device: &UnitId, op: &OpId) -> Outcome
Source§impl ProbeBackend for Fake
impl ProbeBackend for Fake
Source§impl ProcessBackend for Fake
impl ProcessBackend for Fake
Source§impl RuntimeOptionBackend for Fake
impl RuntimeOptionBackend for Fake
Source§impl SessionBackend for Fake
impl SessionBackend for Fake
fn sessions(&self) -> Result<Vec<SessionInfo>, Outcome>
Source§fn compositor_running(&self, s: &SessionInfo) -> Option<bool>
fn compositor_running(&self, s: &SessionInfo) -> Option<bool>
Source§fn foreground(&self) -> Vec<String>
fn foreground(&self) -> Vec<String>
Condition::Foreground.fn power(&self) -> Option<PowerSource>
Source§impl UnitBackend for Fake
impl UnitBackend for Fake
Source§fn protecting(&self, tools: &[UnitId]) -> Result<BTreeSet<UnitId>, Outcome>
fn protecting(&self, tools: &[UnitId]) -> Result<BTreeSet<UnitId>, Outcome>
§12d: the scripted footprints (footprint_view), read as the Linux
side reads the files.
fn observe(&self, id: &UnitId) -> Result<Observed, Outcome>
Source§fn ended_by(&self, id: &UnitId) -> Option<Ending>
fn ended_by(&self, id: &UnitId) -> Option<Ending>
Source§fn auto_restarts(&self, id: &UnitId) -> Option<u32>
fn auto_restarts(&self, id: &UnitId) -> Option<u32>
NRestarts); None
if the backend cannot say.Source§fn foreign_units(&self) -> Vec<String>
fn foreign_units(&self) -> Vec<String>
fn list(&self) -> Result<Vec<UnitId>, Outcome>
Source§fn start_agent(
&self,
name: &str,
_argv: &[String],
_limits: &AgentLimits,
) -> Result<InstanceId, Outcome>
fn start_agent( &self, name: &str, _argv: &[String], _limits: &AgentLimits, ) -> Result<InstanceId, Outcome>
planarian-agent-<name>,
under a dynamic uid of its own. Returns the started unit’s instance
(its InvocationID), read back once it has started (I24).Source§fn agent_running(&self, name: &str) -> bool
fn agent_running(&self, name: &str) -> bool
agent run refuses a name in use).Source§fn hold(&self, unit: &UnitId, wait: Millis) -> Outcome
fn hold(&self, unit: &UnitId, wait: Millis) -> Outcome
planarian-hold@<unit>). A failure
posture response, not a transition: no Prepared, no lease (it only
ever restricts traffic; docs/bypasses.md). Idempotent. Unlike the
other mutations here it takes no OpId; the daemon journals
HoldApplied before calling it. Read moreSource§fn lift_hold(&self, unit: &UnitId, wait: Millis) -> Outcome
fn lift_hold(&self, unit: &UnitId, wait: Millis) -> Outcome
HoldLifted first). Idempotent. At most wait.Source§fn held(&self) -> Result<BTreeSet<UnitId>, Outcome>
fn held(&self) -> Result<BTreeSet<UnitId>, Outcome>
Source§fn release_hold(
&self,
unit: &UnitId,
until: Option<Timestamp>,
wait: Millis,
) -> Outcome
fn release_hold( &self, unit: &UnitId, until: Option<Timestamp>, wait: Millis, ) -> Outcome
planarian hold release (an attested Override, decided before this):
mark the unit’s hold released until until (None: the next boot),
then lift it, waiting at most wait. While the mark stands, a new
failure does not hold.Source§fn end_release(&self, unit: &UnitId) -> Outcome
fn end_release(&self, unit: &UnitId) -> Outcome
Source§fn hold_table_present(&self, wait: Millis) -> Result<bool, Outcome>
fn hold_table_present(&self, wait: Millis) -> Result<bool, Outcome>
nft flush ruleset) removes it and would fail
open; the daemon checks this while a hold is active. An error means
“cannot say” (also past wait).Source§fn reapply_hold(&self, unit: &UnitId, wait: Millis) -> Outcome
fn reapply_hold(&self, unit: &UnitId, wait: Millis) -> Outcome
wait.