-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: zinniad
for Filecoin Station
#141
Conversation
Implement a new binary `zinniad` that can run multiple modules at the same time and acts as another Filecoin Station Module. Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
self.tracker | ||
.borrow_mut() | ||
.job_completed(|n| self.print_jobs_completed(n)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.tracker | |
.borrow_mut() | |
.job_completed(|n| self.print_jobs_completed(n)); | |
self.print_jobs_completed(self.tracker | |
.borrow_mut() | |
.job_completed()); |
API question: Is a closure the way to go, or could we simply return the value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I want to log the message only if it's at least 500ms since we printed the message for the last time.
I suppose I could change job_completed()
and flush()
function to return a tuple (job_count: u64, should_log: bool)
and let the caller handle should_log
.
let (job_count, should_log) = self.tracker.borrow_mut().job_completed();
if should_log { self.print_jobs_completed(job_count); }
Do you find this version easier to understand and work with?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I want to log the message only if it's at least 500ms since we printed the message for the last time.
Meaning that if we call reporter.job_completed
twice within 500ms, the first call will trigger calling the printer closure but the second call will not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, returning (job_count, should_log)
would not work well. The tracker will not know whether it should reset the timer or not. It can reset the timer every time job_completed
returns should_log = true
, but that relies on the caller logging the message when told so. I find that brittle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah gotcha, I didn't know the closure was being called optionally. That works 👍
Implement a new binary
zinniad
that can run multiple modules at the same time and acts as another Filecoin Station Module.See #75
Out of Scope
Usage
In Action
Raw stdout (ND-JSON):
Raw stderr - notice that Console logs are printed via Rust logging API, annotated with module name and timestamp: