Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Progress and ProgressReader types #10

Merged
merged 1 commit into from
Nov 15, 2022
Merged

add Progress and ProgressReader types #10

merged 1 commit into from
Nov 15, 2022

Conversation

aead
Copy link
Owner

@aead aead commented Nov 15, 2022

This commit adds two new types for measuring
progress of I/O operations.

A Progress represents the status of an I/O
operation. It contains the number of bytes
read since the last progress reporting, the
number of bytes processed in total so far and
a potential error.

The ProgressReader wraps an io.Reader and
sends progress updates to its Update callback.
By default, it calls the Update callback after
every completed read. However, users can specify:

  • an UpdateAfter size causing the ProgressReader to invoke the callback once it has read at least UpdateAfter bytes since the last update.
  • an UpdateEvery duration causing the ProgressReader to invoke the callback only if no update has happened for at least UpdateEvery time period.

@aead aead force-pushed the progress branch 7 times, most recently from 2f93ee1 to 826d688 Compare November 15, 2022 14:14
This commit adds two new types for measuring
progress of I/O operations.

A `Progress` represents the status of an I/O
operation. It contains the number of bytes
read since the last progress reporting, the
number of bytes processed in total so far and
a potential error.

The `ProgressReader` wraps an `io.Reader` and
sends progress updates to its `Update` callback.
By default, it calls the `Update` callback after
every completed read. However, users can specify:
 - an `UpdateAfter` size causing the `ProgressReader`
   to invoke the callback once it has read at least
   `UpdateAfter` bytes since the last update.
 - an `UpdateEvery` duration causing the `ProgressReader`
   to invoke the callback only if no update has happened
   for at least `UpdateEvery` time period.

Signed-off-by: Andreas Auernhammer <hi@aead.dev>
@aead aead merged commit ae5340e into main Nov 15, 2022
@aead aead deleted the progress branch November 15, 2022 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant