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

Refactor time.rs to make the code logic the same as others. #347

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Dirreke
Copy link
Contributor

@Dirreke Dirreke commented Feb 11, 2024

  • Delete struct TimeTriggerConfig for lib without config_parsing feature.
  • Transfer time trigger initialization to the first trigger() execution

@Dirreke Dirreke requested review from estk and gadunga as code owners February 11, 2024 16:55
@codecov-commenter
Copy link

codecov-commenter commented Feb 11, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 88.57143% with 4 lines in your changes missing coverage. Please review.

Project coverage is 63.68%. Comparing base (f688e38) to head (d0d35b8).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ppend/rolling_file/policy/compound/trigger/time.rs 88.57% 4 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #347      +/-   ##
==========================================
+ Coverage   63.42%   63.68%   +0.26%     
==========================================
  Files          25       25              
  Lines        1572     1589      +17     
==========================================
+ Hits          997     1012      +15     
- Misses        575      577       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@bconn98 bconn98 left a comment

Choose a reason for hiding this comment

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

Couple questions, but otherwise looks good

@bconn98
Copy link
Collaborator

bconn98 commented Feb 16, 2024 via email

bconn98
bconn98 previously approved these changes Feb 16, 2024
bconn98
bconn98 previously approved these changes Mar 8, 2024
@bconn98 bconn98 enabled auto-merge (squash) March 8, 2024 02:55
@bconn98
Copy link
Collaborator

bconn98 commented Mar 9, 2024

Looks like chronic changed their time interface. Can you fix that well you're already in there for this PR? @Dirreke

@Dirreke
Copy link
Contributor Author

Dirreke commented Mar 9, 2024

Which choice do you prefer if the duration time as millis exceed i64::MAX?
return panic? or just use i64::MAX.

auto-merge was automatically disabled March 9, 2024 16:22

Head branch was pushed to by a user without write access

@bconn98
Copy link
Collaborator

bconn98 commented Mar 9, 2024

Let’s return an error, similar to how the size trigger does it

@Dirreke Dirreke force-pushed the refactor-timetrigger branch from eb9a7bd to 1db6e18 Compare March 9, 2024 16:25
@Dirreke
Copy link
Contributor Author

Dirreke commented Mar 9, 2024

I will fix it tomorrow.

@Dirreke Dirreke force-pushed the refactor-timetrigger branch from 1db6e18 to 0b8f045 Compare March 10, 2024 04:09
Copy link
Collaborator

@bconn98 bconn98 left a comment

Choose a reason for hiding this comment

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

Please make sure to bump the minimum required chrono.

src/append/rolling_file/policy/compound/trigger/time.rs Outdated Show resolved Hide resolved
@Dirreke Dirreke force-pushed the refactor-timetrigger branch from 1db83e0 to df5e6a5 Compare March 11, 2024 06:08
bconn98
bconn98 previously approved these changes Mar 12, 2024
Copy link
Collaborator

@bconn98 bconn98 left a comment

Choose a reason for hiding this comment

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

Great work! 🎉

@Hellager
Copy link

Is there any progress about this PR?

@bconn98
Copy link
Collaborator

bconn98 commented Mar 27, 2024

I’m communicating with the repo owner to get this merged in. It’s g2g from me.

@Hellager
Copy link

Got it, hopes it will be soon and thanks for your great work.

next_time + Duration::seconds(random_delay as i64)
} else {
next_time
};
Copy link
Owner

Choose a reason for hiding this comment

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

Why was this deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can I close this consersation?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The answer to this is tied into the "wondering" question. Lets wait until estk is back next week. Let's target issues first for future efforts to ensure implications and impacts are considered up front.

let result = time
+ Duration::try_hours(increment)
.ok_or(TimeTrigerError::TooLargeInterval(interval))?;
return Ok(result);
Copy link
Owner

Choose a reason for hiding this comment

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

Please refactor this and other instances into a helper function:

let dur = try_from_hours(increment)?;
return Ok(time + dur);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about using macros?

@estk
Copy link
Owner

estk commented Apr 1, 2024

Wondering the reason for this:

Transfer time trigger initialization to the first trigger() execution

@Dirreke
Copy link
Contributor Author

Dirreke commented Apr 1, 2024

If we build it in program instead of config file, we have to build TimeTrigger first before initiating builder. The time recorded should be the time when the first log message is written but not the time when TimeTrigger be built.
Another reason is just that I want to keep it the same as the onstartup trigger.

@Dirreke Dirreke force-pushed the refactor-timetrigger branch from df5e6a5 to 0e56e18 Compare April 1, 2024 17:26
@Dirreke Dirreke force-pushed the refactor-timetrigger branch 2 times, most recently from 29d8dbd to e475695 Compare April 2, 2024 09:12
@carlocorradini
Copy link

Awesome, any update? 🥳

@bconn98
Copy link
Collaborator

bconn98 commented Apr 18, 2024

@carlocorradini The owner of the repo requested that we break up this PR into separate pieces.

  1. Fix the deprecated API fix: replace deprecated API in chrono 0.4.35 for converting to time #367. This is waiting on getting the owners time again to review.
  2. Move when the trigger is initialized.
  3. Refactor the code to include making the config field public.

This will allow the changes to be analyzed independently and makes the impact of each change more easily tracked. @Dirreke Have you been able to work on breaking number 2 out into a separate PR?

@Dirreke
Copy link
Contributor Author

Dirreke commented Apr 18, 2024

Thanks for that. However, I'm a little busy these days. Maybe I will do it next week. Or maybe I can rebase it after #367 merged

@carlocorradini
Copy link

Firstly, awesome 😎
And... What do you think if we use the builder pattern to populate the fields in config?

@Dirreke
Copy link
Contributor Author

Dirreke commented May 3, 2024

2. Move when the trigger is initialized.

Task 2 has a lot of code related to task 1. I'd like to finish it after #367 is merged.

For Issue #370, I open #372 to provide a quick PR to solve it.

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.

6 participants