swift-server/async-http-client

Accept any EventLoops in `.delegate(on:)`, not just ones from AHC's own ELG

weissi opened this issue · 0 comments

The badly named but highly useful .delegate(on:) specifies two things:

  1. Which EventLoop the returned futures are bound to
  2. Which EventLoop the delegate callouts happen on.

Crucially it does not specify on what EventLoop the underlying Channels are running on. Yes, as an optimisation if possible & sensible (i.e. the connection pool doesn't already have a valid connection) we try to create new Channels on the same EventLoop but that's neither guaranteed nor required.

Expected behaviour

If I pass a random EventLoop to AHC's eventLoop: .delegate(on: myRandomEL) then I would expect this to work, even if AHC itself is using an EventLoopGroup that doesn't contain my EventLoop for its Channels.

Actual behaviour

AHC crashes and tells me that I can only use EventLoops from AHC's EventLoopGroup at runtime. That's bad an unnecessary.