Expand description
Connector for fetching entities from a remote Haystack server.
§Overview
A Connector maintains a persistent connection (HTTP or WebSocket) to a
remote Haystack server, periodically syncs entities into a local cache, and
proxies write operations (hisRead, hisWrite, pointWrite,
invokeAction, import) to the remote when the target entity is owned by
that connector.
§Lifecycle
- Construction —
Connector::newcreates a connector with an empty cache from aConnectorConfig(parsed from the TOML federation config). - Connection — on first sync,
Connector::synccallsconnect_persistent()which tries WebSocket first, falling back to HTTP. - Sync loop —
Connector::spawn_sync_taskspawns a tokio task that callsConnector::syncat an adaptive interval. Sync tries incremental delta sync via thechangesop first, falling back to full entity fetch. - Cache —
Connector::update_cachereplaces the cached entity list and rebuilds the bitmap tag index and owned-ID set for fast lookups. - Proxy — write ops check
Connector::ownsand forward to the remote server viaproxy_*methods, stripping/re-adding the ID prefix as needed.
§ID Prefixing
When id_prefix is configured, all Ref values (id, siteRef, etc.) are
prefixed on sync and stripped before proxying. See prefix_refs and
strip_prefix_refs.
Structs§
- Connector
- Connector
Config - Configuration for a remote Haystack server connection.
- Connector
State - and state for adaptive sync and federation proxy operations. See the module-level documentation for the full lifecycle. Observable state of a federation connector.
Enums§
- Transport
Mode - Transport protocol used by a connector.
Functions§
- decode_
sync_ payload - Decode an entity grid from HBF binary received during federation sync.
- encode_
sync_ payload - Encode an entity grid to HBF binary for efficient federation sync.
- prefix_
refs - Prefix all Ref values in an entity dict.
- strip_
prefix_ refs - Strip a prefix from all Ref values in an entity dict.