Install
Building the client
.Build(ctx) establishes the WebSocket connection before returning - the passed context governs the initial dial. If the connection fails, you get the error immediately. The client then runs until Close().
Builder methods
.URL(url) - Primary WebSocket endpoint. Falls back to ORBITFLARE_WS_URL env var.
.URLs(urls...) - Primary + fallbacks in one call.
.FallbackURL(url) / .FallbackURLs(urls...) - Add failover endpoints. On reconnect, the SDK rotates through them.
.APIKey(key) - License key. Falls back to ORBITFLARE_LICENSE_KEY env var. Injected into the URL at connect time, never printed in logs or errors.
.Retry(policy) - Reconnection backoff. Default: 100ms initial, 30s max, 2x multiplier, infinite attempts.
.PingInterval(duration) - How often the SDK sends WebSocket Ping frames. Default: 10s.
.MaxMissedPongs(n) - Pings without a response before killing the connection. Default: 3.
.Logger(logger) - A *slog.Logger for connection lifecycle events. When unset, controlled by ORBITFLARE_LOG.
Available subscriptions
SlotSubscribe(ctx)
Fires every time a slot is processed, confirmed, or finalized.
slot, parent, and root fields:
AccountSubscribe(ctx, address, commitment)
Fires when the specified account’s data changes.
LogsSubscribe(ctx, mentions, commitment)
Fires for transactions that mention the given addresses. Pass an empty slice for all transactions.
SignatureSubscribe(ctx, signature, commitment)
Fires once when a transaction reaches the given commitment level. Useful for confirming a transaction you just sent.
Reading events
All subscriptions return a*ws.Subscription. Call Next(ctx) to get the next event:
Next(ctx) returns (json.RawMessage, bool). When ok is false the subscription is finished (the context was cancelled or the client closed).
Unsubscribing
Multiple subscriptions
All subscriptions run on a single WebSocket connection. The SDK routes notifications to the right subscription internally.Reconnection
If the connection drops, the background goroutine reconnects with exponential backoff and re-subscribes everything automatically. YourNext(ctx) calls just keep working - events resume once the connection is back.