-
-
Notifications
You must be signed in to change notification settings - Fork 15
feat: Add Duration::from_minutes, hours and days #657
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
Conversation
@Techassi @nightkr so, what is the plan here? I see the following options
Both 2. and 3. would work for me. I don't have enough Rust const knowledge, but my understanding is that Option 2. comes with a panic!() in case the Duration overflows. This is the same way What would be your preferred Option? |
I agree that this is quite tedious.
A panic is necessary, because
This would need some more research (I would volunteer for that if we decide to move forward with it). Additionally, we have to maintain the macro code. This sometimes can get a little tricky, but this macro would probably be easy enough to maintain. We can also choose to move forward using a "middle-ground" solution like exporting public constants like: pub const ONE_MINUTE_IN_SECS: u64 = 60;
pub const ONE_HOUR_IN_SECS: u64 = ONE_MINUTE_IN_SECS * 60;
pub const ONE_DAY_IN_SECS: u64 = ONE_HOUR_IN_SECS * 24;
// In operator code
use stackable_operator::duration::{Duration, ONE_DAY_IN_SECS};
pub const TLS_CERT_LIFETIME = Duration::from_secs(365 * ONE_DAY_IN_SECS); |
As I've written before, my primary concern is that making it too convenient to write long durations.. encourages people to use more long durations where doing so is largely an antipattern or just puts a band-aid over a bigger issue. |
I don't think the time periods are going to change based upon the presence or absence of an |
During todays architecture meeting we decided to go ahead with this feature (not necessarily this implementation). |
@siegfriedweber, @Techassi and I did go though the PR and reached a conclusion. |
Co-authored-by: Siegfried Weber <mail@siegfriedweber.net>
Co-authored-by: Techassi <git@techassi.dev>
b2ccbbd
to
fd0b0d4
Compare
Description
Please add a description here. This will become the commit message of the merge request later.
Definition of Done Checklist