Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dev): Add wrapper for codecs to vector-lib #18959

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ vrl.workspace = true
pin-project.workspace = true

# Internal libs
codecs = { path = "lib/codecs", default-features = false }
dnsmsg-parser = { path = "lib/dnsmsg-parser", optional = true }
enrichment = { path = "lib/enrichment" }
fakedata = { path = "lib/fakedata", optional = true }
Expand Down Expand Up @@ -468,7 +467,7 @@ enrichment-tables = ["enrichment-tables-geoip"]
enrichment-tables-geoip = ["dep:maxminddb"]

# Codecs
codecs-syslog = ["codecs/syslog"]
codecs-syslog = ["vector-lib/syslog"]

# Sources
sources = ["sources-logs", "sources-metrics"]
Expand Down
2 changes: 2 additions & 0 deletions lib/vector-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"
publish = false

[dependencies]
codecs = { path = "../codecs", default-features = false }
vector-common = { path = "../vector-common" }
vector-config = { path = "../vector-config" }
vector-core = { path = "../vector-core", default-features = false }
Expand All @@ -14,5 +15,6 @@ vector-stream = { path = "../vector-stream" }
[features]
api = ["vector-core/api"]
lua = ["vector-core/lua"]
syslog = ["codecs/syslog"]
test = ["vector-core/test"]
vrl = ["vector-core/vrl"]
1 change: 1 addition & 0 deletions lib/vector-lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub use codecs;
pub use vector_common::{
assert_event_data_eq, btreemap, byte_size_of, byte_size_of::ByteSizeOf, conversion,
encode_logfmt, finalization, finalizer, impl_event_data_eq, internal_event, json_size,
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/decoding/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use codecs::decoding::{DeserializerConfig, FramingConfig};
use serde::{Deserialize, Serialize};
use vector_lib::codecs::decoding::{DeserializerConfig, FramingConfig};
use vector_lib::config::LogNamespace;

use crate::codecs::Decoder;
Expand Down
10 changes: 5 additions & 5 deletions src/codecs/decoding/decoder.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use bytes::{Bytes, BytesMut};
use codecs::decoding::{
use smallvec::SmallVec;
use vector_lib::codecs::decoding::{
format::Deserializer as _, BoxedFramingError, BytesDeserializer, Deserializer, Error, Framer,
NewlineDelimitedDecoder,
};
use smallvec::SmallVec;
use vector_lib::config::LogNamespace;

use crate::{
Expand Down Expand Up @@ -103,12 +103,12 @@ impl tokio_util::codec::Decoder for Decoder {
mod tests {
use super::Decoder;
use bytes::Bytes;
use codecs::{
use futures::{stream, StreamExt};
use tokio_util::{codec::FramedRead, io::StreamReader};
use vector_lib::codecs::{
decoding::{Deserializer, Framer},
JsonDeserializer, NewlineDelimitedDecoder, StreamDecodingError,
};
use futures::{stream, StreamExt};
use tokio_util::{codec::FramedRead, io::StreamReader};
use vrl::value::Value;

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/encoding/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::codecs::Transformer;
use codecs::{
use vector_lib::codecs::{
encoding::{Framer, FramingConfig, Serializer, SerializerConfig},
CharacterDelimitedEncoder, LengthDelimitedEncoder, NewlineDelimitedEncoder,
};
Expand Down
6 changes: 3 additions & 3 deletions src/codecs/encoding/encoder.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use bytes::BytesMut;
use codecs::{
use tokio_util::codec::Encoder as _;
use vector_lib::codecs::{
encoding::{Error, Framer, Serializer},
CharacterDelimitedEncoder, NewlineDelimitedEncoder, TextSerializerConfig,
};
use tokio_util::codec::Encoder as _;

use crate::{
event::Event,
Expand Down Expand Up @@ -184,9 +184,9 @@ impl tokio_util::codec::Encoder<Event> for Encoder<()> {
#[cfg(test)]
mod tests {
use bytes::BufMut;
use codecs::encoding::BoxedFramingError;
use futures_util::{SinkExt, StreamExt};
use tokio_util::codec::FramedWrite;
use vector_lib::codecs::encoding::BoxedFramingError;
use vector_lib::event::LogEvent;

use super::*;
Expand Down
2 changes: 1 addition & 1 deletion src/components/validation/resources/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use snafu::Snafu;
use tokio_util::codec::Encoder as _;

use crate::codecs::Encoder;
use codecs::{
use vector_lib::codecs::{
encoding, JsonSerializer, LengthDelimitedEncoder, LogfmtSerializer, MetricTagValues,
NewlineDelimitedEncoder,
};
Expand Down
12 changes: 6 additions & 6 deletions src/components/validation/resources/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
mod event;
mod http;

use codecs::{
use tokio::sync::mpsc;
use vector_lib::codecs::{
decoding::{self, DeserializerConfig},
encoding::{
self, Framer, FramingConfig, JsonSerializerConfig, SerializerConfig, TextSerializerConfig,
},
BytesEncoder,
};
use tokio::sync::mpsc;
use vector_lib::{config::DataType, event::Event};

use crate::codecs::{Decoder, DecodingConfig, Encoder, EncodingConfig, EncodingConfigWithFraming};
Expand Down Expand Up @@ -143,8 +143,8 @@ fn deserializer_config_to_serializer(config: &DeserializerConfig) -> encoding::S
DeserializerConfig::Bytes => SerializerConfig::Text(TextSerializerConfig::default()),
DeserializerConfig::Json { .. } => SerializerConfig::Json(JsonSerializerConfig::default()),
DeserializerConfig::Protobuf(config) => {
SerializerConfig::Protobuf(codecs::encoding::ProtobufSerializerConfig {
protobuf: codecs::encoding::ProtobufSerializerOptions {
SerializerConfig::Protobuf(vector_lib::codecs::encoding::ProtobufSerializerConfig {
protobuf: vector_lib::codecs::encoding::ProtobufSerializerOptions {
desc_file: config.protobuf.desc_file.clone(),
message_type: config.protobuf.message_type.clone(),
},
Expand Down Expand Up @@ -197,8 +197,8 @@ fn serializer_config_to_deserializer(
SerializerConfig::Native => DeserializerConfig::Native,
SerializerConfig::NativeJson => DeserializerConfig::NativeJson(Default::default()),
SerializerConfig::Protobuf(config) => {
DeserializerConfig::Protobuf(codecs::decoding::ProtobufDeserializerConfig {
protobuf: codecs::decoding::ProtobufDeserializerOptions {
DeserializerConfig::Protobuf(vector_lib::codecs::decoding::ProtobufDeserializerConfig {
protobuf: vector_lib::codecs::decoding::ProtobufDeserializerOptions {
desc_file: config.protobuf.desc_file.clone(),
message_type: config.protobuf.message_type.clone(),
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/validation/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use tokio::{
};
use tokio_util::codec::Encoder as _;

use codecs::encoding;
use vector_lib::codecs::encoding;
use vector_lib::{event::Event, EstimatedJsonEncodedSizeOf};

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion src/internal_events/codecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<'a> InternalEvent for DecoderDeserializeError<'a> {

#[derive(Debug)]
pub struct EncoderFramingError<'a> {
pub error: &'a codecs::encoding::BoxedFramingError,
pub error: &'a vector_lib::codecs::encoding::BoxedFramingError,
}

impl<'a> InternalEvent for EncoderFramingError<'a> {
Expand Down
2 changes: 1 addition & 1 deletion src/internal_events/journald.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use codecs::decoding::BoxedFramingError;
use metrics::counter;
use vector_lib::codecs::decoding::BoxedFramingError;
use vector_lib::internal_event::InternalEvent;

use vector_lib::internal_event::{error_stage, error_type};
Expand Down
6 changes: 3 additions & 3 deletions src/serde.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![allow(missing_docs)]
use codecs::{
use indexmap::map::IndexMap;
use serde::{Deserialize, Serialize};
use vector_lib::codecs::{
decoding::{DeserializerConfig, FramingConfig},
BytesDecoderConfig, BytesDeserializerConfig,
};
use indexmap::map::IndexMap;
use serde::{Deserialize, Serialize};
use vector_lib::configurable::configurable_component;
pub use vector_lib::serde::{bool_or_struct, skip_serializing_if_default};

Expand Down
2 changes: 1 addition & 1 deletion src/sinks/amqp/config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Configuration functionality for the `AMQP` sink.
use crate::{amqp::AmqpConfig, sinks::prelude::*};
use codecs::TextSerializerConfig;
use lapin::{types::ShortString, BasicProperties};
use std::sync::Arc;
use vector_lib::codecs::TextSerializerConfig;

use super::sink::AmqpSink;

Expand Down
2 changes: 1 addition & 1 deletion src/sinks/aws_cloudwatch_logs/config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use aws_sdk_cloudwatchlogs::Client as CloudwatchLogsClient;
use aws_smithy_types::retry::RetryConfig;
use codecs::JsonSerializerConfig;
use futures::FutureExt;
use tower::ServiceBuilder;
use vector_lib::codecs::JsonSerializerConfig;
use vector_lib::configurable::configurable_component;
use vector_lib::schema;
use vrl::value::Kind;
Expand Down
2 changes: 1 addition & 1 deletion src/sinks/aws_cloudwatch_logs/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::convert::TryFrom;
use aws_sdk_cloudwatchlogs::Client as CloudwatchLogsClient;
use aws_sdk_cloudwatchlogs::Region;
use chrono::Duration;
use codecs::TextSerializerConfig;
use futures::{stream, StreamExt};
use similar_asserts::assert_eq;
use vector_lib::codecs::TextSerializerConfig;

use super::*;
use crate::aws::create_client;
Expand Down
2 changes: 1 addition & 1 deletion src/sinks/aws_kinesis/firehose/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

use aws_sdk_elasticsearch::Client as EsClient;
use aws_sdk_firehose::model::ElasticsearchDestinationConfiguration;
use codecs::JsonSerializerConfig;
use futures::TryFutureExt;
use serde_json::{json, Value};
use tokio::time::{sleep, Duration};
use vector_lib::codecs::JsonSerializerConfig;

use super::{config::KinesisFirehoseClientBuilder, *};
use crate::{
Expand Down
2 changes: 1 addition & 1 deletion src/sinks/aws_kinesis/firehose/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg(test)]

use codecs::JsonSerializerConfig;
use vector_lib::codecs::JsonSerializerConfig;

use super::*;
use crate::{
Expand Down
2 changes: 1 addition & 1 deletion src/sinks/aws_kinesis/streams/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use aws_sdk_kinesis::{
model::{Record, ShardIteratorType},
types::DateTime,
};
use codecs::TextSerializerConfig;
use tokio::time::{sleep, Duration};
use vector_lib::codecs::TextSerializerConfig;

use super::{config::KinesisClientBuilder, *};
use crate::{
Expand Down
4 changes: 2 additions & 2 deletions src/sinks/aws_s3/config.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::convert::TryInto;

use aws_sdk_s3::Client as S3Client;
use codecs::{
use tower::ServiceBuilder;
use vector_lib::codecs::{
encoding::{Framer, FramingConfig},
TextSerializerConfig,
};
use tower::ServiceBuilder;
use vector_lib::configurable::configurable_component;
use vector_lib::sink::VectorSink;

Expand Down
2 changes: 1 addition & 1 deletion src/sinks/aws_s3/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ use aws_sdk_s3::{
Client as S3Client,
};
use bytes::Buf;
use codecs::{encoding::FramingConfig, TextSerializerConfig};
use flate2::read::MultiGzDecoder;
use futures::{stream, Stream};
use similar_asserts::assert_eq;
use tokio_stream::StreamExt;
use vector_lib::codecs::{encoding::FramingConfig, TextSerializerConfig};
use vector_lib::{
config::proxy::ProxyConfig,
event::{BatchNotifier, BatchStatus, BatchStatusReceiver, Event, EventArray, LogEvent},
Expand Down
2 changes: 1 addition & 1 deletion src/sinks/aws_s3/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::io;

use bytes::Bytes;
use chrono::Utc;
use codecs::encoding::Framer;
use uuid::Uuid;
use vector_lib::codecs::encoding::Framer;
use vector_lib::event::Finalizable;
use vector_lib::request_metadata::RequestMetadata;

Expand Down
2 changes: 1 addition & 1 deletion src/sinks/aws_s_s/sns/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::collections::HashMap;
use aws_sdk_sns::{Client as SnsClient, Region};
use aws_sdk_sqs::model::QueueAttributeName;
use aws_sdk_sqs::Client as SqsClient;
use codecs::TextSerializerConfig;
use tokio::time::{sleep, Duration};
use vector_lib::codecs::TextSerializerConfig;

use super::{
config::SnsClientBuilder,
Expand Down
2 changes: 1 addition & 1 deletion src/sinks/aws_s_s/sqs/integration_tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::HashMap;

use aws_sdk_sqs::{model::QueueAttributeName, Client as SqsClient, Region};
use codecs::TextSerializerConfig;
use tokio::time::{sleep, Duration};
use vector_lib::codecs::TextSerializerConfig;

use crate::config::{SinkConfig, SinkContext};
use crate::sinks::aws_s_s::sqs::config::{healthcheck, SqsSinkConfig};
Expand Down
2 changes: 1 addition & 1 deletion src/sinks/azure_blob/config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::sync::Arc;

use azure_storage_blobs::prelude::*;
use codecs::{encoding::Framer, JsonSerializerConfig, NewlineDelimitedEncoderConfig};
use tower::ServiceBuilder;
use vector_lib::codecs::{encoding::Framer, JsonSerializerConfig, NewlineDelimitedEncoderConfig};
use vector_lib::configurable::configurable_component;
use vector_lib::sensitive_string::SensitiveString;

Expand Down
8 changes: 4 additions & 4 deletions src/sinks/azure_blob/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use std::{
use azure_core::{error::HttpError, prelude::Range};
use azure_storage_blobs::prelude::*;
use bytes::{Buf, BytesMut};
use codecs::{
encoding::FramingConfig, JsonSerializerConfig, NewlineDelimitedEncoderConfig,
TextSerializerConfig,
};
use flate2::read::GzDecoder;
use futures::{stream, Stream, StreamExt};
use http::StatusCode;
use vector_lib::codecs::{
encoding::FramingConfig, JsonSerializerConfig, NewlineDelimitedEncoderConfig,
TextSerializerConfig,
};
use vector_lib::ByteSizeOf;

use super::config::AzureBlobSinkConfig;
Expand Down
2 changes: 1 addition & 1 deletion src/sinks/azure_blob/request_builder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bytes::Bytes;
use chrono::Utc;
use codecs::encoding::Framer;
use uuid::Uuid;
use vector_lib::codecs::encoding::Framer;
use vector_lib::request_metadata::RequestMetadata;
use vector_lib::EstimatedJsonEncodedSizeOf;

Expand Down
2 changes: 1 addition & 1 deletion src/sinks/azure_blob/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bytes::Bytes;
use chrono::Utc;
use codecs::{
use vector_lib::codecs::{
encoding::{Framer, FramingConfig},
NewlineDelimitedEncoder, TextSerializerConfig,
};
Expand Down
2 changes: 1 addition & 1 deletion src/sinks/azure_monitor_logs/sink.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{fmt::Debug, io};

use bytes::Bytes;
use codecs::{encoding::Framer, CharacterDelimitedEncoder, JsonSerializerConfig};
use lookup::{OwnedValuePath, PathPrefix};
use vector_lib::codecs::{encoding::Framer, CharacterDelimitedEncoder, JsonSerializerConfig};

use crate::sinks::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion src/sinks/clickhouse/sink.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bytes::Bytes;
use codecs::{encoding::Framer, JsonSerializerConfig, NewlineDelimitedEncoderConfig};
use vector_lib::codecs::{encoding::Framer, JsonSerializerConfig, NewlineDelimitedEncoderConfig};

use super::service::{ClickhouseRequest, ClickhouseRetryLogic, ClickhouseService};
use crate::sinks::prelude::*;
Expand Down
6 changes: 3 additions & 3 deletions src/sinks/console/config.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use codecs::{
use futures::{future, FutureExt};
use tokio::io;
use vector_lib::codecs::{
encoding::{Framer, FramingConfig},
JsonSerializerConfig,
};
use futures::{future, FutureExt};
use tokio::io;
use vector_lib::configurable::configurable_component;

use crate::{
Expand Down
Loading
Loading