NodeRuntime class

A remote participant that connects out to a hub, registers, heartbeats, and optionally answers RPCs — reconnecting with backoff on drops.

final node = OmnyNode(NodeConfig(
  hubUri: Uri.parse('ws://hub.local/_node'),
  nodeId: NodeId('worker-1'),
  capabilities: {'transcode'},
));
await node.start();

Constructors

NodeRuntime(NodeConfig config, {ConnectionCodec<NodeControlMessage>? codec, Logger logger = const NoopLogger(), IdGenerator? idGenerator})
Creates a node runtime.

Properties

codec ConnectionCodec<NodeControlMessage>
The codec used on the control channel.
final
config NodeConfig
The node's configuration.
final
hashCode int
The hash code for this object.
no setterinherited
isReady bool
Whether the node is registered and serving.
no setter
logger Logger
Logger for lifecycle events.
final
registration NodeRegistered?
The hub's acknowledgement of the current registration, or null if the node has never completed one. Carries the hub id and any application payload the hub returned (see NodeConfig.registerPayload).
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state NodeState
The current lifecycle state.
no setter
states Stream<NodeState>
A broadcast stream of state transitions.
no setter
terminalError Object?
The failure that ended the runtime, if NodeConfig.isTerminal judged one unrecoverable. null when the node is running, or was stopped by stop.
no setter

Methods

discoverPeers({String? capability, Map<String, String> labels = const {}, Map<String, dynamic> filter = const {}, Duration timeout = const Duration(seconds: 10)}) Future<List<NodeDescriptor>>
Discovers peer nodes via the hub (must be isReady).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify(String action, {Map<String, dynamic> payload = const {}}) → void
Pushes a one-way NodeNotify to the hub — no correlation id, no reply.
request(String action, {Map<String, dynamic> payload = const {}, Duration timeout = const Duration(seconds: 30)}) Future<NodeResponse>
Invokes action on the hub over the control channel and awaits its NodeResponse — the mirror of NodeGateway.request.
start() Future<void>
Starts the connect → register → heartbeat loop (with reconnection).
stop() Future<void>
Stops the node: sends a goodbye, closes the connection, and ends the loop.
toString() String
A string representation of this object.
inherited
updateDescriptor(NodeDescriptor descriptor) → void
Revises what this node advertises, without re-registering.

Operators

operator ==(Object other) bool
The equality operator.
inherited