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

fix: use tokio::time::Interval for scheduling anchor batches #563

Merged
merged 5 commits into from
Oct 16, 2024

Conversation

nathanielc
Copy link
Collaborator

This leverages the time math of skipping missed ticks etc. We are only left with computing the time when we should start the first tick. For this we use chrono and then rely on Interval for the heavy lifting.

This leverages the time math of skipping missed ticks etc. We are only
left with computing the time when we should start the first tick. For
this we use chrono and then rely on Interval for the heavy lifting.
@nathanielc nathanielc requested review from AaronGoldman and a team as code owners October 16, 2024 19:31
@nathanielc nathanielc requested review from sam701 and removed request for a team October 16, 2024 19:31
@@ -76,28 +77,42 @@ impl AnchorService {
pin_mut!(shutdown_signal);

info!("anchor service started");
let period =
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick, but could we pull all this logic for building the interval into a helper function to improve readability?

@@ -76,28 +77,42 @@ impl AnchorService {
pin_mut!(shutdown_signal);

info!("anchor service started");
let period =
TimeDelta::from_std(self.anchor_interval).expect("anchor interval should be in range");
let buffer = period / 12;
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is buffer doing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

its the buffer time we give ourselves to actually process the batch. I'll add a comment. For 1hour it ends up being 5 minutes.

Copy link
Collaborator

@smrz2001 smrz2001 left a comment

Choose a reason for hiding this comment

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

🚀

@nathanielc nathanielc added this pull request to the merge queue Oct 16, 2024
Merged via the queue into main with commit e42df1a Oct 16, 2024
5 checks passed
@nathanielc nathanielc deleted the fix/use-interval-anchor-batches branch October 16, 2024 22:02
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.

3 participants