Skip to main content

Module state

Module state 

Source
Expand description

Publishing shared state as snapshots or patches.

The client keeps a copy of the agent’s state. Sending the whole thing on every change is wasteful for a large document that gained one field, and sending a patch is wasteful for a small document that changed completely. StateManager keeps the last published snapshot and picks per publish:

  1. the first publish is always a STATE_SNAPSHOT — the client’s copy may have drifted, and a patch against an unknown base is inapplicable;
  2. afterwards it diffs against the last snapshot with RFC 6902 and emits STATE_DELTA;
  3. unless the serialized patch is no smaller than the serialized snapshot, in which case it snapshots instead.

Structs§

StateManager
Tracks the last published state so changes can go out as patches.

Enums§

StatePublish
What a publish decided to send.