Skip to content

Commit 2f94d66

Browse files
authored
rename failover to fallback (#465)
1 parent 6096547 commit 2f94d66

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

bottlecap/src/config/mod.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ use crate::config::log_level::{deserialize_log_level, LogLevel};
1919
use crate::config::processing_rule::{deserialize_processing_rules, ProcessingRule};
2020
use crate::config::service_mapping::deserialize_service_mapping;
2121

22-
/// `FailoverConfig` is a struct that represents fields that are not supported in the extension yet.
22+
/// `FallbackConfig` is a struct that represents fields that are not supported in the extension yet.
2323
///
2424
/// `extension_version` is expected to be set to "next" to enable the optimized extension.
2525
#[derive(Debug, PartialEq, Deserialize, Clone, Default)]
2626
#[serde(default)]
2727
#[allow(clippy::module_name_repetitions)]
28-
pub struct FailoverConfig {
28+
pub struct FallbackConfig {
2929
extension_version: Option<String>,
3030
serverless_appsec_enabled: bool,
3131
appsec_enabled: bool,
@@ -124,24 +124,24 @@ pub enum ConfigError {
124124
UnsupportedField(String),
125125
}
126126

127-
fn log_failover_reason(reason: &str) {
128-
println!("{{\"DD_EXTENSION_FAILOVER_REASON\":\"{reason}\"}}");
127+
fn log_fallback_reason(reason: &str) {
128+
println!("{{\"DD_EXTENSION_FALLBACK_REASON\":\"{reason}\"}}");
129129
}
130130

131-
fn failsover(figment: &Figment) -> Result<(), ConfigError> {
132-
let failover_config: FailoverConfig = match figment.extract() {
133-
Ok(failover_config) => failover_config,
131+
fn fallback(figment: &Figment) -> Result<(), ConfigError> {
132+
let fallback_config: FallbackConfig = match figment.extract() {
133+
Ok(fallback_config) => fallback_config,
134134
Err(err) => {
135135
println!("Failed to parse Datadog config: {err}");
136136
return Err(ConfigError::ParseError(err.to_string()));
137137
}
138138
};
139139

140-
let opted_in = match failover_config.extension_version.as_deref() {
140+
let opted_in = match fallback_config.extension_version.as_deref() {
141141
Some("next") => true,
142142
// Only log when the field is present but its not "next"
143143
Some(_) => {
144-
log_failover_reason("extension_version");
144+
log_fallback_reason("extension_version");
145145
false
146146
}
147147
_ => false,
@@ -153,13 +153,13 @@ fn failsover(figment: &Figment) -> Result<(), ConfigError> {
153153
));
154154
}
155155

156-
if failover_config.serverless_appsec_enabled || failover_config.appsec_enabled {
157-
log_failover_reason("appsec_enabled");
156+
if fallback_config.serverless_appsec_enabled || fallback_config.appsec_enabled {
157+
log_fallback_reason("appsec_enabled");
158158
return Err(ConfigError::UnsupportedField("appsec_enabled".to_string()));
159159
}
160160

161-
if failover_config.profiling_enabled {
162-
log_failover_reason("profiling_enabled");
161+
if fallback_config.profiling_enabled {
162+
log_fallback_reason("profiling_enabled");
163163
return Err(ConfigError::UnsupportedField(
164164
"profiling_enabled".to_string(),
165165
));
@@ -182,8 +182,7 @@ pub fn get_config(config_directory: &Path) -> Result<Config, ConfigError> {
182182
// Get YAML nested fields
183183
let yaml_figment = Figment::from(Yaml::file(&path));
184184

185-
// Failover
186-
failsover(&figment)?;
185+
fallback(&figment)?;
187186

188187
let (mut config, yaml_config): (Config, YamlConfig) =
189188
match (figment.extract(), yaml_figment.extract()) {

0 commit comments

Comments
 (0)