Skip to content

Commit

Permalink
chore(codecs): consolidate enum types (vectordotdev#17688)
Browse files Browse the repository at this point in the history
Consolidate enum types to reduce duplicate type definitions and
documentation.
  • Loading branch information
dsmith3197 authored Jun 14, 2023
1 parent ee480cd commit 9c45394
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 296 deletions.
5 changes: 3 additions & 2 deletions lib/codecs/src/decoding/format/gelf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ use crate::{gelf_fields::*, VALID_FIELD_REGEX};
/// of vector will still work with the new relaxed decoding.
/// Config used to build a `GelfDeserializer`.
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
#[configurable_component]
#[derive(Debug, Clone, Default)]
pub struct GelfDeserializerConfig {
/// GELF-specific decoding options.
#[serde(
default,
skip_serializing_if = "vector_core::serde::skip_serializing_if_default"
)]
/// GELF-specific decoding options.
pub gelf: GelfDeserializerOptions,
}

Expand Down
5 changes: 2 additions & 3 deletions lib/codecs/src/decoding/format/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ use super::{default_lossy, Deserializer};

/// Config used to build a `JsonDeserializer`.
#[configurable_component]
#[derive(Debug, Clone, PartialEq, Eq, Derivative)]
#[derivative(Default)]
#[derive(Debug, Clone, Default)]
pub struct JsonDeserializerConfig {
/// JSON-specific decoding options.
#[serde(
default,
skip_serializing_if = "vector_core::serde::skip_serializing_if_default"
)]
/// JSON-specific decoding options.
pub json: JsonDeserializerOptions,
}

Expand Down
8 changes: 6 additions & 2 deletions lib/codecs/src/decoding/format/native_json.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use bytes::Bytes;
use derivative::Derivative;
use serde::{Deserialize, Serialize};
use smallvec::{smallvec, SmallVec};
use vector_config::configurable_component;
use vector_core::{config::DataType, event::Event, schema};
Expand All @@ -11,9 +10,14 @@ use super::{default_lossy, Deserializer};
use vector_core::config::LogNamespace;

/// Config used to build a `NativeJsonDeserializer`.
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
#[configurable_component]
#[derive(Debug, Clone, Default)]
pub struct NativeJsonDeserializerConfig {
/// Vector's native JSON-specific decoding options.
#[serde(
default,
skip_serializing_if = "vector_core::serde::skip_serializing_if_default"
)]
pub native_json: NativeJsonDeserializerOptions,
}

Expand Down
10 changes: 8 additions & 2 deletions lib/codecs/src/decoding/format/syslog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use chrono::{DateTime, Datelike, Utc};
use derivative::Derivative;
use lookup::lookup_v2::parse_value_path;
use lookup::{event_path, owned_value_path, OwnedTargetPath, OwnedValuePath, PathPrefix};
use serde::{Deserialize, Serialize};
use smallvec::{smallvec, SmallVec};
use std::borrow::Cow;
use std::collections::BTreeMap;
Expand All @@ -20,10 +19,17 @@ use vrl::value::{kind::Collection, Kind};
use super::{default_lossy, Deserializer};

/// Config used to build a `SyslogDeserializer`.
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
#[configurable_component]
#[derive(Debug, Clone, Default)]
pub struct SyslogDeserializerConfig {
#[serde(skip)]
source: Option<&'static str>,

/// Syslog-specific decoding options.
#[serde(
default,
skip_serializing_if = "vector_core::serde::skip_serializing_if_default"
)]
pub syslog: SyslogDeserializerOptions,
}

Expand Down
4 changes: 2 additions & 2 deletions lib/codecs/src/decoding/framing/character_delimited.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use bytes::{Buf, Bytes, BytesMut};
use memchr::memchr;
use serde::{Deserialize, Serialize};
use tokio_util::codec::Decoder;
use tracing::{trace, warn};
use vector_config::configurable_component;

use super::BoxedFramingError;

/// Config used to build a `CharacterDelimitedDecoder`.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[configurable_component]
#[derive(Debug, Clone)]
pub struct CharacterDelimitedDecoderConfig {
/// Options for the character delimited decoder.
pub character_delimited: CharacterDelimitedDecoderOptions,
Expand Down
6 changes: 3 additions & 3 deletions lib/codecs/src/decoding/framing/newline_delimited.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use bytes::{Bytes, BytesMut};
use derivative::Derivative;
use serde::{Deserialize, Serialize};
use tokio_util::codec::Decoder;
use vector_config::configurable_component;

use super::{BoxedFramingError, CharacterDelimitedDecoder};

/// Config used to build a `NewlineDelimitedDecoder`.
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Eq)]
#[configurable_component]
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct NewlineDelimitedDecoderConfig {
/// Options for the newline delimited decoder.
#[serde(
default,
skip_serializing_if = "vector_core::serde::skip_serializing_if_default"
)]
/// Options for the newline delimited decoder.
pub newline_delimited: NewlineDelimitedDecoderOptions,
}

Expand Down
4 changes: 2 additions & 2 deletions lib/codecs/src/decoding/framing/octet_counting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ use std::io;

use bytes::{Buf, Bytes, BytesMut};
use derivative::Derivative;
use serde::{Deserialize, Serialize};
use tokio_util::codec::{LinesCodec, LinesCodecError};
use tracing::trace;
use vector_config::configurable_component;

use super::BoxedFramingError;

/// Config used to build a `OctetCountingDecoder`.
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
#[configurable_component]
#[derive(Debug, Clone, Default)]
pub struct OctetCountingDecoderConfig {
#[serde(
default,
Expand Down
Loading

0 comments on commit 9c45394

Please sign in to comment.