Files
lmxopcua/docs/DataConnections.md
T

132 lines
9.3 KiB
Markdown

# gRPC data connections
Data connections expose current Raw and UNS data between explicitly configured nodes or clusters.
The contract supports capabilities, browse, metadata, cached reads, writes and data-change
subscriptions. It is independent of the existing mesh command, telemetry, configuration and
pair-sync planes. An Akka pair continues to own its local field-device drivers; importing a peer's
data does not start another device driver or join the peer's gossip ring.
## Configuration and deployment
A connection is directional. Configure each direction separately when both sides need imports.
The deployed configuration uses three entities:
| Entity | Operator choices |
|---|---|
| `DataConnection` | Owning cluster, explicit consumer nodes, expected remote cluster/node, Node or Cluster target, endpoint set, consistency, secret reference, operation subset and finite call limits. |
| `DataExport` | Origin-owned Raw or UNS root, authenticated peer principal, operation grants and export limits. |
| `RemoteNamespaceMapping` | Connection, consumer subset, local parent and branch name, same-realm remote root/address, operations, optional write-through, projection limits and freshness settings. |
New connections, exports and mappings are disabled by default; write-through also defaults off.
A saved draft is not a live import. Use the existing cluster deployment flow to validate and apply
changes, and inspect applied state before enabling dependent consumers. The server-side schema
validator remains authoritative: consumers must belong to the owning cluster, mapping consumers
must be a subset of the connection's consumers, local parents must be valid containers, and branch
collisions, invalid self-routes and unsupported type expectations are rejected.
New connections default to a 30-second call timeout. Existing explicitly configured shorter
timeouts remain in force. This limit never extends a caller's original deadline; a write without
enough remaining time for the driver budget is rejected before dispatch.
Raw maps to Raw and UNS maps to UNS. A remote root is a branch, so descendants can be discovered
without authoring one import row per leaf. The local mapping owns a distinct view with remote origin
provenance. Remote projected branches cannot be re-exported as locally owned data. Stable addresses
use cluster, namespace URI, identifier kind and identifier; numeric OPC UA namespace indexes are
process-local.
## Listener, credentials and trust
Enable the dedicated listener with `DataConnections` host settings; see
[Configuration](Configuration.md#dataconnections). Production requires TLS, a dedicated port,
explicit allowed hosts and authenticated target identity. The listener certificate must have a
current private key and SANs covering every allowed host; server-certificate rotation requires a
rolling restart. Outbound trust validates the hostname and configured custom roots. The development cleartext exception is
limited to Development on a literal loopback listener.
The consuming node must have its target bearer credential provisioned locally under the configured
canonical `secret:data/...` reference and scoped to that connection. An origin export names the
principal authenticated by that credential. Deployment artifacts carry references and scope,
never raw target credentials. `CredentialBundlePath` and `TrustBundlePath` support independently
versioned local provisioning. Trust roots are provisioned independently of credentials; rotating
one does not implicitly authorize the other. Protect mounted files and replace them atomically.
Missing or unreadable mounts are retried rather than treated as credential deletion; explicit
versioned deletion/removal and deployed scope retirement revoke authority. Do not reuse the
existing mesh PSKs for this data plane.
## Routing and availability
Node targets pin the expected node. Cluster targets select an authenticated, ready primary from
the configured eligible endpoints; an endpoint's claimed cluster and serving incarnation must match
policy. An explicit Node target may allow `ReadyReplica` for reads/subscriptions; writes still
require primary authority. A secondary is not a write proxy to its partner. Same-cluster peer
connections and cross-cluster connections use the same explicit routing rules.
Role changes, deployment changes, metadata lease expiry and credential/trust changes invalidate
stale authority. Recovery discovers the current catalog and starts a new subscription epoch with
a fresh snapshot. Transitions during a disconnect can be lost. A peer outage must be treated as
unavailable/pending remote data rather than a successfully browsed empty branch. Local device data
continues independently. [Read/write operations](ReadWriteOperations.md) describes asynchronous
projected cache refresh, freshness checks and mutation outcomes.
### Subscription freshness and exact-item renewal
Peers negotiate stream freshness challenges and per-item metadata leases as separate capabilities.
A Subscribe-authorized active item can receive a bounded, same-stream freshness challenge. The
origin captures its age after accepting that challenge and keeps the challenge identifier coupled
to the sample through delivery. The consumer bounds age by combining that origin age with elapsed
time since its challenge started, then advances the bound through local queueing and publication.
An unknown, expired, evicted or unnegotiated challenge cannot establish a finite age bound.
Periodic challenge snapshots can renew a quiet item's age evidence without a device poll or an
additional Read grant. A newer sample version alone cannot inherit an older challenge's proof.
An existing SDK monitored item can renew only its **exact projected node** through a successful
`GetMetadata` response with an explicit item lease from a peer advertising that capability.
`MaxMetadataLease` is a ceiling, not an implicit grant. The origin still authorizes the service
principal for Metadata; the consumer rechecks the original local caller and key for Subscribe.
Renewal checks the full prior origin view and subject, serving identity, catalog/authority epochs,
mapping scope, node lifetime and compatible metadata shape. Its lease begins at the consumer's
monotonic request start and is capped by the mapping and original credential lifetime. A delayed
reply cannot lengthen it. Renewal grants no parent or sibling visibility, Browse page, cursor or
local Browse privilege. Missing capability, denied Metadata or an invalid lease leaves the item
unavailable until valid authority can be established.
An authorized logical monitored-item request can survive a physical stream expiry and seek a new
pinned binding with bounded retries. The old binding and any queued sample evidence remain tied to
their original authority and serving generation. The same item needs a fresh, complete baseline
under the new stream epoch before it can publish again; old queued or Republish data cannot borrow
the new proof. Withdrawal or expiry of the original local Subscribe authority stops renewal.
Consumers can miss intermediate changes during an interruption.
## Rollout and diagnosis
1. Provision TLS trust and connection-scoped target credentials on each consumer; configure the
origin export and local mapping grants.
2. Deploy with writes disabled. Confirm applied consumer scope, endpoint identity and role, then
expand a remote branch and verify metadata and current-value quality.
3. Verify subscription snapshot recovery and freshness for the intended consumer workload.
4. Enable write-through only where the application can handle confirmed, unconfirmed and unknown
outcomes. Never replay an ambiguous write after reconnect or failover.
5. To disable imports, disable the connection/mapping through the existing deployment flow. Retired
authority makes imported data unavailable; disabling does not replay pending writes.
For an unavailable import, check enabled versus deployed state, consumer membership, endpoint and
allowed-host identity, target role/readiness, credential scope/version, trust roots, export/mapping
operation intersection, metadata lease and sample age. Inspect stream resets/overflow, admitted
retained import views, acknowledged registrations and distinct write outcomes where diagnostics expose them.
The age upper bound is measured by the reporting node at the observation, independent of the admin
server clock. Coalescing notices and resets have separate counts; unavailable overflow evidence is
shown as unavailable. Ready describes the last verified handshake, whose timestamp is shown. Saving configuration is not evidence
of a ready connection, and a live transport alone is not evidence of current metadata authority.
Listener, connection, export and projection limits bound messages, streams, monitored items,
retained bytes, metadata and call lifetimes. Tune them together for measured workload demand;
defaults are admission bounds, not a throughput or capacity guarantee. Overload can reject work or
reset a stream, requiring a fresh snapshot. Do not interpret that recovery as lossless replay.
## Feature boundary
Remote history, alarm/event forwarding and relay operations are future work. Authorized imported
current values can feed local derived engines, including calculations, scripts, historization and
alarm evaluation. Such local processing does not add a remote history/alarm API or permit re-export
of an imported branch.