Skip to main content

Crate brainos_bridge

Crate brainos_bridge 

Source
Expand description

§Brain Bridge

External service relay — WebSocket client that connects Brain to a remote messaging gateway and relays inbound messages through Brain’s signal processing pipeline.

§Protocol

  1. BridgeClient connects to the configured url via WebSocket.
  2. Each inbound text frame must be a JSON-encoded BridgeMessage.
  3. A caller-supplied handler function processes the message and returns a BridgeMessage response.
  4. The response is serialised and sent back as a text frame.
  5. On disconnect, the client reconnects with exponential backoff.

§Usage

let client = BridgeClient::new("ws://gateway.example.com/brain", BridgeConfig::default());
client.connect_and_relay(|msg| async move {
    BridgeMessage::reply(&msg, format!("Echo: {}", msg.content))
}).await?;

Structs§

BridgeClient
WebSocket client that relays messages between Brain and a remote gateway.
BridgeConfig
Configuration for BridgeClient reconnection behaviour.
BridgeMessage
A message exchanged between Brain and the remote gateway.

Enums§

BridgeError