pub enum WritePolicy {
OnboardFirst,
CardFirst,
}Expand description
Where new samples land.
Chosen at construction with no default, because the right answer depends on what the deployment values and both answers are defensible.
Variants§
OnboardFirst
Always append to the onboard log; copy to the volume in the background.
The write path never depends on the volume being present, so a removal at any instant — clean or not — cannot lose a sample. Costs onboard write endurance and space, since every sample is written twice.
CardFirst
Append directly to the volume once the backlog is drained.
Spares the onboard log both space and wear while the volume is present: samples bypass it entirely, so it is written only while the volume is out. A removal at any instant still loses nothing — whatever the volume held in RAM is rescued into the onboard log, because a yank leaves the processor running.
Two costs to weigh against that:
- A power cut is not a yank. It takes the processor too, so samples
buffered on the volume and not yet
synced are gone. That window is one page — the same as any un-synced write — but underOnboardFirstthose samples would have been onboard already. - There is only one copy. Under
OnboardFirsta sample exists in both logs until the onboard ring reclaims it. Here, once a sample is on the volume it is only there, so the volume filling up and wrapping is real loss rather than the loss of a redundant copy. Size the volume for the collection interval, and swap it before it wraps —TieredDb::volume_fillis the signal that says when that is due.
One more thing to know about this mode: appends land on the volume, so a
sector rotation there — 100 ms or more on many NOR parts — lands on the
append path rather than on replication. Sample
SensorDb::sectors_erased on the
volume to see them.
Trait Implementations§
Source§impl Clone for WritePolicy
impl Clone for WritePolicy
impl Copy for WritePolicy
Source§impl Debug for WritePolicy
impl Debug for WritePolicy
impl Eq for WritePolicy
Source§impl Format for WritePolicy
Available on crate feature defmt only.
impl Format for WritePolicy
defmt only.