Use MissedTickBehavior::Delay for updating crates.io-index (#161)

This commit is contained in:
Paolo Barbolini 2022-08-14 22:48:09 +02:00 committed by GitHub
parent cf7513873b
commit bacc736364
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,7 +8,7 @@ use crates_index::Crate;
use crates_index::Index; use crates_index::Index;
use slog::{error, Logger}; use slog::{error, Logger};
use tokio::task::spawn_blocking; use tokio::task::spawn_blocking;
use tokio::time; use tokio::time::{self, MissedTickBehavior};
#[derive(Clone)] #[derive(Clone)]
pub struct ManagedIndex { pub struct ManagedIndex {
@ -31,6 +31,7 @@ impl ManagedIndex {
pub async fn refresh_at_interval(&self, update_interval: Duration) { pub async fn refresh_at_interval(&self, update_interval: Duration) {
let mut update_interval = time::interval(update_interval); let mut update_interval = time::interval(update_interval);
update_interval.set_missed_tick_behavior(MissedTickBehavior::Delay);
loop { loop {
if let Err(e) = self.refresh().await { if let Err(e) = self.refresh().await {