Skip to content

belatedly address Ben's code review feedback #395

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

Merged
merged 1 commit into from
Nov 16, 2021
Merged
Changes from all 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
26 changes: 7 additions & 19 deletions nexus/src/nexus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ impl Nexus {
"n_producers" => producers.len(),
"collector_id" => ?oximeter_info.collector_id,
);
let (client, _) = self.build_oximeter_client(
oximeter_info.collector_id,
let client = self.build_oximeter_client(
&oximeter_info.collector_id,
oximeter_info.address,
);
for producer in producers.into_iter() {
Expand Down Expand Up @@ -316,26 +316,13 @@ impl Nexus {
.expect("expected an infinite retry loop registering nexus as a metric producer");
}

/// Return a client to the Oximeter instance with the given ID.
pub async fn oximeter_client(
&self,
id: Uuid,
) -> Result<(OximeterClient, Uuid), Error> {
let oximeter_info = self.db_datastore.oximeter_fetch(id).await?;
let address = SocketAddr::new(
oximeter_info.ip.ip(),
oximeter_info.port.try_into().unwrap(),
);
Ok(self.build_oximeter_client(oximeter_info.id, address))
}

// Internal helper to build an Oximeter client from its ID and address (common data between
// model type and the API type).
fn build_oximeter_client(
&self,
id: Uuid,
id: &Uuid,
address: SocketAddr,
) -> (OximeterClient, Uuid) {
) -> OximeterClient {
let client_log =
self.log.new(o!("oximeter-collector" => id.to_string()));
let client =
Expand All @@ -345,7 +332,7 @@ impl Nexus {
"registered oximeter collector client";
"id" => id.to_string(),
);
(client, id)
client
}

/**
Expand Down Expand Up @@ -2142,7 +2129,8 @@ impl Nexus {
})?;
let address =
SocketAddr::from((info.ip.ip(), info.port.try_into().unwrap()));
Ok(self.build_oximeter_client(info.id, address))
let id = info.id;
Ok((self.build_oximeter_client(&id, address), id))
}

pub async fn session_fetch(
Expand Down