From 0dc450fac14ac0236ca48466fd4fe42630d421ed Mon Sep 17 00:00:00 2001 From: Doug Smith Date: Thu, 8 Jun 2023 15:44:35 -0400 Subject: [PATCH] chore(sinks): mark VectorSink::from_event_sink as deprecated (#17649) This will help steer contributors away from writing new sinks in the deprecated fashion. See https://github.com/vectordotdev/vector/issues/9261 for more context. --- lib/vector-core/src/sink.rs | 6 ++++++ src/config/unit_test/unit_test_components.rs | 1 + src/sinks/appsignal/mod.rs | 1 + src/sinks/aws_cloudwatch_metrics/mod.rs | 1 + src/sinks/azure_monitor_logs.rs | 2 ++ src/sinks/clickhouse/http_sink.rs | 1 + src/sinks/gcp/pubsub.rs | 1 + src/sinks/gcp/stackdriver_logs.rs | 1 + src/sinks/gcp/stackdriver_metrics.rs | 1 + src/sinks/honeycomb.rs | 1 + src/sinks/http.rs | 1 + src/sinks/influxdb/logs.rs | 1 + src/sinks/influxdb/metrics.rs | 1 + src/sinks/mezmo.rs | 1 + src/sinks/prometheus/remote_write.rs | 1 + src/sinks/redis.rs | 1 + src/sinks/sematext/metrics.rs | 1 + src/sinks/util/adaptive_concurrency/tests.rs | 1 + src/test_util/mock/sinks/error.rs | 1 + src/test_util/mock/sinks/panic.rs | 1 + 20 files changed, 26 insertions(+) diff --git a/lib/vector-core/src/sink.rs b/lib/vector-core/src/sink.rs index b39b9d1c75c5d..fb47b6f4d50dd 100644 --- a/lib/vector-core/src/sink.rs +++ b/lib/vector-core/src/sink.rs @@ -61,6 +61,12 @@ impl VectorSink { } /// Converts an event sink into a `VectorSink` + /// + /// Deprecated in favor of `VectorSink::from_event_streamsink`. See [vector/9261] + /// for more info. + /// + /// [vector/9261]: https://github.com/vectordotdev/vector/issues/9261 + #[deprecated] pub fn from_event_sink(sink: impl Sink + Send + Unpin + 'static) -> Self { VectorSink::Sink(Box::new(EventSink::new(sink))) } diff --git a/src/config/unit_test/unit_test_components.rs b/src/config/unit_test/unit_test_components.rs index a38e0492d87aa..157c2306abe3a 100644 --- a/src/config/unit_test/unit_test_components.rs +++ b/src/config/unit_test/unit_test_components.rs @@ -302,6 +302,7 @@ impl SinkConfig for UnitTestStreamSinkConfig { let sink = self.sink.lock().await.take().unwrap(); let healthcheck = future::ok(()).boxed(); + #[allow(deprecated)] Ok((VectorSink::from_event_sink(sink), healthcheck)) } diff --git a/src/sinks/appsignal/mod.rs b/src/sinks/appsignal/mod.rs index ca2211f8505a2..9d24731f01c9a 100644 --- a/src/sinks/appsignal/mod.rs +++ b/src/sinks/appsignal/mod.rs @@ -136,6 +136,7 @@ impl SinkConfig for AppsignalSinkConfig { ) .boxed(); + #[allow(deprecated)] Ok((super::VectorSink::from_event_sink(sink), healthcheck)) } diff --git a/src/sinks/aws_cloudwatch_metrics/mod.rs b/src/sinks/aws_cloudwatch_metrics/mod.rs index accc041b54c32..e169dde9b01fb 100644 --- a/src/sinks/aws_cloudwatch_metrics/mod.rs +++ b/src/sinks/aws_cloudwatch_metrics/mod.rs @@ -252,6 +252,7 @@ impl CloudWatchMetricsSvc { }) }); + #[allow(deprecated)] Ok(VectorSink::from_event_sink(sink)) } diff --git a/src/sinks/azure_monitor_logs.rs b/src/sinks/azure_monitor_logs.rs index bc6bc1b43a330..77e675daf3074 100644 --- a/src/sinks/azure_monitor_logs.rs +++ b/src/sinks/azure_monitor_logs.rs @@ -204,6 +204,7 @@ impl SinkConfig for AzureMonitorLogsConfig { ) .sink_map_err(|error| error!(message = "Fatal azure_monitor_logs sink error.", %error)); + #[allow(deprecated)] Ok((VectorSink::from_event_sink(sink), healthcheck)) } @@ -471,6 +472,7 @@ mod tests { .sink_map_err(|error| error!(message = "Fatal azure_monitor_logs sink error.", %error)); let event = Event::Log(LogEvent::from("simple message")); + #[allow(deprecated)] run_and_assert_sink_compliance( VectorSink::from_event_sink(sink), stream::once(ready(event)), diff --git a/src/sinks/clickhouse/http_sink.rs b/src/sinks/clickhouse/http_sink.rs index 65d96dc341ab1..91c197d126723 100644 --- a/src/sinks/clickhouse/http_sink.rs +++ b/src/sinks/clickhouse/http_sink.rs @@ -47,6 +47,7 @@ pub(crate) async fn build_http_sink( let healthcheck = healthcheck(client, config).boxed(); + #[allow(deprecated)] Ok((VectorSink::from_event_sink(sink), healthcheck)) } diff --git a/src/sinks/gcp/pubsub.rs b/src/sinks/gcp/pubsub.rs index eee4a64c496c4..dded23587438f 100644 --- a/src/sinks/gcp/pubsub.rs +++ b/src/sinks/gcp/pubsub.rs @@ -135,6 +135,7 @@ impl SinkConfig for PubsubConfig { ) .sink_map_err(|error| error!(message = "Fatal gcp_pubsub sink error.", %error)); + #[allow(deprecated)] Ok((VectorSink::from_event_sink(sink), healthcheck)) } diff --git a/src/sinks/gcp/stackdriver_logs.rs b/src/sinks/gcp/stackdriver_logs.rs index f313bb1a38c5e..8e7c43276bd20 100644 --- a/src/sinks/gcp/stackdriver_logs.rs +++ b/src/sinks/gcp/stackdriver_logs.rs @@ -237,6 +237,7 @@ impl SinkConfig for StackdriverConfig { ) .sink_map_err(|error| error!(message = "Fatal gcp_stackdriver_logs sink error.", %error)); + #[allow(deprecated)] Ok((VectorSink::from_event_sink(sink), healthcheck)) } diff --git a/src/sinks/gcp/stackdriver_metrics.rs b/src/sinks/gcp/stackdriver_metrics.rs index f6c66735ddb71..a68140e2bced8 100644 --- a/src/sinks/gcp/stackdriver_metrics.rs +++ b/src/sinks/gcp/stackdriver_metrics.rs @@ -126,6 +126,7 @@ impl SinkConfig for StackdriverConfig { |error| error!(message = "Fatal gcp_stackdriver_metrics sink error.", %error), ); + #[allow(deprecated)] Ok((VectorSink::from_event_sink(sink), healthcheck)) } diff --git a/src/sinks/honeycomb.rs b/src/sinks/honeycomb.rs index c69b52515ec9e..f9a05c2a7a5b0 100644 --- a/src/sinks/honeycomb.rs +++ b/src/sinks/honeycomb.rs @@ -108,6 +108,7 @@ impl SinkConfig for HoneycombConfig { let healthcheck = healthcheck(self.clone(), client).boxed(); + #[allow(deprecated)] Ok((super::VectorSink::from_event_sink(sink), healthcheck)) } diff --git a/src/sinks/http.rs b/src/sinks/http.rs index a49335b77b5c3..1d21b052c2c82 100644 --- a/src/sinks/http.rs +++ b/src/sinks/http.rs @@ -251,6 +251,7 @@ impl SinkConfig for HttpSinkConfig { ) .sink_map_err(|error| error!(message = "Fatal HTTP sink error.", %error)); + #[allow(deprecated)] let sink = super::VectorSink::from_event_sink(sink); Ok((sink, healthcheck)) diff --git a/src/sinks/influxdb/logs.rs b/src/sinks/influxdb/logs.rs index 0bcd27ef35e90..96c5be07ee96f 100644 --- a/src/sinks/influxdb/logs.rs +++ b/src/sinks/influxdb/logs.rs @@ -232,6 +232,7 @@ impl SinkConfig for InfluxDbLogsConfig { ) .sink_map_err(|error| error!(message = "Fatal influxdb_logs sink error.", %error)); + #[allow(deprecated)] Ok((VectorSink::from_event_sink(sink), healthcheck)) } diff --git a/src/sinks/influxdb/metrics.rs b/src/sinks/influxdb/metrics.rs index 75bde8fde1238..e8f8d281ca106 100644 --- a/src/sinks/influxdb/metrics.rs +++ b/src/sinks/influxdb/metrics.rs @@ -193,6 +193,7 @@ impl InfluxDbSvc { }) .sink_map_err(|error| error!(message = "Fatal influxdb sink error.", %error)); + #[allow(deprecated)] Ok(VectorSink::from_event_sink(sink)) } } diff --git a/src/sinks/mezmo.rs b/src/sinks/mezmo.rs index 8f741e6e26074..00a8bf09278bc 100644 --- a/src/sinks/mezmo.rs +++ b/src/sinks/mezmo.rs @@ -175,6 +175,7 @@ impl SinkConfig for MezmoConfig { let healthcheck = healthcheck(self.clone(), client).boxed(); + #[allow(deprecated)] Ok((super::VectorSink::from_event_sink(sink), healthcheck)) } diff --git a/src/sinks/prometheus/remote_write.rs b/src/sinks/prometheus/remote_write.rs index 027cd19e4d8cd..6451e591f11e0 100644 --- a/src/sinks/prometheus/remote_write.rs +++ b/src/sinks/prometheus/remote_write.rs @@ -261,6 +261,7 @@ impl SinkConfig for RemoteWriteConfig { ) }; + #[allow(deprecated)] Ok((sinks::VectorSink::from_event_sink(sink), healthcheck)) } diff --git a/src/sinks/redis.rs b/src/sinks/redis.rs index 611127b4641d0..5a53831bebd3c 100644 --- a/src/sinks/redis.rs +++ b/src/sinks/redis.rs @@ -235,6 +235,7 @@ impl RedisSinkConfig { }) .sink_map_err(|error| error!(message = "Sink failed to flush.", %error)); + #[allow(deprecated)] Ok(super::VectorSink::from_event_sink(sink)) } diff --git a/src/sinks/sematext/metrics.rs b/src/sinks/sematext/metrics.rs index c67898f307d59..29a51c9309638 100644 --- a/src/sinks/sematext/metrics.rs +++ b/src/sinks/sematext/metrics.rs @@ -194,6 +194,7 @@ impl SematextMetricsService { }) .sink_map_err(|error| error!(message = "Fatal sematext metrics sink error.", %error)); + #[allow(deprecated)] Ok(VectorSink::from_event_sink(sink)) } } diff --git a/src/sinks/util/adaptive_concurrency/tests.rs b/src/sinks/util/adaptive_concurrency/tests.rs index 33d735a76f187..69c52bc6ca236 100644 --- a/src/sinks/util/adaptive_concurrency/tests.rs +++ b/src/sinks/util/adaptive_concurrency/tests.rs @@ -200,6 +200,7 @@ impl SinkConfig for TestConfig { ); *self.controller_stats.lock().unwrap() = stats; + #[allow(deprecated)] Ok((VectorSink::from_event_sink(sink), healthcheck)) } diff --git a/src/test_util/mock/sinks/error.rs b/src/test_util/mock/sinks/error.rs index 4e26e9a263317..b1a662fa6694f 100644 --- a/src/test_util/mock/sinks/error.rs +++ b/src/test_util/mock/sinks/error.rs @@ -30,6 +30,7 @@ impl_generate_config_from_default!(ErrorSinkConfig); #[async_trait] impl SinkConfig for ErrorSinkConfig { async fn build(&self, _cx: SinkContext) -> crate::Result<(VectorSink, Healthcheck)> { + #[allow(deprecated)] Ok((VectorSink::from_event_sink(ErrorSink), ok(()).boxed())) } diff --git a/src/test_util/mock/sinks/panic.rs b/src/test_util/mock/sinks/panic.rs index 1f27c256516aa..34079fc30f4ec 100644 --- a/src/test_util/mock/sinks/panic.rs +++ b/src/test_util/mock/sinks/panic.rs @@ -30,6 +30,7 @@ impl_generate_config_from_default!(PanicSinkConfig); #[async_trait] impl SinkConfig for PanicSinkConfig { async fn build(&self, _cx: SinkContext) -> crate::Result<(VectorSink, Healthcheck)> { + #[allow(deprecated)] Ok((VectorSink::from_event_sink(PanicSink), ok(()).boxed())) }