-
Notifications
You must be signed in to change notification settings - Fork 123
All internal connection flow should be executed when shutting down #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All internal connection flow should be executed when shutting down #268
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me.
let waiter = HTTP1ConnectionProvider.Waiter(promise: connectionPromise, setupComplete: setupPromise.futureResult, preference: .indifferent) | ||
var action = state.acquire(waiter: waiter) | ||
|
||
switch action { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you can write this a bit shorter as
guard case .create = action else {
XCTFail("unexpected action \(action)")
return
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
action = state.offer(connection: connection) | ||
switch action { | ||
case .closeAnd(_, let next): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this
guard case .closeAnd(_, .closeProvider) = action else {
XCTFail("unexpected action \(action)")
return
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
let waiter = HTTP1ConnectionProvider.Waiter(promise: connectionPromise, setupComplete: setupPromise.futureResult, preference: .indifferent) | ||
var action = state.acquire(waiter: waiter) | ||
|
||
switch action { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this could be a guard
too I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
} | ||
|
||
action = state.connectFailed() | ||
switch action { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, LGTM!
All internal connection flow should be executed when shutting down.
Motivation:
When we shut the client down, we expect the provider to finish all its tasks, if there are some, and then delete itself and succeed the close promise. Currently, if connection is created unsuccessfully, or available connection is closed/times out before we close it as part of shutdown, those connection will not trigger correct flow.
Modifications:
connectFailed
now triggers correct flow when client is.closed
timeout
now triggers correct flow when client is.closed
removeClose
now triggers correct flow when client is.closed
offer
is refactoredResult:
Closes #263
Closes #260