Skip to content

Commit

Permalink
chore(http sink): refactor to new style (vectordotdev#18200)
Browse files Browse the repository at this point in the history
* First iteration, unit tests pass.

* Extract common Service functionality for HTTP based stream sinks.

* docs touchup

* Touch ups

* spell checker

* fix rust doc

* hopefully fix encoding regression

* Try item sized batching

* Refactor a bit

* cleanup

* cleanup

* doc clean up

* extract common service code for re use in other HTTP sinks

* feeback sw

* duplicate

* feedback ds

* feedback ds

* clippy

* fix write issue

* fix docs
  • Loading branch information
neuronull committed Aug 18, 2023
1 parent 31ec4b3 commit d3a6235
Show file tree
Hide file tree
Showing 17 changed files with 1,465 additions and 1,044 deletions.
6 changes: 6 additions & 0 deletions docs/tutorials/sinks/2_http_sink.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ where the data is actually sent.

# Service

**⚠ NOTE! This section implements an HTTP tower `Service` from scratch, for the
purpose of demonstration only. Many sinks will require implementing `Service`
in this way. Any new HTTP-based sink should ideally utilize the
`HttpService` structure, which abstracts away most of the logic shared
amongst HTTP-based sinks.**

We need to create a [`Tower`][tower] service that is responsible for actually
sending our final encoded data.

Expand Down
3 changes: 3 additions & 0 deletions src/sinks/appsignal/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ use super::request_builder::AppsignalRequest;

#[derive(Clone)]
pub(super) struct AppsignalService {
// TODO: `HttpBatchService` has been deprecated for direct use in sinks.
// This sink should undergo a refactor to utilize the `HttpService`
// instead, which extracts much of the boilerplate code for `Service`.
pub(super) batch_service:
HttpBatchService<Ready<Result<http::Request<Bytes>, crate::Error>>, AppsignalRequest>,
}
Expand Down
3 changes: 3 additions & 0 deletions src/sinks/datadog/events/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ impl DriverResponse for DatadogEventsResponse {

#[derive(Clone)]
pub struct DatadogEventsService {
// TODO: `HttpBatchService` has been deprecated for direct use in sinks.
// This sink should undergo a refactor to utilize the `HttpService`
// instead, which extracts much of the boilerplate code for `Service`.
batch_http_service:
HttpBatchService<Ready<Result<http::Request<Bytes>, crate::Error>>, DatadogEventsRequest>,
}
Expand Down
3 changes: 3 additions & 0 deletions src/sinks/elasticsearch/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ impl MetaDescriptive for ElasticsearchRequest {

#[derive(Clone)]
pub struct ElasticsearchService {
// TODO: `HttpBatchService` has been deprecated for direct use in sinks.
// This sink should undergo a refactor to utilize the `HttpService`
// instead, which extracts much of the boilerplate code for `Service`.
batch_service: HttpBatchService<
BoxFuture<'static, Result<http::Request<Bytes>, crate::Error>>,
ElasticsearchRequest,
Expand Down
Loading

0 comments on commit d3a6235

Please sign in to comment.