Skip to content
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
16 changes: 4 additions & 12 deletions lib/vector-common/src/finalization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,23 +280,19 @@ impl Drop for OwnedBatchNotifier {
/// The status of an individual batch.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[repr(u8)]
#[derive(Default)]
pub enum BatchStatus {
/// All events in the batch were accepted.
///
/// This is the default.
#[default]
Delivered,
/// At least one event in the batch had a transient error in delivery.
Errored,
/// At least one event in the batch had a permanent failure or rejection.
Rejected,
}

impl Default for BatchStatus {
fn default() -> Self {
Self::Delivered
}
}

impl BatchStatus {
/// Updates the delivery status based on another batch's delivery status, returning the result.
///
Expand All @@ -320,10 +316,12 @@ impl BatchStatus {
/// The status of an individual event.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[repr(u8)]
#[derive(Default)]
pub enum EventStatus {
/// All copies of this event were dropped without being finalized.
///
/// This is the default.
#[default]
Dropped,
/// All copies of this event were delivered successfully.
Delivered,
Expand All @@ -335,12 +333,6 @@ pub enum EventStatus {
Recorded,
}

impl Default for EventStatus {
fn default() -> Self {
Self::Dropped
}
}

impl EventStatus {
/// Updates the status based on another event's status, returning the result.
///
Expand Down
2 changes: 1 addition & 1 deletion lib/vector-config-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod configurable_component;

/// Designates a type as being part of a Vector configuration.
///
/// This will automatically derive the [`Configurable`][vector-config::Configurable] trait for the given struct/enum, as
/// This will automatically derive the `Configurable` trait for the given struct/enum, as
/// well as ensuring that serialization/deserialization (via `serde`) is derived.
///
/// ## Basics
Expand Down
2 changes: 1 addition & 1 deletion lib/vector-config/src/named.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// A component with a well-known name.
///
/// Users can derive this trait automatically by using the
/// [`component_name`][vector-config::component_name] macro on their structs/enums.
/// [`NamedComponent`][derive@crate::NamedComponent] derive macro on their structs/enums.
pub trait NamedComponent {
/// Gets the name of the component.
fn get_component_name(&self) -> &'static str;
Expand Down
9 changes: 2 additions & 7 deletions lib/vector-core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ impl From<bool> for AcknowledgementsConfig {
}
}

#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize, PartialOrd, Ord, Eq)]
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize, PartialOrd, Ord, Eq, Default)]
pub enum LogNamespace {
/// Vector native namespacing
///
Expand All @@ -405,6 +405,7 @@ pub enum LogNamespace {
///
/// All data is set in the root of the event. Since this can lead
/// to collisions, deserialized data has priority over metadata
#[default]
Legacy,
}

Expand All @@ -420,12 +421,6 @@ impl From<bool> for LogNamespace {
}
}

impl Default for LogNamespace {
fn default() -> Self {
Self::Legacy
}
}

/// A shortcut to specify no `LegacyKey` should be used (since otherwise a turbofish would be required)
pub const NO_LEGACY_KEY: Option<LegacyKey<&'static str>> = None;

Expand Down
2 changes: 1 addition & 1 deletion lib/vector-core/src/event/lua/metric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl FromLua for TagValueSet {
}
Ok(Self::from(string_values))
}
LuaValue::String(x) => Ok(Self::from([x.to_string_lossy().to_string()])),
LuaValue::String(x) => Ok(Self::from([x.to_string_lossy().clone()])),
_ => Err(mlua::Error::FromLuaConversionError {
from: value.type_name(),
to: String::from("metric tag value"),
Expand Down
9 changes: 2 additions & 7 deletions lib/vector-core/src/event/metric/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ type TagValueRef<'a> = Option<&'a str>;

/// Tag values for a metric series. This may be empty, a single value, or a set of values. This is
/// used to provide the storage for `TagValueSet`.
#[derive(Clone, Configurable, Debug, Eq, PartialEq)]
#[derive(Clone, Configurable, Debug, Eq, PartialEq, Default)]
pub enum TagValueSet {
/// This represents a set containing no value.
#[default]
Empty,

/// This represents a set containing a single value. This is stored separately to avoid the
Expand All @@ -111,12 +112,6 @@ pub enum TagValueSet {
Set(IndexSet<TagValue>),
}

impl Default for TagValueSet {
fn default() -> Self {
Self::Empty
}
}

impl Display for TagValueSet {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for (i, value) in self.iter().enumerate() {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.90"
channel = "1.91"
profile = "default"
8 changes: 2 additions & 6 deletions src/sinks/databend/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@ use vector_lib::configurable::configurable_component;
#[configurable(metadata(
docs::enum_tag_description = "The compression algorithm to use for sending."
))]
#[derive(Default)]
pub enum DatabendCompression {
/// No compression.
#[default]
None,

/// [Gzip][gzip] compression.
///
/// [gzip]: https://www.gzip.org/
Gzip,
}

impl Default for DatabendCompression {
fn default() -> Self {
Self::None
}
}
8 changes: 2 additions & 6 deletions src/sinks/databend/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ impl DatabendEncodingConfig {
#[derive(Clone, Debug)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[configurable(metadata(docs::enum_tag_description = "How to handle missing fields for NDJson."))]
#[derive(Default)]
pub enum DatabendMissingFieldAS {
/// Generates an error if a missing field is encountered.
Error,

/// Interprets missing fields as NULL values. An error will be generated for non-nullable fields.
#[default]
Null,

/// Uses the default value of the field for missing fields.
Expand All @@ -89,12 +91,6 @@ pub enum DatabendMissingFieldAS {
TypeDefault,
}

impl Default for DatabendMissingFieldAS {
fn default() -> Self {
Self::Null
}
}

impl DatabendMissingFieldAS {
pub(super) const fn as_str(&self) -> &'static str {
match self {
Expand Down
8 changes: 2 additions & 6 deletions src/sinks/elasticsearch/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ pub const DATA_STREAM_TIMESTAMP_KEY: &str = "@timestamp";
#[configurable_component]
#[derive(Clone, Debug, Eq, PartialEq)]
#[serde(deny_unknown_fields, rename_all = "lowercase")]
#[derive(Default)]
pub enum OpenSearchServiceType {
/// Elasticsearch or OpenSearch Managed domain
#[default]
Managed,
/// OpenSearch Serverless collection
Serverless,
Expand All @@ -62,12 +64,6 @@ impl OpenSearchServiceType {
}
}

impl Default for OpenSearchServiceType {
fn default() -> Self {
Self::Managed
}
}

/// Configuration for the `elasticsearch` sink.
#[configurable_component(sink("elasticsearch", "Index observability events in Elasticsearch."))]
#[derive(Clone, Debug)]
Expand Down
16 changes: 4 additions & 12 deletions src/sinks/elasticsearch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ pub enum ElasticsearchAuthConfig {
#[configurable_component]
#[derive(Clone, Debug, Eq, PartialEq)]
#[serde(deny_unknown_fields, rename_all = "snake_case")]
#[derive(Default)]
pub enum ElasticsearchMode {
/// Ingests documents in bulk, using the bulk API `index` action.
#[serde(alias = "normal")]
#[default]
Bulk,

/// Ingests documents in bulk, using the bulk API `create` action.
Expand All @@ -75,12 +77,6 @@ pub enum ElasticsearchMode {
DataStream,
}

impl Default for ElasticsearchMode {
fn default() -> Self {
Self::Bulk
}
}

/// Bulk API actions.
#[configurable_component]
#[derive(Clone, Copy, Debug, Derivative, Eq, Hash, PartialEq)]
Expand Down Expand Up @@ -295,6 +291,7 @@ impl ElasticsearchCommonMode {
#[derive(Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "proptest", derive(proptest_derive::Arbitrary))]
#[serde(deny_unknown_fields, rename_all = "snake_case")]
#[derive(Default)]
pub enum ElasticsearchApiVersion {
/// Auto-detect the API version.
///
Expand All @@ -305,6 +302,7 @@ pub enum ElasticsearchApiVersion {
/// incorrect API calls.
///
/// [es_version]: https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html#cluster-state-api-path-params
#[default]
Auto,
/// Use the Elasticsearch 6.x API.
V6,
Expand All @@ -314,12 +312,6 @@ pub enum ElasticsearchApiVersion {
V8,
}

impl Default for ElasticsearchApiVersion {
fn default() -> Self {
Self::Auto
}
}

#[derive(Debug, Snafu)]
#[snafu(visibility(pub))]
pub enum ParseError {
Expand Down
6 changes: 3 additions & 3 deletions src/sinks/prometheus/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ mod tests {
},
);

let metrics = vec![
let metrics = [
base_summary_metric.clone(),
base_summary_metric
.clone()
Expand Down Expand Up @@ -1305,7 +1305,7 @@ mod tests {
},
);

let metrics = vec![
let metrics = [
base_summary_metric.clone(),
base_summary_metric
.clone()
Expand Down Expand Up @@ -1406,7 +1406,7 @@ mod tests {
MetricValue::Gauge { value: -10.0 },
);

let metrics = vec![
let metrics = [
base_absolute_gauge_metric.clone(),
base_absolute_gauge_metric
.clone()
Expand Down
9 changes: 2 additions & 7 deletions src/sinks/util/service/concurrency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use vector_lib::configurable::{
///
/// This can be set either to one of the below enum values or to a positive integer, which denotes
/// a fixed concurrency limit.
#[derive(Clone, Copy, Debug, Derivative, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Derivative, Eq, PartialEq, Default)]
pub enum Concurrency {
/// A fixed concurrency of 1.
///
Expand All @@ -28,6 +28,7 @@ pub enum Concurrency {
/// Concurrency is managed by the [Adaptive Request Concurrency][arc] feature.
///
/// [arc]: https://vector.dev/docs/architecture/arc/
#[default]
Adaptive,

/// A fixed amount of concurrency is allowed.
Expand All @@ -47,12 +48,6 @@ impl Serialize for Concurrency {
}
}

impl Default for Concurrency {
fn default() -> Self {
Self::Adaptive
}
}

impl Concurrency {
pub const fn parse_concurrency(&self) -> Option<usize> {
match self {
Expand Down
8 changes: 4 additions & 4 deletions src/sources/fluent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ mod tests {
250, 129, 167, 109, 101, 115, 115, 97, 103, 101, 163, 98, 97, 122,
];

let expected = vec![
let expected = [
mock_event("foo", "2015-09-07T01:23:04Z"),
mock_event("bar", "2015-09-07T01:23:05Z"),
mock_event("baz", "2015-09-07T01:23:06Z"),
Expand Down Expand Up @@ -958,7 +958,7 @@ mod tests {
122, 101, 3,
];

let expected = vec![
let expected = [
mock_event("foo", "2015-09-07T01:23:04Z"),
mock_event("bar", "2015-09-07T01:23:05Z"),
mock_event("baz", "2015-09-07T01:23:06Z"),
Expand Down Expand Up @@ -992,7 +992,7 @@ mod tests {
101, 115, 115, 97, 103, 101, 163, 102, 111, 111,
];

let expected = vec![
let expected = [
mock_event("foo", "2015-09-07T01:23:04Z"),
mock_event("bar", "2015-09-07T01:23:05Z"),
mock_event("baz", "2015-09-07T01:23:06Z"),
Expand Down Expand Up @@ -1027,7 +1027,7 @@ mod tests {
164, 103, 122, 105, 112,
];

let expected = vec![
let expected = [
mock_event("foo", "2015-09-07T01:23:04Z"),
mock_event("bar", "2015-09-07T01:23:05Z"),
mock_event("baz", "2015-09-07T01:23:06Z"),
Expand Down
16 changes: 8 additions & 8 deletions src/sources/util/grpc/decompression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ impl CompressionScheme {
}
}

#[derive(Default)]
enum State {
#[default]
WaitingForHeader,
Forward { overall_len: usize },
Decompress { remaining: usize },
}

impl Default for State {
fn default() -> Self {
Self::WaitingForHeader
}
Forward {
overall_len: usize,
},
Decompress {
remaining: usize,
},
}

fn new_decompressor() -> GzDecoder<Vec<u8>> {
Expand Down
Loading
Loading