-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Use Async calls from AsyncHTTPClient #555
Conversation
Currently streaming is not working
Codecov Report
@@ Coverage Diff @@
## 7.x.x #555 +/- ##
==========================================
- Coverage 77.17% 71.54% -5.64%
==========================================
Files 75 76 +1
Lines 7860 7847 -13
==========================================
- Hits 6066 5614 -452
- Misses 1794 2233 +439
... and 11 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
XCTFail("Unexpected error: \(error)") | ||
} | ||
} | ||
/* func testRequestStreaming() async throws { |
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.
Is this to be added back in or deleted?
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.
I should have made it clear streaming requests/responses don't work yet. They will the subject of the next few PRs. So I commented out the tests that would fail and will uncomment them as features are implemented.
_ = try await responseTask | ||
XCTAssertEqual(countAtomic.load(ordering: .relaxed), 0) | ||
} | ||
/* func testStreamingResponse() async { |
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.
As above
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.
see above
let eventLoop = eventLoop ?? self.eventLoopGroup.any() | ||
return try await self.execute(request: request, timeout: timeout, on: eventLoop, logger: logger, stream: stream).get() | ||
) async throws -> HTTPClientResponse { | ||
preconditionFailure("Not supported") |
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.
Should we just remove this if it's not supported?
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.
It will get removed in the next PR. Currently it a stub used by another section of code
/* case .asyncSequence(let sequence, let length): | ||
requestBody = .stream( | ||
sequence, | ||
length: length.map { .known($0) } ?? .unknown | ||
) */ |
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.
Commented out code
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 is commented out while streaming requests don't work. It will be re-instated when I get them working
8931bb0
to
18766e6
Compare
Fixed the tests. There was a weird interaction between the test server which can only receive one request at a time and me not flush the response body when I don't expect one |
* Use async HTTPClient calls Currently streaming is not working * Comments * Extract HTTPBody out so it can be used in request * Flush body, when not expecting anything * Remove eventLoop from function comment headers
* Use async HTTPClient calls Currently streaming is not working * Comments * Extract HTTPBody out so it can be used in request * Flush body, when not expecting anything * Remove eventLoop from function comment headers
* Use async HTTPClient calls Currently streaming is not working * Comments * Extract HTTPBody out so it can be used in request * Flush body, when not expecting anything * Remove eventLoop from function comment headers
* Use async HTTPClient calls Currently streaming is not working * Comments * Extract HTTPBody out so it can be used in request * Flush body, when not expecting anything * Remove eventLoop from function comment headers
* Use async HTTPClient calls Currently streaming is not working * Comments * Extract HTTPBody out so it can be used in request * Flush body, when not expecting anything * Remove eventLoop from function comment headers
* Use async HTTPClient calls Currently streaming is not working * Comments * Extract HTTPBody out so it can be used in request * Flush body, when not expecting anything * Remove eventLoop from function comment headers
* Use async HTTPClient calls Currently streaming is not working * Comments * Extract HTTPBody out so it can be used in request * Flush body, when not expecting anything * Remove eventLoop from function comment headers
* Use async HTTPClient calls Currently streaming is not working * Comments * Extract HTTPBody out so it can be used in request * Flush body, when not expecting anything * Remove eventLoop from function comment headers
* Use async HTTPClient calls Currently streaming is not working * Comments * Extract HTTPBody out so it can be used in request * Flush body, when not expecting anything * Remove eventLoop from function comment headers
This was complex. Trying to return back the AsyncSequence from AHC in a generic way until I found
AnyAsyncSequence
in AHC. This simplified passing the body back from AHC through my own types.AnyAsyncSequence
as a generic method for passing AsyncSequences about.ByteBufferAsyncSequence
as a way to convert aByteBuffer
into anAsyncSequence
ofByteBuffer
slices.HTTPBody
to hold response payloads. This'll probably be also used in requests but I haven't got to that yet. If so I'll rename back toAWSPayload
for some consistency. TheHTTPBody
no longer defines the type of data it holds (eg xml, json, raw data) this data is got from the serviceProtocolStreaming requests and response currently don't work, so related code and tests may be commented out