Skip to content

Commit

Permalink
Move to using interval
Browse files Browse the repository at this point in the history
This way our Introspection watching works as well
as watching schema files.
  • Loading branch information
jonathanrainer committed Aug 29, 2024
1 parent 44348e8 commit 360fb26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/rover-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ camino = { workspace = true }
console = { workspace = true }
notify = { workspace = true }
notify-debouncer-full = { workspace = true }
tokio = { workspace = true, features = ["rt-multi-thread", "rt"]}
tokio = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
url = { workspace = true }
Expand Down
5 changes: 4 additions & 1 deletion src/command/dev/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use anyhow::{anyhow, Context};
use apollo_federation_types::build::SubgraphDefinition;
use camino::{Utf8Path, Utf8PathBuf};
use reqwest::Client;
use tokio::time::MissedTickBehavior::Delay;
use url::Url;

use rover_client::blocking::StudioClient;
Expand Down Expand Up @@ -283,11 +284,13 @@ impl SubgraphSchemaWatcher {
_ => "seconds",
}
);
let mut interval = tokio::time::interval(Duration::from_secs(polling_interval));
interval.set_missed_tick_behavior(Delay);
loop {
last_message = self
.update_subgraph(last_message.as_ref(), retry_period)
.await?;
tokio::time::sleep(std::time::Duration::from_secs(polling_interval)).await;
interval.tick().await;
}
}
SubgraphSchemaWatcherKind::File(path) => {
Expand Down

0 comments on commit 360fb26

Please sign in to comment.