zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

proxy_supervisor.ex (655B)


      1 defmodule Absinthe.Subscription.ProxySupervisor do
      2   @moduledoc false
      3 
      4   use Supervisor
      5 
      6   def start_link([pubsub, registry, pool_size]) do
      7     Supervisor.start_link(__MODULE__, {pubsub, registry, pool_size})
      8   end
      9 
     10   def init({pubsub, registry, pool_size}) do
     11     task_super_name = Module.concat(registry, TaskSuper)
     12     task_super = {Task.Supervisor, name: task_super_name}
     13 
     14     # Shard numbers are generated by phash2 which is 0-based:
     15     proxies =
     16       for shard <- 0..(pool_size - 1) do
     17         {Absinthe.Subscription.Proxy, [task_super_name, pubsub, shard]}
     18       end
     19 
     20     Supervisor.init([task_super | proxies], strategy: :one_for_one)
     21   end
     22 end