Skip to content
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 NIOThrowingAsyncSequenceProducer #317

Merged
merged 6 commits into from
Oct 26, 2022

Conversation

fabianfett
Copy link
Collaborator

@fabianfett fabianfett commented Oct 26, 2022

Motivation

We should use components from NIO where possible and not rely on our own. Learnings from PostgresNIO have influenced the new very shiny NIOThrowingAsyncSequenceProducer. We should adopt sooner rather than later.

Changes

  • Use NIOThrowingAsyncSequenceProducer and drop our own AsyncStreamConsumer

Result

We support task cancellation on iterator.next()

Copy link
Member

@gwynne gwynne left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov-commenter
Copy link

codecov-commenter commented Oct 26, 2022

Codecov Report

Merging #317 (4e35c66) into main (a365a9b) will decrease coverage by 1.75%.
The diff coverage is 92.95%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #317      +/-   ##
==========================================
- Coverage   43.52%   41.76%   -1.76%     
==========================================
  Files         115      115              
  Lines        9763     9408     -355     
==========================================
- Hits         4249     3929     -320     
+ Misses       5514     5479      -35     
Flag Coverage Δ
unittests 41.76% <92.95%> (-1.76%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
Sources/PostgresNIO/New/Messages/DataRow.swift 95.38% <ø> (ø)
Sources/PostgresNIO/New/PSQLRowStream.swift 84.67% <89.13%> (+0.13%) ⬆️
Sources/PostgresNIO/New/PostgresRowSequence.swift 89.06% <100.00%> (-0.67%) ⬇️

Copy link
Contributor

@FranzBusch FranzBusch left a comment

Choose a reason for hiding this comment

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

Nice! Glad this all worked out perfectly. I left a small comment inline

case .asyncSequence(let consumer, let dataSource):
let error = PSQLError.connectionClosed
case .asyncSequence(let source, let dataSource):
let error = CancellationError()
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't fully agree with the usage of CancellationError here. It should only get thrown if the task is cancelled; however, in your code path it code be thrown when the source terminated the sequence where this would be quite confusing for the user. In general, you don't have to call source.finish as a result of didTerminate at all.

@fabianfett fabianfett merged commit 7daf026 into vapor:main Oct 26, 2022
@fabianfett fabianfett deleted the ff-nio-async-sequence2 branch October 26, 2022 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants