Skip to content

Commit

Permalink
Obey clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Darach Ennis <darach@gmail.com>
  • Loading branch information
darach committed Jan 12, 2023
1 parent 6696089 commit 3a92a43
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 28 deletions.
16 changes: 8 additions & 8 deletions src/connectors/google.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ type TonicInternalBodyType = UnsyncBoxBody<bytes::Bytes, tonic::Status>;
impl Display for TremorTonicServiceError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match *self {
Self::HyperError(ref err) => write!(f, "Hyper error: {}", err),
Self::TonicStatus(ref status) => write!(f, "Tonic error: {}", status),
Self::TonicTransportError(ref err) => write!(f, "Tonic transport error: {}", err),
Self::GoogleAuthError(ref err) => write!(f, "Google Auth error: {}", err),
Self::GoogleCredentialsError(ref err) => write!(f, "Google Credentials error: {}", err),
Self::HyperError(ref err) => write!(f, "Hyper error: {err}"),
Self::TonicStatus(ref status) => write!(f, "Tonic error: {status}"),
Self::TonicTransportError(ref err) => write!(f, "Tonic transport error: {err}"),
Self::GoogleAuthError(ref err) => write!(f, "Google Auth error: {err}"),
Self::GoogleCredentialsError(ref err) => write!(f, "Google Credentials error: {err}"),
}
}
}
Expand Down Expand Up @@ -230,8 +230,8 @@ impl TremorGoogleAuthz {
}

// Create a new mock channel to a GCP gRPC service
pub async fn new_mock(logic: MockServiceRpcCall) -> Result<Self> {
Ok(Self::Test(TonicMockService::new(logic)))
pub fn new_mock(logic: MockServiceRpcCall) -> Self {
Self::Test(TonicMockService::new(logic))
}
}

Expand All @@ -256,7 +256,7 @@ pub(crate) mod tests {
// NOTE so we use mock tests where emulators/simulators are not available at this time
#[async_std::test]
async fn appease_the_coverage_gods() -> Result<()> {
let mut mock = TremorGoogleAuthz::new_mock(|_| http::Response::new(empty_body())).await?;
let mut mock = TremorGoogleAuthz::new_mock(|_| http::Response::new(empty_body())).await;
let actual = mock.call(http::Request::new(empty_body())).await;
if let Ok(actual) = actual {
let actual = hyper::body::to_bytes(actual).await?;
Expand Down
6 changes: 3 additions & 3 deletions src/connectors/impls/gbq/writer/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ impl Sink for GbqSink {
let request = AppendRowsRequest {
write_stream: write_stream.name.clone(),
offset: None,
trace_id: "".to_string(),
trace_id: String::new(),
rows: Some(append_rows_request::Rows::ProtoRows(ProtoData {
writer_schema: Some(ProtoSchema {
proto_descriptor: Some(mapping.descriptor().clone()),
Expand Down Expand Up @@ -399,12 +399,12 @@ impl Sink for GbqSink {
parent: self.config.table_id.clone(),
write_stream: Some(WriteStream {
// The stream name here will be ignored and a generated value will be set in the response
name: "".to_string(),
name: String::new(),
r#type: i32::from(write_stream::Type::Committed),
create_time: None,
commit_time: None,
table_schema: None,
location: "".to_string(), // Should be a valid region TODO FIXME
location: String::new(), // Should be a valid region TODO FIXME
write_mode: WriteMode::Insert.into(),
}),
})
Expand Down
29 changes: 13 additions & 16 deletions src/connectors/impls/gcl/writer/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,22 +203,19 @@ impl Sink for GclSink {
}

async fn connect(&mut self, ctx: &SinkContext, _attempt: &Attempt) -> Result<bool> {
match self.mock_logic {
Some(logic) => {
info!("{} Mocking connection to Google Cloud Logging", ctx);
self.client = Some(LoggingServiceV2Client::new(
TremorGoogleAuthz::new_mock(logic).await?,
));
}
None => {
info!("{} Connecting to Google Cloud Logging", ctx);
let channel =
make_tonic_channel(Duration::from_nanos(self.config.connect_timeout)).await?;

let client = LoggingServiceV2Client::new(channel);

self.client = Some(client);
}
if let Some(logic) = self.mock_logic {
info!("{} Mocking connection to Google Cloud Logging", ctx);
self.client = Some(LoggingServiceV2Client::new(
TremorGoogleAuthz::new_mock(logic),
));
} else {
info!("{} Connecting to Google Cloud Logging", ctx);
let channel =
make_tonic_channel(Duration::from_nanos(self.config.connect_timeout)).await?;

let client = LoggingServiceV2Client::new(channel);

self.client = Some(client);
}

Ok(true)
Expand Down
2 changes: 1 addition & 1 deletion src/connectors/impls/otel/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ pub(crate) fn metrics_records_to_pb(json: Option<&Value<'_>>) -> Result<Vec<Metr
json.as_array()
.ok_or("Invalid json mapping for [MetricRecord, ...]")?
.iter()
.map(|item| metric_to_pb(item))
.map(metric_to_pb)
.collect()
} else {
Ok(vec![])
Expand Down

0 comments on commit 3a92a43

Please sign in to comment.