diff --git a/src/connectors/google.rs b/src/connectors/google.rs index 8f069596bf..be5dece177 100644 --- a/src/connectors/google.rs +++ b/src/connectors/google.rs @@ -47,11 +47,11 @@ type TonicInternalBodyType = UnsyncBoxBody; 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}"), } } } @@ -230,8 +230,8 @@ impl TremorGoogleAuthz { } // Create a new mock channel to a GCP gRPC service - pub async fn new_mock(logic: MockServiceRpcCall) -> Result { - Ok(Self::Test(TonicMockService::new(logic))) + pub fn new_mock(logic: MockServiceRpcCall) -> Self { + Self::Test(TonicMockService::new(logic)) } } @@ -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?; diff --git a/src/connectors/impls/gbq/writer/sink.rs b/src/connectors/impls/gbq/writer/sink.rs index cb768b3b3d..b649fb3968 100644 --- a/src/connectors/impls/gbq/writer/sink.rs +++ b/src/connectors/impls/gbq/writer/sink.rs @@ -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()), @@ -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(), }), }) diff --git a/src/connectors/impls/gcl/writer/sink.rs b/src/connectors/impls/gcl/writer/sink.rs index 7e2a1dfc28..dc83733131 100644 --- a/src/connectors/impls/gcl/writer/sink.rs +++ b/src/connectors/impls/gcl/writer/sink.rs @@ -203,22 +203,19 @@ impl Sink for GclSink { } async fn connect(&mut self, ctx: &SinkContext, _attempt: &Attempt) -> Result { - 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) diff --git a/src/connectors/impls/otel/metrics.rs b/src/connectors/impls/otel/metrics.rs index b5cb060847..7e851a0aa1 100644 --- a/src/connectors/impls/otel/metrics.rs +++ b/src/connectors/impls/otel/metrics.rs @@ -327,7 +327,7 @@ pub(crate) fn metrics_records_to_pb(json: Option<&Value<'_>>) -> Result