All data that is published is turned into a
shared_ptr and wrapped in an envelope.
You can save a call to
std::move by pre-allocating your object as a
but remember, the object is shared at that point so avoid changing the data it
points to. Subscribers only receive pointers to const data.
There are a handful of major envelope types.
- All envelopes inherit from
pipeline::AbstractEnvelope. This is a type-erased envelope that provides base functionality (timestamping and serialization).
pipeline::DataEnvelopetype is a type that holds serialized data (typically coming from a log or from the comms system). This is a type-erased envelope, and provides functionality for converting itself into a “concrete envelope” on demand, one you know the underlying type.
pipeline::Envelope<T>type, or “concrete envelope”, wraps a particular type
T, which you can either fetch directly (by const reference), or you can get the timestamp, or serialize the object (assuming
Tis serializable, it doesn’t need to be).
Subscribers can subscribe to the abstract envelope if they so desire. You can simply
subscribe to the
pipeline::AbstractEnvelope type and you will receive envelope pointers.
Each envelope has the following members:
publish_time()- The time the message was published.
to_json()- Serializes the object as a JSON blob.
to_bytes()- Serializes the object into a
Subscribing to the abstract envelope can be useful if you want to listen to what a publisher is sending without necessarily knowing the type.
A system limitation at the moment is that the log reader will refuse to publish
to subscribers of
pipeline::AbstractEnvelope, and the comms stages will refuse to
publish data coming in over HTTP to a subscriber of
This is a temporary limitation; it is expected to be lifted soon.