Skip to main content

3. Asynchronous Duplex Client API

· One min read

Status

Accepted

Context

The reactive nature of the Hydra node means that clients produce a stream of inputs to a node which in turns issues a stream of outputs representing the outcome of previous inputs or resulting from interaction with peers in the network.

For example, a client may send a command as input, upon which the node might do something. When that something is finished, a output does indicate that. However, there might also be an output emitted to the client when another peer interacted with "our" node.

Queries, messages by clients which do only fetch information from the node, are not in scope of this ADR.

Decision

  • We use a single, full-duplex communication channel per client connected to a Hydra node
  • This is implemented using a simple Websocket with messages corresponding to Inputs and Outputs.

Consequences

  • Clients needing a synchronous API need to implement it on top
  • Clients can receive outputs decorrelated from any inputs and at any time