API Reference ZenWebsocket v#0.7.0

Copy Markdown View Source

Modules

A robust WebSocket client library for Elixir, built on Gun transport.

WebSocket client GenServer using Gun as transport layer.

Process-down-safe GenServer.call helpers used by ZenWebsocket.Client.

Gun connection open, upgrade, and cleanup for ZenWebsocket.Client.

JSON-RPC response and timeout correlation for ZenWebsocket.Client.

Inbound WebSocket frame routing for ZenWebsocket.Client.

Explicit reconnect target and option handling for ZenWebsocket.Client.

Session recorder lifecycle and frame writes for ZenWebsocket.Client.

Connection-error retry state machine for ZenWebsocket.Client.

Pure retry eligibility and error normalization for ZenWebsocket.Client.

Gun error/down logging and retry dispatch for ZenWebsocket.Client.

Optional supervisor for WebSocket client connections.

Configuration struct for WebSocket connections.

ETS-based connection tracking without GenServer.

Conditional debug logging for ZenWebsocket.

Simple error handling for WebSocket connections.

Supervisor for WebSocket adapters with fault tolerance.

Simple batch subscription manager for efficiently subscribing to multiple channels.

Simplified Deribit WebSocket API adapter.

Production-ready supervised Deribit adapter with automatic reconnection.

Shared Deribit JSON-RPC method definitions and request builders.

Basic usage examples from the documentation. These examples demonstrate simple WebSocket connections and message handling.

Error handling and retry patterns from Examples.md

JSON-RPC client example from documentation.

Examples of subscription management with WebSocket connections.

Shared JSON-RPC send helper used by Deribit example adapters.

Minimal template for creating platform-specific WebSocket adapters.

Basic WebSocket client supervision example.

Examples of different WebSocket client usage patterns. This module demonstrates three ways to use ZenWebsocket

Example application module demonstrating all WebSocket connection patterns.

WebSocket frame encoding and decoding utilities.

Records application-level heartbeat pongs and emits interval telemetry.

Manages heartbeat lifecycle for WebSocket connections.

Helper functions for Deribit-specific WebSocket operations.

JSON-RPC 2.0 request builder and response matcher.

Bounded circular buffer for latency statistics calculation.

Message handling utilities for WebSocket connections.

Health-based connection routing for WebSocket client pools.

Token bucket rate limiter for WebSocket API calls.

Internal reconnection helper for Client GenServer.

Pure functions for WebSocket session recording and replay.

Async GenServer for recording WebSocket sessions to JSONL files.

Manages request/response correlation for JSON-RPC WebSocket connections.

Invokes user-provided lifecycle callbacks without letting them crash the caller.

Tracks Deribit-dialect JSON-RPC subscriptions for reconnect restoration.

Test helpers for consumers testing ZenWebsocket integrations.

Mix Tasks

Mix task to export ZenWebsocket usage rules for AI agents and developers.

Validates that code follows ZenWebsocket usage rules.