xmachines-codec-msgpack
MessagePack for xmachines-rs machines, an xmachines-codec codec named msgpack: events as MessagePack (application/msgpack, application/x-msgpack, application/vnd.msgpack), and snapshot records of format byte 2 followed by the snapshot as MessagePack, maps with string keys, so any MessagePack reader can decode them.
When to use it
Use it for snapshots that are smaller and faster to write than JSON (a small order actor's snapshot is 484 bytes and about 1.1 µs to write in the compact form) and still self-describing, so it needs no schema and reads back every snapshot JSON can hold: in the Kafka service, "codec": "msgpack" with its msgpack feature. Register it in a host's Codecs wherever events or snapshots should be MessagePack.
Snapshots are written by a dedicated writer, byte-identical to rmp_serde's named encoding, because snapshots are written once per changed actor and rmp_serde's general writer cost several times the encoding; data of unknown length goes through rmp_serde. Records are read with rmp_serde.
Example
use json;
use Codecs;
let mut codecs = new;
codecs.register.unwrap;
let msgpack = codecs.get.unwrap;
let mut record = Vecnew;
msgpack.snapshots.unwrap.encode.unwrap;
assert_eq!;
assert_eq!;
Pins
rmp-serde 1.3 for reading.
Related crates
xmachines-codec: the codec traits and their registry.xmachines-kafka: itsmsgpackfeature registers this codec.
License
MIT