Add non-breaking async callback surface to uSyncCallbacks - #1049
Merged
Conversation
The uSyncCallbacks delegates (Callback, Update, SetRange, IncrementalUpdate, Complete) were void, which forced consumers like uSync.Complete's LocalHubClient/PublisherHubClient to .Wait() on every SignalR send. Add optional async counterparts (CallbackAsync, UpdateAsync, SetRangeAsync, IncrementalUpdateAsync, CompleteAsync) alongside the existing sync delegates, plus Raise*Async helper methods that invoke the sync delegate then await the async one if set. Existing constructors, properties and delegate types are untouched, so this is purely additive. Update the call sites that invoke callbacks directly off a uSyncCallbacks instance (SyncService, SyncService_Single, SyncActionService, SyncHandlerRoot, uSyncManagementService) to await the new Raise*Async helpers. Call sites that extract the raw SyncUpdateCallback delegate to pass into the public ISyncHandler.ExportAllAsync/ReportAsync interface are left untouched, since changing that interface would be a breaking change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
uSyncCallbacks' delegates (Callback,Update,SetRange,IncrementalUpdate,Complete) arevoid, which forces consumers like uSync.Complete'sLocalHubClient/PublisherHubClientto.Wait()on every SignalR send. Adds optional async counterparts (CallbackAsync,UpdateAsync,SetRangeAsync,IncrementalUpdateAsync,CompleteAsync) that can be set alongside the existing sync ones.Raise*Asynchelper methods onuSyncCallbacksthat invoke the sync delegate then await the async one if set, so callers get one call site regardless of which style a consumer wired up.uSyncCallbacksare untouched — this is purely additive, so it's non-breaking for anything currently calling into it.uSyncCallbacksinstance (SyncService,SyncService_Single,SyncActionService,SyncHandlerRoot,uSyncManagementService) toawaitthe newRaise*Asynchelpers instead of firing the sync delegate directly.Not changed (deliberately)
Call sites that extract the raw
SyncUpdateCallbackdelegate to pass into the publicISyncHandler.ExportAllAsync/ReportAsyncinterface (andSyncMergeOptions/CreateNotificationScope) are left as-is, since changing those public signatures would be a breaking change. This is a follow-up from investigating the "CreateRestorePoint timeout after v17 upgrade" issue — see uSync.Complete PR 178 — and unblocks wiring real per-item/progress callbacks into restore-point export without forcing a blocking.Wait()per SignalR message.Test plan
dotnet build uSync.slnx— succeeds, no new warnings/errorsdotnet test uSync.Tests/uSync.Tests.csproj— 141/141 passing