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

feat(core): allow to pause/resume query result observers #588

Merged
merged 16 commits into from
Sep 30, 2022

Conversation

sranka
Copy link
Contributor

@sranka sranka commented Sep 27, 2022

This PR allows pausing query results by returning false in the next callback of queryApi.queryLines and queryApi.queryRows consumer. The consumer must define useResume callback that receives a function that resumes receiving data when called. This feature adds a low-level (node.js stream) style of lossless backpressure to query result processing via communication observer.

Method signatures changed, the next callback of CommunicationObserver and FluxResultObserver can newly return also a boolean value, false value will stop processing. All these changes are backward compatible, no change is required for the existing code.

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • yarn test completes successfully
  • Commit messages are conventional

@sranka sranka marked this pull request as ready for review September 28, 2022 04:56
@sranka sranka requested a review from bednar September 28, 2022 04:56
@sranka sranka force-pushed the feat/query_result_backpressure branch from f37a49c to ba10b46 Compare September 30, 2022 05:33
@codecov-commenter
Copy link

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (ba10b46) compared to base (bb3a52b).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #588   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           33        33           
  Lines         1273      1333   +60     
  Branches       306       323   +17     
=========================================
+ Hits          1273      1333   +60     
Impacted Files Coverage Δ
packages/core/src/impl/browser/FetchTransport.ts 100.00% <100.00%> (ø)
...ges/core/src/impl/completeCommunicationObserver.ts 100.00% <100.00%> (ø)
packages/core/src/impl/node/NodeHttpTransport.ts 100.00% <100.00%> (ø)
packages/core/src/results/chunksToLines.ts 100.00% <100.00%> (ø)
packages/core/src/results/linesToTables.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@bednar bednar left a comment

Choose a reason for hiding this comment

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

LGTM 👍

What do you think about add new example which with pause/resume behaviour?

@sranka
Copy link
Contributor Author

sranka commented Sep 30, 2022

LGTM +1

What do you think about add new example which with pause/resume behaviour?

The ultimate goal is to switch to reading query results from an async iterable (in a simple for await loop), I am working on it now. All the query examples and demos will be changed to show primarily async iterables, the existing observable consumption of results will not be then a preferred result consumption method. Therefore I think that it can live without an example.

@sranka sranka merged commit d8ac54a into master Sep 30, 2022
@sranka sranka deleted the feat/query_result_backpressure branch September 30, 2022 13:52
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.

3 participants