pub struct Observation {
pub schema: String,
pub deployment: String,
pub url: String,
pub expected: String,
pub served: Option<BuildIdentity>,
pub judgement: Judgement,
pub at: String,
}Expand description
One observation of one deployment, as recorded: what was asked, what was served, what
was judged and when. Everything needed to judge it again later is in the record, which
is what lets Observation::rejudge answer without probing.
use majordomus_cli::served::{observe, Fetch, Fetched, GitAncestry, Observation, OBSERVATION_SCHEMA};
use std::{path::Path, time::SystemTime};
struct None_;
impl Fetch for None_ {
fn fetch(&self, _: &str) -> Fetched { Fetched::Unreachable("no route".into()) }
}
let git = GitAncestry { root: Path::new(env!("CARGO_MANIFEST_DIR")) };
let o: Observation = observe("pages", "https://s", "build.json", &"a".repeat(40), &None_,
&git, SystemTime::UNIX_EPOCH);
assert_eq!(o.schema, OBSERVATION_SCHEMA);
assert_eq!(o.url, "https://s/build.json");
assert_eq!(o.at, "1970-01-01T00:00:00Z");Fields§
§schema: StringAlways OBSERVATION_SCHEMA.
deployment: StringWhich deployment: the name the caller observed it under (pages, or a deployment
object’s id).
url: StringThe identity URL probed.
expected: StringThe commit that was expected, full.
served: Option<BuildIdentity>What was served, when a build identity was received.
judgement: JudgementThe judgement at the time of the observation.
at: StringWhen, RFC 3339 UTC.
Implementations§
Source§impl Observation
impl Observation
Sourcepub fn rejudge(&self, expected: &str, git: &dyn Ancestry) -> Judgement
pub fn rejudge(&self, expected: &str, git: &dyn Ancestry) -> Judgement
Re-judges this record against expected now. A served commit keeps proving what it
contains; a record that received nothing keeps proving nothing. This is where a
proof goes stale: nothing about the record changes, the commit asked about does.
use majordomus_cli::served::{observe, Ancestry, Fetch, Fetched, ServedVerdict};
use std::time::SystemTime;
struct Linear; // a <- b
impl Ancestry for Linear {
fn has(&self, c: &str) -> Option<bool> { Some(c.starts_with('a') || c.starts_with('b')) }
fn contains(&self, d: &str, a: &str) -> Option<bool> { Some(d >= a) }
}
let (a, b) = ("a".repeat(40), "b".repeat(40));
struct ServesA(String);
impl Fetch for ServesA {
fn fetch(&self, _: &str) -> Fetched {
Fetched::Body(format!(r#"{{"commit":"{}","dirty":false}}"#, self.0).into_bytes())
}
}
let o = observe("pages", "https://s", "build.json", &a, &ServesA(a.clone()), &Linear,
SystemTime::UNIX_EPOCH);
assert_eq!(o.judgement.verdict, ServedVerdict::Served);
// the same record, asked about a commit the served build does not contain
assert_eq!(o.rejudge(&b, &Linear).verdict, ServedVerdict::Stale);Trait Implementations§
Source§impl Clone for Observation
impl Clone for Observation
Source§fn clone(&self) -> Observation
fn clone(&self) -> Observation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Observation
impl Debug for Observation
Source§impl<'de> Deserialize<'de> for Observation
impl<'de> Deserialize<'de> for Observation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Observation
Source§impl JsonSchema for Observation
impl JsonSchema for Observation
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for Observation
impl PartialEq for Observation
Source§fn eq(&self, other: &Observation) -> bool
fn eq(&self, other: &Observation) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for Observation
impl Serialize for Observation
impl StructuralPartialEq for Observation
Auto Trait Implementations§
impl Freeze for Observation
impl RefUnwindSafe for Observation
impl Send for Observation
impl Sync for Observation
impl Unpin for Observation
impl UnsafeUnpin for Observation
impl UnwindSafe for Observation
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.