message: applied review changes
diff: @@ -5,6 +5,21 @@ pub enum MetricOwner {
  Participant,
  }
  +impl From<&MetricOwner> for &'static str {
  + fn from(metric_owner: &MetricOwner) -> &'static str {
  + match metric_owner {
  + MetricOwner::Coordinator => "coordinator",
  + MetricOwner::Participant => "participant",
  + }
  + }
  +}
  +
  +impl ToString for MetricOwner {
  + fn to_string(&self) -> String {
  + Into::<&str>::into(self).into()
  + }
  +}
  +
  pub struct InfluxDBMetricStore {
  client: Client,
  }
  @@ -16,26 +31,19 @@ impl InfluxDBMetricStore {
  }
  }
  - fn metrics_owner_to_string(&self, metrics_owner: MetricOwner) -> &'static str {
  - match metrics_owner {
  - MetricOwner::Coordinator => "coordinator",
  - MetricOwner::Participant => "participant",
  - }
  - }
  -
  async fn write(&self, metrics_owner: MetricOwner, fields: Vec<(String, Type)>) -> () {
  let mut write_query: WriteQuery =
  - Query::write_query(Timestamp::Now, self.metrics_owner_to_string(metrics_owner));
  + Query::write_query(Timestamp::Now, metrics_owner.to_string());
  for (name, value) in fields {
  write_query = write_query.add_field(name, value);
  }
  // Submit the query to InfluxDB.
  - match self.client.query(&write_query).await {
  - Err(err) => eprintln!("{:?}", err),
  - _ => ()
  - };
  + self.client
  + .query(&write_query)
  + .await
  + .map_err(|e| error!("{}", e));
  }
  async fn write_with_tags(
  @@ -44,8 +52,7 @@ impl InfluxDBMetricStore {
  fields: Vec<(String, Type)>,
  tags: Vec<(String, String)>,
  ) -> () {
  - let mut write_query =
  - Query::write_query(Timestamp::Now, self.metrics_owner_to_string(metrics_owner));
  + let mut write_query = Query::write_query(Timestamp::Now, metrics_owner.to_string());
  for (name, value) in fields {
  write_query = write_query.add_field(name, value);
  @@ -56,10 +63,10 @@ impl InfluxDBMetricStore {
  }
  //Submit the query to InfluxDB.
  - match self.client.query(&write_query).await {
  - Err(err) => eprintln!("{:?}", err),
  - _ => ()
  - };
  + self.client
  + .query(&write_query)
  + .await
  + .map_err(|e| error!("{}", e));
  }
  }
  @@ -83,6 +90,8 @@ mod tests {
  let fields = vec![(String::from("CPU"), Type::SignedInteger(123))];
  let tags = vec![(String::from("ID"), String::from("1234-1234-1234-1234"))];
  - metric_store.write_with_tags(MetricOwner::Coordinator, fields, tags).await;
  + metric_store
  + .write_with_tags(MetricOwner::Coordinator, fields, tags)
  + .await;
  }
  }
  