Repository navigation
state: node properties (min, max, unit, ...), as STATE_API.md documents them - #685
Merged
Merged
Conversation
STATE_API.md has documented state::property("min", ...) for metadata such
as units and ranges, but nodes carried only comment, hidden and readOnly.
This adds the documented API:
- property(key), property(key, value), has_property, property_keys and
properties(): named metadata strings beside the comment. "" removes a
key. propertyChanged fires with the key. A property does not
initialize the node, and reset() clears them.
- They replicate as a new set_property mutation (the key in type_name,
the value in string_value). It is appended to state_mutation_op, so
the IPC wire's op byte keeps its values, and becomes
MUTATION_OP_SET_PROPERTY = 11 in the proto.
- Snapshots carry them:
- snapshot_entry::properties, applied by ingest_snapshot_entry;
- gRPC SnapshotEntry.properties (field 11);
- IPC: a trailer after the entries, which older peers stop before.
- pycvc's State gets property, has_property and property_keys; the signal
and the map accessor are %ignored.
Tests: state_test (set, get, remove, signal, reset) and
distributed_state_session_test (live replication, removal, and snapshot
reassembly).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
docs/STATE_API.mdhas documentedstate::property("min", ...)/property("max", ...)/property("units", ...)as the place for a node's metadata ("Use state properties for metadata (units, ranges, descriptions)"), butcvc::statenodes only carriedcomment,hiddenandreadOnly. This adds the documented API, so a binding can publish a recommended range, a unit or a role next to a value, and any application can read it: a UI slider, a validator, a remote peer.The API
property(key)returns the value,""when the key is not set.property(key, value)sets it;""removes the key.has_property(key),property_keys(),properties().propertyChangedfires with the key.comment), so describing a key before anything sets it does not make it look set.reset()clears a node's properties.Replication and snapshots
state_mutation_op::set_property: the key intype_name, the value instring_value. The op is appended to the enum, so the IPC wire's op byte keeps its existing values. On gRPC it isMUTATION_OP_SET_PROPERTY = 11.snapshot_entry::properties, applied bystate_cluster_shard::ingest_snapshot_entry;SnapshotEntry.properties(field 11);Python
pycvc's
Statewraps the real header, so it getsproperty,has_propertyandproperty_keys. The signal and the map accessor are%ignored, like the other signals.Tests
state_test: set, get, remove, the signal, not initializing,reset().distributed_state_session_test: live replication, removal, and snapshot reassembly on a joiner.Built and run on Windows MSVC (
state_test165 tests,distributed_state_session_test16 tests). This box builds neither the IPC transport (POSIX-only) nor gRPC, so their edits rest on CI.The vehicle-physics bindings use this next, for recommended ranges, units and comments on every knob (the P3 PR).