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 structured concurrency for sync jobs #157

Merged
merged 8 commits into from
Mar 31, 2025
Merged

Conversation

simolus3
Copy link
Contributor

@simolus3 simolus3 commented Mar 27, 2025

The jobs to download and upload data (as well as the one forwarding sync status changes) are all operating independently from each other, which can potentially cause issues stopping these jobs as once.

This adopts a SupervisorJob for the three, allowing us to cancel just one job in disconnect that's guaranteed to get them all.

I've also slightly refactored our test client so that it properly forwards cancellations (when we cancel the sync jobs, that propagates to SyncStream.streamingSyncRequest in the request.execute block). With the mock HTTP engine from ktor we unfortunately have no access to that scope, but by implementing a fairly trivial custom engine we can implement the same functionality while also reporting downstream listeners being cancelled.
This then allows testing that calling disconnect() or close() on a database does indeed close the underlying HTTP response stream.

@simolus3 simolus3 marked this pull request as ready for review March 31, 2025 08:00
stevensJourney
stevensJourney previously approved these changes Mar 31, 2025
Copy link
Contributor

@stevensJourney stevensJourney left a comment

Choose a reason for hiding this comment

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

LGTM

@simolus3 simolus3 merged commit ad5e6b3 into main Mar 31, 2025
3 checks passed
@simolus3 simolus3 deleted the single-scope-for-sync-jobs branch March 31, 2025 11:37
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.

2 participants