Repository navigation
v0.5.0
- @streamsy/core@0.5.0
- @streamsy/projection@0.5.0
- @streamsy/serve@0.5.0
- @streamsy/storage@0.5.0
Durable State control messages (93fb11f)
Breaking change: the item type of a State address now includes control messages. Code that reads type, key or headers.operation from a State item must narrow the item first.
A State stream can now hold the control messages of the Durable State protocol: snapshot-start, snapshot-end and reset. Before this release, StreamAddress.state failed to decode a stored control. Streams.decode then failed the whole batch with a DecodeFault, and a follow or projection on that address stopped.
StreamAddress.statedecodes and encodes controls. The items of aStateAddress, aStreamsy.stateroute andServe.statehave the new typeStreamAddress.CollectionsEvent<C>. That type isCollectionsChange<C> | StateControl. It wasCollectionsChange<C>.StreamAddress.isControlandStreamAddress.isChangenarrow an item.StreamAddress.reset(),StreamAddress.snapshotStart()andStreamAddress.snapshotEnd()make a control. Each one takes an optional{ offset }.StreamAddress.stateControlis the codec for one control.StreamAddress.stateChangestays the codec for the changes of one collection.DurableState.changesand projection outputs acceptDurableState.Entry<C>, which is a row change or a control. A control is written unchanged. With anoffset, a control that has no offset gets that offset.Serve.stateserves stored controls as they are. It still refuses thex-streamsy-state-reset: snapshotrequest header.
To migrate a reader that folds State items, skip controls or handle them:
if (StreamAddress.isControl(item)) {
if (item.headers.control === "reset") rows.clear();
} else if ("value" in item) rows.set(item.key, item.value);
else rows.delete(item.key);