Skip to main content

TriggerStore

Struct TriggerStore 

Source
pub struct TriggerStore { /* private fields */ }

Implementations§

Source§

impl TriggerStore

Source

pub fn default_root() -> Result<PathBuf>

Source

pub fn open(root: impl Into<PathBuf>) -> Result<Self>

Source

pub fn open_default() -> Result<Self>

Source

pub fn open_existing_default() -> Option<Self>

Open only if it already exists — for read paths that must not create state as a side effect.

Source

pub fn root(&self) -> &Path

Source

pub fn path_of(&self, name: &str) -> PathBuf

Source

pub fn ledger_path(&self) -> PathBuf

Source

pub fn list(&self) -> Result<(Vec<Trigger>, Vec<String>)>

Every trigger, by name.

An unreadable or invalid file is reported and skipped rather than failing the whole listing: one bad trigger must not stop the other three from firing.

Source

pub fn get(&self, name: &str) -> Result<Trigger>

Source

pub fn exists(&self, name: &str) -> bool

Source

pub fn save(&self, trigger: &Trigger) -> Result<()>

Source

pub fn remove(&self, name: &str) -> Result<()>

Source

pub fn append_run(&self, record: &RunRecord) -> Result<()>

Append one row. Held under the store lock so two ticks cannot interleave a line.

Source

pub fn runs(&self) -> Result<Vec<RunRecord>>

The ledger, oldest first. A torn or unparseable line is skipped: this is an audit trail, and one bad line must not hide the rest.

Source

pub fn scan_runs_rev(&self, visit: impl FnMut(RunRecord) -> bool) -> Result<()>

Visit ledger rows newest-first, stopping as soon as visit returns false — the tail read behind “what happened last”, for callers that need one recent row and must not deserialize an append-only file that only ever grows. Read once as bytes, not read_to_string: one invalid-UTF-8 byte in an old torn line would otherwise poison every future tail read of a file whose end is fine. An undecodable or unparseable line is skipped, the same audit-trail rule as runs: one bad line must not hide the rest.

Source

pub fn last_slots(&self) -> Result<BTreeMap<String, DateTime<Utc>>>

The most recent accounted-for slot per trigger — one ledger scan for the whole tick. Manual runs carry no slot and so are invisible here, which is the point.

Source

pub fn lock(&self) -> Result<StoreLock>

Writer lock for the ledger.

Source

pub fn try_claim(&self, name: &str) -> Result<Option<RunLock>>

Claim the right to run name, or None if a run of it is already in flight — in this process or any other.

Non-blocking on purpose: the answer “someone else is running it” is the useful one, and waiting for a twenty-minute briefing to finish so a second copy can start is never what anybody wanted.

Source

pub fn mark_running( &self, name: &str, slot: Option<DateTime<Utc>>, ) -> Result<()>

Announce that a run has started, for anything that wants to display whether one is in flight. See crate::runmarker for why this is not the flock.

Source

pub fn clear_running(&self, name: &str)

Clear the marker and any unclaimed cancel request.

Source

pub fn running(&self, name: &str) -> Option<RunMarker>

The run in flight, if there is one.

Source

pub fn request_cancel(&self, name: &str) -> Result<bool>

Ask the run in flight to stop. Returns false when there is nothing to stop, so a caller can say so rather than pretending.

Source

pub fn cancel_requested(&self, name: &str) -> bool

Has a cancel been requested for the run in flight?

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more