Skip to content
markpaper

src/ws/index.ts

v0.3.0 · 1.7 KB

Download file
// Public API of the WebSocket module.
//
// WS gives speed, REST is the truth: reconcile positions, orders and balances through REST
// periodically, keep a REST fallback for every WS cache, and remember that spot balances are not
// delivered over WS at all.

export {
  createWsClient,
  redactWsUrl,
  NODE_WS_SOCKET_OPTIONS,
  type WsClient,
  type WsClientOptions,
  type WsClientState,
  type WsClientStats,
  type WsHandler,
  type WsUnsubscribe,
  type WebSocketLike,
  type WebSocketConstructorLike,
} from './client.js';

export {
  reconnectDelay,
  DEFAULT_RECONNECT_POLICY,
  WS_CLOSE_POLICY_VIOLATION,
  type ReconnectPolicy,
} from './backoff.js';

export {
  WS_LIMITS,
  createWsIpBudget,
  type WsIpBudget,
  type WsIpBudgetLimits,
  type WsIpBudgetStats,
  type WsBudgetWarning,
  type WsSubscribeCheck,
  type WsConnectionCheck,
} from './limits.js';

export {
  classifyWsServerError,
  WsLimitError,
  type WsServerErrorKind,
  type WsServerErrorInfo,
  type WsClientError,
  type WsClientErrorKind,
  type WsLimitReason,
} from './errors.js';

export {
  normalizeAddress,
  isValidAddress,
  canonicalizeSubscription,
  subscriptionKey,
  trackedUserOf,
  channelsOf,
  frameMatchesSubscription,
  matchEcho,
  looseAckKey,
  WsSubscriptionError,
} from './subscriptionKey.js';

export {
  createStalenessTracker,
  type StalenessTracker,
  type StalenessTrackerOptions,
  type StalenessStats,
} from './selfHeal.js';

export {
  createTidDeduper,
  isSnapshotFrame,
  splitUserFills,
  type TidDeduper,
  type UserFillsSplit,
} from './dedupe.js';

export { planUserSlots, diffUserSets, type UserSlotPlan, type UserSetDiff } from './userSet.js';

export type * from './types.js';
All files