Socket draining Phoenix.Socket.Transport

This very useful socket draining feature was added ~six months ago: Add socket draining (#5363) · phoenixframework/phoenix@52061f4 · GitHub

It works just fine with LiveView & Channels, but I yet understand how it works with Phoenix.Socket.Transport, even though there was a drainer_spec callback specified there at the time the PR was merged:

I’ve added the following to my transport module (handler):

  def drainer_spec(opts) do
    Phoenix.Socket.__drainer_spec__(__MODULE__, opts, [])
  def child_spec(opts) do
    Phoenix.Socket.__child_spec__(__MODULE__, opts, [])

It does use the Phoenix.Socket.PoolSupervisor, and I see it’s started up the Phoenix.Socket.PoolDrainer as well, but unless the sockets themselves are started with PoolSupervisor.start_child, they won’t be drained, right? Is there a way to make this work with Phoenix.Socket.Transport?

Thanks in advance for any help! :smile:

1 Like