Skip to main content

Module adapters

Module adapters 

Source
Expand description

Storage and network adapters for BEAM.

This module contains all adapter implementations that connect the crate::Node graph engine to external systems:

§Storage Adapters

  • MemoryStorage — in-memory HashMap-backed storage (default)
  • RedbStorage — persistent embedded storage via redb (native only)
  • [FjallStorage] — persistent LSM-tree storage via [fjall] (native only, feature-gated)
  • [WasmIdbStorage] — persistent IndexedDB storage (browser/WASM only)
  • [WasmNodeFsStorage] — persistent node:fs/promises storage (Node.js WASM, node-fs feature)
  • [WasmOpfsStorage] — persistent OPFS storage (browser/WASM only)

§Storage Read/Write Split

Storage adapters that implement [Actor::try_clone_storage] are started as two actors by the Router: a read actor (receives Get) and a write actor (receives Put, BatchPut, Flush). Both share the same underlying store via Arc, so reads see committed writes immediately.

  • RedbStorage splits — the write actor’s spawn_blocking fsync no longer blocks the read actor’s concurrent Get queries.
  • [FjallStorage] splits — though less critical than redb (fjall’s writes are journal appends, not fsyncs), the split still provides backpressure isolation.
  • MemoryStorage does not split — in-memory writes are synchronous (no fsync), so splitting provides no benefit and would break read-after-write ordering.

§Network Adapters

  • OutgoingWebsocketManager — outgoing WebSocket client manager (native only)
  • WsServer — incoming WebSocket server with optional TLS (native only)
  • WsConn — per-connection WebSocket actor (native only)
  • Multicast — UDP multicast LAN discovery (native only)
  • [WebRtcPeer] — WebRTC data channel P2P connection (feature-gated)

§Adapter Protocol

All adapters implement the crate::actor::Actor trait and receive [crate::message::Message] via the actor system. Storage adapters handle Get, Put, BatchPut, and Flush. Network adapters handle Put and Get by serializing to the wire format and forwarding to remote peers.

Structs§

MemoryStorage
In-memory storage adapter backed by HashMap<String, Children>.
Multicast
UDP multicast adapter for LAN peer discovery and sync.
OutgoingWebsocketManager
Manages outbound WebSocket connections to relay servers.
RedbStorage
redb-backed persistent storage adapter for BEAM.
WsConn
A per-connection WebSocket actor that bridges Gun protocol messages.
WsServer
WebSocket server adapter that accepts inbound connections.
WsServerConfig
Configuration for the WsServer adapter.