feat(CLI): add --parallel flag to phrase pull for concurrent downloads#1067
Open
Thibaut Etienne (tetienne) wants to merge 1 commit intophrase:mainfrom
Open
feat(CLI): add --parallel flag to phrase pull for concurrent downloads#1067Thibaut Etienne (tetienne) wants to merge 1 commit intophrase:mainfrom
Thibaut Etienne (tetienne) wants to merge 1 commit intophrase:mainfrom
Conversation
e4541d8 to
2fa4000
Compare
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.
2fa4000 to
512d21d
Compare
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