ZenWebsocket.Examples.AdapterSupervisor (ZenWebsocket v0.4.2)

Copy Markdown View Source

Supervisor for WebSocket adapters with fault tolerance.

This supervisor manages adapter GenServers alongside the ClientSupervisor, creating a robust supervision tree where:

  • ClientSupervisor manages Client GenServers
  • AdapterSupervisor manages adapter GenServers
  • Adapters monitor their Clients and handle reconnection

Example

children = [
  {ZenWebsocket.ClientSupervisor, []},
  {ZenWebsocket.Examples.AdapterSupervisor, [
    adapters: [
      {DeribitGenServerAdapter, [
        name: :deribit_main,
        client_id: "...",
        client_secret: "..."
      ]},
      {DeribitGenServerAdapter, [
        name: :deribit_backup,
        url: "wss://www.deribit.com/ws/api/v2",
        client_id: "...",
        client_secret: "..."
      ]}
    ]
  ]}
]

Supervisor.start_link(children, strategy: :one_for_one)

Summary

Functions

Returns a specification to start this module under a supervisor.

Starts the adapter supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)

@spec start_link(keyword()) :: Supervisor.on_start()

Starts the adapter supervisor.