Skip to content

Commit

Permalink
updated type and added basic functionality of
Browse files Browse the repository at this point in the history
`polling_duration` configurability
  • Loading branch information
moreno-michael committed Mar 7, 2024
1 parent 76b4a3c commit 331074d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion crates/ott-common/src/discovery/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub struct DnsDiscoveryConfig {
pub dns_server: Option<String>,
/// The A record to query. If using docker-compose, this should be the service name for the monolith.
pub query: String,
/// The configurable polling discovery interval, in seconds.
pub polling_duration: Option<Duration>,
}

pub struct DnsServiceDiscoverer {
Expand Down Expand Up @@ -47,6 +49,9 @@ impl ServiceDiscoverer for DnsServiceDiscoverer {
}

fn mode(&self) -> DiscoveryMode {
DiscoveryMode::Polling(Duration::from_secs(10))
match self.config.polling_duration {
Some(polling_duration) => DiscoveryMode::Polling(polling_duration),
None => DiscoveryMode::Polling(Duration::from_secs(10)),
}
}
}
8 changes: 7 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 tracing::info;
use trust_dns_resolver::TokioAsyncResolver;

Expand All @@ -9,6 +10,8 @@ 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 discovery interval, in seconds.
pub polling_duration: Option<Duration>,
}

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

fn mode(&self) -> DiscoveryMode {
DiscoveryMode::Polling(Duration::from_secs(10))
match self.config.polling_duration {
Some(polling_duration) => DiscoveryMode::Polling(polling_duration),
None => DiscoveryMode::Polling(Duration::from_secs(10)),
}
}
}

0 comments on commit 331074d

Please sign in to comment.