Skip to content

Conversation

@fabianfett
Copy link
Member

Motivation

For the new HTTPConnectionPool.StateMachine we need a new Waiter type.

Modifications

  • Add a new HTTPConnectionPool.Waiter

@fabianfettfabianfett added this to the HTTP/2 support milestone Jul 7, 2021
@fabianfettfabianfett added the 🔨 semver/patch No public API change. label Jul 7, 2021

let id: ID
let request: HTTPScheduledRequest
let eventLoopRequirement: EventLoop?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general for good hygiene I'd recommend these being var instead of let.

let request: HTTPScheduledRequest
let eventLoopRequirement: EventLoop?

init(request: HTTPScheduledRequest, eventLoopRequirement: EventLoop?){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we take the preference separately from the HTTPScheduledRequest, which encodes a preference?

@fabianfettfabianfettforce-pushed the ff-add-waiter branch 2 times, most recently from 0266fef to f92aa7aCompareJuly 8, 2021 13:26
@fabianfettfabianfett requested a review from LukasaJuly 8, 2021 13:53

extension HTTPConnectionPool{
struct Waiter{
struct ID: Hashable{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a great idea ;)

Comment on lines 27 to 35
var id: ID{
ID(self.request)
}

var request: HTTPScheduledRequest{
didSet{
self.updateEventLoopRequirement()
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this feels a bit off. If we can the request then the id of the waiter also changes. Is that the behaviour we actually want or should it really be called requestID?

Comment on lines 18 to 42
struct RequestID: Hashable{
private let objectIdentifier: ObjectIdentifier

init(_ request: HTTPScheduledRequest){
self.objectIdentifier = ObjectIdentifier(request)
}
}

struct Waiter{
var requestID: RequestID{
RequestID(self.request)
}

var request: HTTPScheduledRequest{
didSet{
self.updateEventLoopRequirement()
}
}
Copy link
MemberAuthor

@fabianfettfabianfettJul 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glbrntt Changed to RecordID. But I moved the RecordID type out of the waiter.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still says RequestID. Have I missed something?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to be called ID and was on the type Waiter, but dependent on the HTTPScheduledRequest

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I was confused by this comment saying the change was to RecordID.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

var request: HTTPScheduledRequest{
didSet{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might it be easier to make eventLoopRequirement a computed property?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since HTTPScheduledRequest is a protocol, I wanted to keep the number of calls going through the lookup table as small as possible.

@fabianfettfabianfett merged commit 7311c0e into swift-server:mainJul 8, 2021
@fabianfettfabianfett deleted the ff-add-waiter branch July 8, 2021 16:57
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patchNo public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@fabianfett@Lukasa@glbrntt