swift-server / swift-server/async-http-client
add better EventLoopPreference names
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 1.1k
- Forks
- 156
- PR merge metrics
- No merged PRs in 30d
Description
Right now, we have three (public) EventLoopPreferences:
.delegate(on: EventLoop).indifferent.delegateAndChannel(on: EventLoop)
I did propose this naming personally so I feel a little sheepish for proposing to change (or just add better) names. But let me explain how we got here:
When I proposed this, I thought that the user only wants to choose the EL for the delegate callouts. To use AHC however, a user needs more guarantees. Almost all users will want to specify an EL and they require the following things to happen the specified EL:
Task.futureResultneeds to be bound to the specified EL- all delegate methods need to be called on the specified EL
- all other callouts need to be called on the specified EL
Today (and in the future), .delegate(on: el) does exactly that. The naming however is confusing because it only mentions the delegate (but not the future or other callouts).
My new proposed naming is:
.on(EventLoop).indifferent.forceChannelAndCalouts(on: EventLoop)
Maybe to reduce the number of deprecation warnings we should do
.on(EventLoop).delegate(on: EventLoop)(same as.on(EL)).indifferent. forceChannelAndCalouts(on: EventLoop).delegateAndChannel(on: EventLoop)(same as. forceChannelAndCalouts(on: EL))
I think we need to focus on the 99% case and the 99% case is that users really don't care where the Channel lives but they very much care where the future and all the callouts come from.
That means that we mostly need to focus on the name of the 99% case and I think eventLoopPreference: .on(myEL) is great.
All the other cases (2 - 5) are really for special uses so it's actually good if the names are slightly longer.
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 by locating the public EventLoopPreference declaration and its usages, then review how the proposed .on, .delegate, .indifferent, and .forceChannelAndCallouts names map to the existing cases. Check the public API and compatibility implications, including whether deprecated aliases are needed; done means the naming choice and its migration behavior are agreed and consistently represented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100