Current section

Files

Jump to
absinthe lib absinthe subscription proxy_supervisor.ex
Raw

lib/absinthe/subscription/proxy_supervisor.ex

defmodule Absinthe.Subscription.ProxySupervisor do
@moduledoc false
use Supervisor
def start_link([pubsub, registry, pool_size]) do
Supervisor.start_link(__MODULE__, {pubsub, registry, pool_size})
end
def init({pubsub, registry, pool_size}) do
task_super_name = Module.concat(registry, TaskSuper)
task_super = {Task.Supervisor, name: task_super_name}
# Shard numbers are generated by phash2 which is 0-based:
proxies =
for shard <- 0..(pool_size - 1) do
{Absinthe.Subscription.Proxy, [task_super_name, pubsub, shard]}
end
Supervisor.init([task_super | proxies], strategy: :one_for_one)
end
end