Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This merges all options affecting the sync client (retry duration, crud throttle and client parameters) into a single object (
SyncOptions
) that can be passed toconnect()
. The old field for the retry duration and the independent parameters for throttling and client params have been deprecated in favor of those options.The main motivation for the options class is that we'll have additional options in the future (e.g. to control whether to use the Dart or the Rust sync client, or whether to use websockets vs. HTTP streams). Having these options all in one place makes it easier to expand them later.
This also applies some refactoring to the client, with a focus on how we handle aborting syncs and errors:
StreamingSyncImplementation
, connector methods are now grouped with an interface. The old callbacks didn't have the same name as the methods on the connector, which was confusing to me (e.g.invalidCredentialsCallback
should callprefetchCredentials
- not exactly obvious).addBroadcast
to also cancel all streams when one of them emits adone
event. Previously, we might leak subscriptions.null
to advance the sync iteration. I've introduced sealed classes to be more precise about the event advancing the iteration.StreamSubscription.cancel
? Doing that on the response stream will clean resources, and we can simply close the client afterwards. Thanks to fix number two, we can just close the "local ping" controller to cancel all source streams, which will make_streamingSyncIteration
break out of theawait for
loop after everything has been cleaned up. So we no longer have to close the HTTP client just to cancel the stream.