swift-server / swift-server/async-http-client
Accept any EventLoops in `.delegate(on:)`, not just ones from AHC's own ELG
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 1.1k
- Forks
- 156
- PR merge metrics
- No merged PRs in 30d
Description
The badly named but highly useful .delegate(on:) specifies two things:
- Which
EventLoopthe returned futures are bound to - Which
EventLoopthe 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the .delegate(on:) entry point and trace the runtime validation that restricts the supplied EventLoop to AHC's own EventLoopGroup. Add coverage using an EventLoop from a separate group, then verify that delegation works without a crash while the underlying Channels remain governed by AHC.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100