Polymarket.WebSocket.SocketSupervisor (Polymarket v0.1.1)

Copy Markdown View Source

Dynamic supervisor for all websocket connections to polymarket.

A single websocket can only hold so many asset ids, so sharding is required to make sure we can subscribe to more assets than a single connection allows.

Summary

Functions

Adds a new websocket connection to the supervisor.

Returns a specification to start this module under a supervisor.

Functions

add_connection(opts \\ [])

@spec add_connection(keyword()) :: DynamicSupervisor.on_start_child()

Adds a new websocket connection to the supervisor.

Accepts the same options as Polymarket.WebSocket.start_link/1 (for example handler:) to inject a custom event handler.

Connections are :temporary children: a dead connection is not restarted, because the restarted process would carry a new pid and no subscriptions, invisible to whoever opened it. Owners are expected to monitor the returned pid and open a replacement themselves.

child_spec(arg)

Returns a specification to start this module under a supervisor.

See Supervisor.