pub struct HandoverView {
pub id: String,
pub stream: StreamId,
pub runtime: String,
pub published_lamport: u64,
pub handover: HandoverBody,
pub consumed_by: Vec<String>,
}Expand description
A handover anywhere in the mesh, with everyone who has taken it. The id is the digest
of the body, so the same handover published twice — by a retry, or by two runtimes that
both saw it — is one handover here; and consumed_by is what keeps two workers from
silently picking up the same continuity, since the list is folded from events every
runtime holds.
use std::sync::Arc;
use majordomus_cli::mesh::identity::NodeIdentity;
use majordomus_cli::mesh::journal::{EventBody, HandoverBody, Journal, StreamLiveness};
use majordomus_cli::mesh::state::{fold, HandoverView};
let j = Journal::open(Arc::new(NodeIdentity::ephemeral().unwrap()), "0000000000000001",
"repo".into(), None).unwrap();
let body = "# Objective\nship\n".to_string();
let handover = HandoverBody { id: HandoverBody::digest_of(&body), task: None, issue: None,
milestone: None, branch: Some("feature/x".into()), head: None, created_at: None,
name: None, body };
let id = handover.id.clone();
j.append_own(EventBody::HandoverPublished { handover }).unwrap();
j.append_own(EventBody::HandoverConsumed { handover: id.clone(), session: "s1".into() })
.unwrap();
let state = fold(&j.events(), &|_| StreamLiveness::Own);
let view: &HandoverView = &state.handovers[0];
assert_eq!(view.id, id, "identified by what it says, not by who said it");
assert_eq!(view.consumed_by.len(), 1, "somebody has picked this one up");Fields§
§id: StringThe content digest.
stream: StreamIdThe stream that first published it.
runtime: String<node>-<runtime> of the publisher.
published_lamport: u64The Lamport stamp of the first publication.
handover: HandoverBodyThe record’s facts and body.
consumed_by: Vec<String>Every session that consumed it, by key, in Lamport order.
Trait Implementations§
Source§impl Clone for HandoverView
impl Clone for HandoverView
Source§fn clone(&self) -> HandoverView
fn clone(&self) -> HandoverView
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HandoverView
impl Debug for HandoverView
Source§impl<'de> Deserialize<'de> for HandoverView
impl<'de> Deserialize<'de> for HandoverView
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for HandoverView
Source§impl JsonSchema for HandoverView
impl JsonSchema for HandoverView
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl PartialEq for HandoverView
impl PartialEq for HandoverView
Source§fn eq(&self, other: &HandoverView) -> bool
fn eq(&self, other: &HandoverView) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for HandoverView
impl Serialize for HandoverView
impl StructuralPartialEq for HandoverView
Auto Trait Implementations§
impl Freeze for HandoverView
impl RefUnwindSafe for HandoverView
impl Send for HandoverView
impl Sync for HandoverView
impl Unpin for HandoverView
impl UnsafeUnpin for HandoverView
impl UnwindSafe for HandoverView
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
Mutably borrows from an owned value. Read more
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
Compare self to
key and return true if they are equal.