Skip to main content

LastGoodPolicies

Struct LastGoodPolicies 

Source
pub struct LastGoodPolicies {
    good: Mutex<HashMap<String, Good>>,
}
Expand description

The operator source’s last-good-revision state. Empty and legitimate at startup – nothing has compiled yet, which is the “never compiled” state every id starts in, not an error.

Held by whoever repeatedly rebuilds the tree from a fresh view of the operator’s records, the same way that view itself is held – long-lived, across many crate::merge::build calls, never reconstructed per rebuild, or there would be nothing to fall back to.

Fields§

§good: Mutex<HashMap<String, Good>>

Implementations§

Source§

impl LastGoodPolicies

Source

pub fn new() -> Self

No id has a last-good revision yet.

Source

pub(crate) fn get(&self, id: &str) -> Option<(Revision, ParsedPolicy)>

The last successfully-compiled ParsedPolicy for id, and the revision it was observed at, if this id has ever compiled.

Source

pub(crate) fn record_success(&self, id: &str, policy: &ParsedPolicy)

Record that policy (at id) compiled successfully at its own revision – the new last-good, replacing whatever was stored before.

Source

pub(crate) fn prune(&self, current: &HashMap<String, ParsedPolicy>)

Drop every id not present in current – a record the current view no longer holds at all (deleted, or never re-observed after a source outage recovered onto a view that no longer names it) has nothing left to fall back to, and keeping it here would let a stale policy affect a future id that happens to reuse the same at-uri. Called once per rebuild, after every id in current has had a chance to update its own entry via record_success.

Trait Implementations§

Source§

impl Default for LastGoodPolicies

Source§

fn default() -> LastGoodPolicies

Returns the “default value” for a type. Read more

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.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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