Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

feat: Add generic progress emitter utility #141

Merged
merged 2 commits into from
Feb 14, 2023
Merged

Conversation

flub
Copy link
Contributor

@flub flub commented Feb 13, 2023

This adds a generic utility which can be used to track progress of
data transfers by emitting progress via a tokio broadcast channel.

This is extracted from the deltachat PR:
chatmail/core#4007

This adds a generic utility which can be used to track progress of
data transfers by emitting progress via a tokio broadcast channel.
@flub flub self-assigned this Feb 13, 2023
@flub flub added this to the v0.1.0 milestone Feb 13, 2023
@flub flub added the feature New feature or request label Feb 13, 2023
@flub flub requested a review from dignifiedquire February 13, 2023 17:37
/// The emitter expects to see *total* being added via [`ProgressEmitter::inc`] and will
/// emit *steps* updates.
pub fn new(total: u64, steps: u16) -> Self {
let (tx, _rx) = broadcast::channel(16);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this 16 be configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My opiniated answer is: no. At least not until someone has a good usecase.

My reasoning:

Firstly, you should be able to keep up: spawn a task.

Secondly it is only a progress report. If you happen to hit the RecvErr::Lagged branch you still have access to the most up to date progress. The historical progress updates are not really useful anymore, there is not event a timestamp associated with them.

Copy link
Collaborator

@dignifiedquire dignifiedquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@flub flub merged commit d09a786 into main Feb 14, 2023
@flub flub deleted the flub/progress-emitter branch February 14, 2023 12:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New feature or request
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants