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

allow discovery polling interval to be configurable #1459

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/ott-balancer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ futures-util.workspace = true
hyper.workspace = true
hyper-util.workspace = true
http-body-util.workspace = true
humantime-serde.workspace = true
jemallocator.workspace = true
rand.workspace = true
reqwest.workspace = true
Expand Down
9 changes: 8 additions & 1 deletion crates/ott-common/src/discovery/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ pub struct DnsDiscoveryConfig {
pub dns_server: Option<SocketAddr>,
/// The A record to query. If using docker-compose, this should be the service name for the monolith.
pub query: String,
/// The configurable polling mode discovery interval, in seconds.
dyc3 marked this conversation as resolved.
Show resolved Hide resolved
#[serde(with = "humantime_serde")]
pub polling_interval: Option<Duration>,
}

pub struct DnsServiceDiscoverer {
Expand Down Expand Up @@ -59,7 +62,11 @@ impl ServiceDiscoverer for DnsServiceDiscoverer {
}

fn mode(&self) -> DiscoveryMode {
DiscoveryMode::Polling(Duration::from_secs(10))
DiscoveryMode::Polling(
self.config
.polling_interval
.unwrap_or_else(|| Duration::from_secs(10)),
)
}
}
#[cfg(test)]
Expand Down
10 changes: 9 additions & 1 deletion crates/ott-common/src/discovery/fly.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use async_trait::async_trait;
use serde::Deserialize;
use hickory_resolver::TokioAsyncResolver;
use tracing::info;

Expand All @@ -9,6 +10,9 @@ pub struct FlyDiscoveryConfig {
/// The port that monoliths should be listening on for load balancer connections.
pub service_port: u16,
pub fly_app: String,
/// The configurable polling mode discovery interval, in seconds.
dyc3 marked this conversation as resolved.
Show resolved Hide resolved
#[serde(with = "humantime_serde")]
pub polling_interval: Option<Duration>,
}

pub struct FlyServiceDiscoverer {
Expand Down Expand Up @@ -46,6 +50,10 @@ impl ServiceDiscoverer for FlyServiceDiscoverer {
}

fn mode(&self) -> DiscoveryMode {
DiscoveryMode::Polling(Duration::from_secs(10))
DiscoveryMode::Polling(
self.config
.polling_interval
.unwrap_or_else(|| Duration::from_secs(10)),
)
}
}
Loading