feat(datasync): add chunk package for partitioned sync#19
Merged
Conversation
Remove the invented "extend if trailing gap < ChunkSize/2" heuristic and replace the Partitions method with the plain align+iterate+clamp algorithm used by para-sync. Fix all three affected test expectations: BasicWindow now uses now=midnight, LastChunkClampedToNow expects 3 partitions, and AlignsToCalendarMidnightInTimezone expects 2 partitions with the comment updated to document the corrected iteration.
Adds the ChunkedSync[In, Out, K] builder with all setters, Build() validation (panics on missing required fields), and a stub run() method returning an error — workflow logic follows in Tasks 13–15.
Extend chunkedSyncWorkflow.run to read cursor position via ReadCursor activity when hasTracker is set, filter out already-processed partitions, and advance cursor after each successful partition via AdvanceCursor.
…AsNew When maxPerExec > 0 and the partition list exceeds the limit, run() truncates to that many partitions and returns ContinueAsNewError so Temporal restarts the workflow for the remainder.
Wraps ChunkedSync[In, Out, int64] with a time.Time API. Internally, time.Time keys are projected onto Unix-nanosecond int64 keys via TimeToKey/KeyToTime. Introduces TimeFetcher and TimeProgressTracker local interface types to work around the cmp.Ordered constraint that time.Time cannot satisfy.
…erExec requires tracker Drop the unused [In any] type parameter from TimeProgressTracker and cascade the change through timeTrackerAdapter, WithTracker, and test stubs. Add a Build-time panic when MaxPartitionsPerExecution is set without WithTracker to prevent silent infinite re-processing loops. Add godoc to defaultCursorActivityOptions and MaxPartitionsPerExecution. Move cursorAdvCtx allocation outside the partition loop (avoid per-iteration re-alloc) using a distinct variable name to avoid shadowing. Add tests for the new MaxPerExec+tracker validation and the partitionSleep workflow path.
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
datasync/chunk/package withChunkedSync[In, Out, K]andDateChunkedSync[In, Out]builders for Temporal-backed partitioned-sync workflows (fetch → map → write per partition).datasync/internal/heartbeatpackage shared bydatasync/activityanddatasync/chunk.datasync/job.go,datasync/workflow/,datasync/builder/, or any caller. Para-sync is intentionally not modified — it will be migrated to consume the upstream package separately.Key design points
K cmp.Orderedfor partition keys;DateChunkedSyncwrapsK = int64(Unix nanos) so users keep atime.TimeAPI.ProgressTracker[K]for resumable syncs (cursor-based filtering + advance).MaxPartitionsPerExecution+ContinueAsNewto bound history for large partition lists. Validated atBuild()time — panics if set without a tracker.starting/fetching/mapping/writing) via the sharedinternal/heartbeatpackage.WithRateLimitRetrydecorator +HeartbeatSleeperported from para-sync.Spec & plan
docs/superpowers/specs/2026-05-10-datasync-chunk-design.mddocs/superpowers/plans/2026-05-10-datasync-chunk.mdTest plan
task ci:test— unit, 24 packages greentask test:integration— integration, 25 packages green,datasync/chunkat 88% coverage; new filedatasync/chunk/sync_integration_test.gospawns a real Temporal container viatestutil.StartTemporalContainertask lint— cleanexamples/datasync/chunk_basic.gobuilds under-tags=example