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

fix(config)!: fix concurrency default & docs #18651

Merged
merged 8 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
8 changes: 4 additions & 4 deletions src/sinks/util/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use tower::{
use vector_config::configurable_component;

pub use crate::sinks::util::service::{
concurrency::{concurrency_is_none, Concurrency},
concurrency::{concurrency_is_adaptive, Concurrency},
health::{HealthConfig, HealthLogic, HealthService},
map::Map,
};
Expand Down Expand Up @@ -93,7 +93,7 @@ impl<L> ServiceBuilderExt<L> for ServiceBuilder<L> {
pub struct TowerRequestConfig {
#[configurable(derived)]
#[serde(default = "default_concurrency")]
#[serde(skip_serializing_if = "concurrency_is_none")]
#[serde(skip_serializing_if = "concurrency_is_adaptive")]
pub concurrency: Concurrency,

/// The time a request can take before being aborted.
Expand Down Expand Up @@ -144,7 +144,7 @@ pub struct TowerRequestConfig {
}

const fn default_concurrency() -> Concurrency {
Concurrency::None
Concurrency::Adaptive
dsmith3197 marked this conversation as resolved.
Show resolved Hide resolved
}

const fn default_timeout_secs() -> Option<u64> {
Expand Down Expand Up @@ -457,7 +457,7 @@ mod tests {
toml::from_str::<TowerRequestConfig>(&toml).expect("Default config failed");

let cfg = toml::from_str::<TowerRequestConfig>("").expect("Empty config failed");
assert_eq!(cfg.concurrency, Concurrency::None);
assert_eq!(cfg.concurrency, Concurrency::Adaptive);

let cfg = toml::from_str::<TowerRequestConfig>("concurrency = 10")
.expect("Fixed concurrency failed");
Expand Down
29 changes: 19 additions & 10 deletions src/sinks/util/service/concurrency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ use serde::{
};

/// Configuration for outbound request concurrency.
///
/// This can be set either to one of the below enum values or to a uint, which denotes
dsmith3197 marked this conversation as resolved.
Show resolved Hide resolved
/// a fixed concurrency limit.
#[derive(Clone, Copy, Debug, Derivative, Eq, PartialEq)]
pub enum Concurrency {
/// A fixed concurrency of 1.
Expand Down Expand Up @@ -48,28 +51,29 @@ impl Serialize for Concurrency {

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

impl Concurrency {
pub const fn if_none(self, other: Self) -> Self {
const fn if_adaptive(self, other: Self) -> Self {
match self {
Self::None => other,
Self::Adaptive => other,
_ => self,
}
}

pub const fn parse_concurrency(&self, default: Self) -> Option<usize> {
match self.if_none(default) {
Concurrency::None | Concurrency::Adaptive => None,
pub const fn parse_concurrency(&self, other: Self) -> Option<usize> {
match self.if_adaptive(other) {
Concurrency::None => Some(1),
Concurrency::Adaptive => None,
Concurrency::Fixed(limit) => Some(limit),
}
}
}

pub const fn concurrency_is_none(concurrency: &Concurrency) -> bool {
matches!(concurrency, Concurrency::None)
pub const fn concurrency_is_adaptive(concurrency: &Concurrency) -> bool {
matches!(concurrency, Concurrency::Adaptive)
}

impl<'de> Deserialize<'de> for Concurrency {
Expand All @@ -93,7 +97,7 @@ impl<'de> Deserialize<'de> for Concurrency {
} else if value == "none" {
Ok(Concurrency::None)
} else {
Err(de::Error::unknown_variant(value, &["adaptive"]))
Err(de::Error::unknown_variant(value, &["adaptive", "none"]))
}
}

Expand Down Expand Up @@ -132,7 +136,12 @@ impl Configurable for Concurrency {

fn metadata() -> Metadata {
let mut metadata = Metadata::default();
metadata.set_description("Configuration for outbound request concurrency.");
metadata.set_description(
r#"Configuration for outbound request concurrency.

This can be set either to one of the below enum values or to a uint, which denotes
a fixed concurrency limit."#,
);
metadata.add_custom_attribute(CustomAttribute::kv("docs::enum_tagging", "external"));
metadata
}
Expand Down
11 changes: 8 additions & 3 deletions website/cue/reference/components/sinks/base/appsignal.cue
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,16 @@ base: components: sinks: appsignal: configuration: {
}
}
concurrency: {
description: "Configuration for outbound request concurrency."
required: false
description: """
Configuration for outbound request concurrency.

This can be set either to one of the below enum values or to a uint, which denotes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This can be set either to one of the below enum values or to a uint, which denotes
This can be set either to one of the below enum values or to a uint, which denotes

Just a general comment/ question, would it be preferred here to change uint to unsigned integer just to avoid confusion on the acronym? Will approve the PR but leave that to your discretion.

a fixed concurrency limit.
"""
required: false
type: {
string: {
default: "none"
default: "adaptive"
enum: {
adaptive: """
Concurrency will be managed by Vector's [Adaptive Request Concurrency][arc] feature.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,16 @@ base: components: sinks: aws_cloudwatch_logs: configuration: {
}
}
concurrency: {
description: "Configuration for outbound request concurrency."
required: false
description: """
Configuration for outbound request concurrency.

This can be set either to one of the below enum values or to a uint, which denotes
a fixed concurrency limit.
"""
required: false
type: {
string: {
default: "none"
default: "adaptive"
enum: {
adaptive: """
Concurrency will be managed by Vector's [Adaptive Request Concurrency][arc] feature.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,16 @@ base: components: sinks: aws_cloudwatch_metrics: configuration: {
}
}
concurrency: {
description: "Configuration for outbound request concurrency."
required: false
description: """
Configuration for outbound request concurrency.

This can be set either to one of the below enum values or to a uint, which denotes
a fixed concurrency limit.
"""
required: false
type: {
string: {
default: "none"
default: "adaptive"
enum: {
adaptive: """
Concurrency will be managed by Vector's [Adaptive Request Concurrency][arc] feature.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,16 @@ base: components: sinks: aws_kinesis_firehose: configuration: {
}
}
concurrency: {
description: "Configuration for outbound request concurrency."
required: false
description: """
Configuration for outbound request concurrency.

This can be set either to one of the below enum values or to a uint, which denotes
a fixed concurrency limit.
"""
required: false
type: {
string: {
default: "none"
default: "adaptive"
enum: {
adaptive: """
Concurrency will be managed by Vector's [Adaptive Request Concurrency][arc] feature.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,16 @@ base: components: sinks: aws_kinesis_streams: configuration: {
}
}
concurrency: {
description: "Configuration for outbound request concurrency."
required: false
description: """
Configuration for outbound request concurrency.

This can be set either to one of the below enum values or to a uint, which denotes
a fixed concurrency limit.
"""
required: false
type: {
string: {
default: "none"
default: "adaptive"
enum: {
adaptive: """
Concurrency will be managed by Vector's [Adaptive Request Concurrency][arc] feature.
Expand Down
11 changes: 8 additions & 3 deletions website/cue/reference/components/sinks/base/aws_s3.cue
Original file line number Diff line number Diff line change
Expand Up @@ -726,11 +726,16 @@ base: components: sinks: aws_s3: configuration: {
}
}
concurrency: {
description: "Configuration for outbound request concurrency."
required: false
description: """
Configuration for outbound request concurrency.

This can be set either to one of the below enum values or to a uint, which denotes
a fixed concurrency limit.
"""
required: false
type: {
string: {
default: "none"
default: "adaptive"
enum: {
adaptive: """
Concurrency will be managed by Vector's [Adaptive Request Concurrency][arc] feature.
Expand Down
11 changes: 8 additions & 3 deletions website/cue/reference/components/sinks/base/aws_sns.cue
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,16 @@ base: components: sinks: aws_sns: configuration: {
}
}
concurrency: {
description: "Configuration for outbound request concurrency."
required: false
description: """
Configuration for outbound request concurrency.

This can be set either to one of the below enum values or to a uint, which denotes
a fixed concurrency limit.
"""
required: false
type: {
string: {
default: "none"
default: "adaptive"
enum: {
adaptive: """
Concurrency will be managed by Vector's [Adaptive Request Concurrency][arc] feature.
Expand Down
11 changes: 8 additions & 3 deletions website/cue/reference/components/sinks/base/aws_sqs.cue
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,16 @@ base: components: sinks: aws_sqs: configuration: {
}
}
concurrency: {
description: "Configuration for outbound request concurrency."
required: false
description: """
Configuration for outbound request concurrency.

This can be set either to one of the below enum values or to a uint, which denotes
a fixed concurrency limit.
"""
required: false
type: {
string: {
default: "none"
default: "adaptive"
enum: {
adaptive: """
Concurrency will be managed by Vector's [Adaptive Request Concurrency][arc] feature.
Expand Down
11 changes: 8 additions & 3 deletions website/cue/reference/components/sinks/base/axiom.cue
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,16 @@ base: components: sinks: axiom: configuration: {
}
}
concurrency: {
description: "Configuration for outbound request concurrency."
required: false
description: """
Configuration for outbound request concurrency.

This can be set either to one of the below enum values or to a uint, which denotes
a fixed concurrency limit.
"""
required: false
type: {
string: {
default: "none"
default: "adaptive"
enum: {
adaptive: """
Concurrency will be managed by Vector's [Adaptive Request Concurrency][arc] feature.
Expand Down
11 changes: 8 additions & 3 deletions website/cue/reference/components/sinks/base/azure_blob.cue
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,16 @@ base: components: sinks: azure_blob: configuration: {
}
}
concurrency: {
description: "Configuration for outbound request concurrency."
required: false
description: """
Configuration for outbound request concurrency.

This can be set either to one of the below enum values or to a uint, which denotes
a fixed concurrency limit.
"""
required: false
type: {
string: {
default: "none"
default: "adaptive"
enum: {
adaptive: """
Concurrency will be managed by Vector's [Adaptive Request Concurrency][arc] feature.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,16 @@ base: components: sinks: azure_monitor_logs: configuration: {
}
}
concurrency: {
description: "Configuration for outbound request concurrency."
required: false
description: """
Configuration for outbound request concurrency.

This can be set either to one of the below enum values or to a uint, which denotes
a fixed concurrency limit.
"""
required: false
type: {
string: {
default: "none"
default: "adaptive"
enum: {
adaptive: """
Concurrency will be managed by Vector's [Adaptive Request Concurrency][arc] feature.
Expand Down
11 changes: 8 additions & 3 deletions website/cue/reference/components/sinks/base/clickhouse.cue
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,16 @@ base: components: sinks: clickhouse: configuration: {
}
}
concurrency: {
description: "Configuration for outbound request concurrency."
required: false
description: """
Configuration for outbound request concurrency.

This can be set either to one of the below enum values or to a uint, which denotes
a fixed concurrency limit.
"""
required: false
type: {
string: {
default: "none"
default: "adaptive"
enum: {
adaptive: """
Concurrency will be managed by Vector's [Adaptive Request Concurrency][arc] feature.
Expand Down
11 changes: 8 additions & 3 deletions website/cue/reference/components/sinks/base/databend.cue
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,16 @@ base: components: sinks: databend: configuration: {
}
}
concurrency: {
description: "Configuration for outbound request concurrency."
required: false
description: """
Configuration for outbound request concurrency.

This can be set either to one of the below enum values or to a uint, which denotes
a fixed concurrency limit.
"""
required: false
type: {
string: {
default: "none"
default: "adaptive"
enum: {
adaptive: """
Concurrency will be managed by Vector's [Adaptive Request Concurrency][arc] feature.
Expand Down
11 changes: 8 additions & 3 deletions website/cue/reference/components/sinks/base/datadog_events.cue
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,16 @@ base: components: sinks: datadog_events: configuration: {
}
}
concurrency: {
description: "Configuration for outbound request concurrency."
required: false
description: """
Configuration for outbound request concurrency.

This can be set either to one of the below enum values or to a uint, which denotes
a fixed concurrency limit.
"""
required: false
type: {
string: {
default: "none"
default: "adaptive"
enum: {
adaptive: """
Concurrency will be managed by Vector's [Adaptive Request Concurrency][arc] feature.
Expand Down
Loading