feat(CLI): add --parallel flag to phrase pull for concurrent downloads#1067
Merged
Sven Dunemann (forelabs) merged 2 commits intophrase:mainfrom Apr 1, 2026
Merged
Conversation
e4541d8 to
2fa4000
Compare
2fa4000 to
512d21d
Compare
jablan
reviewed
Mar 26, 2026
Collaborator
jablan
left a comment
There was a problem hiding this comment.
looks really solid to me, a non-go developer. I have a question regarding the tests though.
jablan
approved these changes
Mar 26, 2026
Collaborator
jablan
left a comment
There was a problem hiding this comment.
Thibaut Etienne (@tetienne) thanks a lot! we're going to merge it only on Monday, though. I presume you are already using your home baked version?
Contributor
Author
|
jablan not on our main ci but locally I played with it yes |
Member
|
Thibaut Etienne (@tetienne) due to the merge of #1066 we have conflicts on this PR now. Thank you a lot for your contribution! Would you mind resolving the conflicts? We appreciate your support ❤️ |
Download locale files using up to 4 concurrent requests (matching the Phrase API concurrency limit) via errgroup. Results are collected and printed in order after all downloads complete for clean output. A shared mutex coordinates rate-limit pauses across all workers. Only supported in sync mode; --parallel with --async warns and ignores.
Drop TestRateGate_* tests that only verified sync.RWMutex standard library behavior without testing any PR code.
d267fac to
56eed2c
Compare
Contributor
Author
|
Sven Dunemann (@forelabs) Many thanks for this. I have updated my PR to resolve the conflicts. |
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.
We run
phrase pullin CI pipelines with 379 locale files across 3 projects. Sequential downloads take over a minute per run, and the latency adds up across branches and environments. This PR adds parallel downloads to dramatically reduce pull time.Pairs well with #1066 (
--cachefor ETag-based conditional requests): parallel mode makes the initial pull fast, and caching makes subsequent pulls nearly free by returning 304 Not Modified (which don't count against rate limits).Summary
--parallelflag (-p) tophrase pullthat downloads locale files using up to 4 concurrent requests (matching the Phrase API concurrency limit)errgroupwithSetLimit(4)for bounded parallelism--parallelwith--asyncwarns and ignoresbuildDownloadOptshelper to eliminate code duplication between sequential and parallel pathsUsage
Real-world results
Tested against a production project with 379 locale files across 3 Phrase projects:
phrase pullphrase pull --parallelDesign decisions
errgroupwithSetLimit: Standard Go concurrency pattern. Provides bounded parallelism, fail-fast error propagation via context cancellation, and cleanWait()semantics.buildDownloadOpts: Extracted the download options preparation (params, file format, tags) into a helper used by both sequential and parallel paths, eliminating ~20 lines of duplication.context.WithTimeoutmatching the existing 30-minute timeout from the sequential path.Test plan
go build ./cmd/internal/...compilesgo test ./cmd/internal/...passesgo vet ./cmd/internal/cleanphrase pull --paralleldownloads 379 files in 11.5sphrase pullwithout--parallelbehaves identicallyphrase pull --parallel --asyncwarns and ignores parallel