Module subscription

Module subscription 

Source
Expand description

Generic subscription state tracking for WebSocket clients.

This module provides a robust subscription tracker that maintains confirmed and pending subscription states with reference counting support. It follows a proven pattern used in production.

§Key Features

  • Three-state tracking: confirmed, pending_subscribe, pending_unsubscribe.
  • Reference counting: Prevents duplicate subscribe/unsubscribe messages.
  • Reconnection support: all_topics() returns topics to resubscribe after reconnect.
  • Configurable delimiter: Supports different topic formats (. or : etc.).

§Topic Format

Topics are strings in the format channel{delimiter}symbol:

  • Dot delimiter: tickers.BTCUSDT
  • Colon delimiter: trades:BTC-USDT

Channels without symbols are also supported (e.g., execution for all instruments).

Structs§

SubscriptionState
Generic subscription state tracker for WebSocket connections.

Functions§

split_topic
Splits a topic into channel and optional symbol using the specified delimiter.