Add _example/download CLI: curl-like downloader with SIGUSR1 rate toggle#13
Merged
Conversation
The CLI takes a URL, --default-rate-limit and --lower-rate-limit (k/M/G units, 0 = pause), and an output file. It downloads the URL while printing a single-line progress display (downloaded/total, percent, instantaneous rate, current mode, ETA) updated every 200ms. SIGUSR1 flips the limit between the default and lower rates at runtime via SetRateLimit, demonstrating the dynamic-rate API end-to-end. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: fujiwara <fujiwara.shunichiro@gmail.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: fujiwara <fujiwara.shunichiro@gmail.com>
Make it obvious how to toggle the rate while a download is running. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: fujiwara <fujiwara.shunichiro@gmail.com>
The previous snippet only showed SetRateLimit; users couldn't tell that ReadCloser, SetRateLimitEvery, and dynamic rate changes (incl. pausing with 0) existed without scrolling. Replace it with a single short example that exercises all three, and point at example/download for a runnable CLI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: fujiwara <fujiwara.shunichiro@gmail.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: fujiwara <fujiwara.shunichiro@gmail.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: fujiwara <fujiwara.shunichiro@gmail.com>
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
_example/download/main.go: a small CLI that downloads a URL to a file.--default-rate-limit/--lower-rate-limitacceptk/M/Gunits;0means "pause".SIGUSR1toggles between default and lower rates at runtime (demonstrates the new dynamic-rate API).downloaded/total (pct) @ inst-rate [mode set=N/s] ETA Ns.Why
The library now supports dynamic rate changes, paused state (rate=0), and ReadCloser. This example exercises all three end-to-end in a recognizable, curl-like shape, so users can copy the pattern.