Struct actyx_sdk::Event [−][src]
Expand description
Events are delivered in this envelope together with their metadata
Metadata
Ordering and equality do not depend on the type of payload: lamport
and key.stream
uniquely identify the event and give rise to a total order (first by Lamport timestamp,
then by stream ID; an Actyx node will never use the same Lamport timestamp
more than once).
The contained Lamport timestamp tracks the causal order of events, which may not
always be linked to or consistent with real time, especially when events were produced by devices
that were not communicating for some time period. This implies that the wall clock
timestamp
may go backwards when consuming an ordered event stream (this would also
be the case due to clock skew between devices).
Illustrative example: two groups of nodes are separated from each other for some time period, for example due to traveling through an area without network coverage. Their logical clocks may advance at different speeds because the number of events created in each group may be different. When sorting by Lamport timestamp, the events from the group with the lower event rate will tend to be sorted earlier than the events from the other group, regardless of the wall clock time at which they occurred.
It is desirable to sort by Lamport timestamps because they provide the correct (intuitive) sort order when nodes are properly communicating, which is the common case. Using device hardware clocks has proven to be quite unreliable because they may jump forward and backward due to human or machine error.
Payload
The envelope contains a generic Payload
payload type, you may use
the extract
method to parse the payload as a more specific object.
use serde::{Deserialize, Serialize};
use actyx_sdk::{Event, Payload};
#[derive(Serialize, Deserialize, Debug, Clone)]
struct MyPayload {
x: f64,
y: Option<f64>,
}
let payload = Payload::from_json_str(r#"{"x":1.3}"#).unwrap();
Fields
key: EventKey
Uniquely identifying event key. Used for sorting.
meta: Metadata
Metadata incl. tags, timestamp and app ID
payload: T
The actual event payload
Implementations
Try to extract the given type from the generic payload and return a new
event envelope if successful. The produced payload is deserialized as efficiently
as possible and may therefore still reference memory owned by the Payload
.
You may need to .clone()
it to remove this dependency.
Trait Implementations
Write any additional information about &self
beyond its binary representation. Read more
Performs the +=
operation. Read more
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
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Ensure that the given event is no longer contained within this OffsetMap.
Auto Trait Implementations
impl<T> !RefUnwindSafe for Event<T>
impl<T> !UnwindSafe for Event<T>
Blanket Implementations
Mutably borrows from an owned value. Read more
Casts the value.
Casts the value.
Compare self to key
and return true
if they are equal.
Performs the conversion.
Performs the conversion.
Casts the value.
OverflowingCasts the value.
Casts the value.
Casts the value.
Casts the value.
UnwrappedCasts the value.
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Casts the value.
WrappingCasts the value.