Skip to content

Commit c796217

Browse files
made suggested changes, working on resolving
compiler issues
1 parent 89212db commit c796217

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

crates/ott-balancer/src/discovery.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::{collections::HashSet, net::SocketAddr};
77
mod fly;
88
mod harness;
99
mod manual;
10+
mod dns;
1011

1112
pub use fly::*;
1213
pub use harness::*;

crates/ott-balancer/src/discovery/dns.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,35 @@ use trust_dns_resolver::TokioAsyncResolver;
55
use super::*;
66

77
#[derive(Debug, Clone, Deserialize)]
8-
pub struct DockerDiscoveryConfig {
8+
pub struct DnsDiscoveryConfig {
99
/// The port that monoliths should be listening on for load balancer connections.
1010
pub monolith_port: u16,
1111
pub dns_server: Option<String>,
12+
pub query: String
1213
}
1314

14-
pub struct DockerMonolithDiscoverer {
15-
config: DockerDiscoveryConfig,
16-
query: Option<String>,
15+
pub struct DnsMonolithDiscoverer {
16+
config: DnsDiscoveryConfig,
1717
}
1818

19-
impl DockerMonolithDiscoverer {
20-
pub fn new(config: DockerDiscoveryConfig) -> Self {
19+
impl DnsMonolithDiscoverer {
20+
pub fn new(config: DnsDiscoveryConfig) -> Self {
2121
info!(
2222
"Creating DockerMonolithDiscoverer, Docker DNS server: {}",
23-
&config.docker_dns_server
23+
dns_server
2424
);
2525
let query = format!("{}", &config.dns_server);
26-
Self { config, query }
26+
Self { config }
2727
}
2828
}
2929

3030
#[async_trait]
31-
impl MonolithDiscoverer for DockerMonolithDiscoverer {
31+
impl MonolithDiscoverer for DnsMonolithDiscoverer {
3232
async fn discover(&mut self) -> anyhow::Result<Vec<MonolithConnectionConfig>> {
3333
let resolver =
3434
TokioAsyncResolver::tokio_from_system_conf().expect("failed to create resolver");
3535

36-
let lookup = resolver.ipv4_lookup(&self.query).await?;
36+
let lookup = resolver.ipv4_lookup(&self).await?;
3737
let monoliths = lookup
3838
.iter()
3939
.map(|ip| MonolithConnectionConfig {

0 commit comments

Comments
 (0)