diff --git a/server/src/builder.rs b/server/src/builder.rs index 61c72354..6209e93f 100644 --- a/server/src/builder.rs +++ b/server/src/builder.rs @@ -12,7 +12,7 @@ use unleash_yggdrasil::EngineState; use crate::cli::RedisMode; use crate::feature_cache::FeatureCache; -use crate::http::feature_refresher::FeatureRefreshConfig; +use crate::http::feature_refresher::{FeatureRefreshConfig, FeatureRefresherMode}; use crate::http::unleash_client::new_reqwest_client; use crate::offline::offline_hotload::{load_bootstrap, load_offline_engine_cache}; use crate::persistence::file::FilePersister; @@ -259,10 +259,14 @@ async fn build_edge(args: &EdgeArgs, app_name: &str) -> EdgeResult { unleash_client: unleash_client.clone(), persistence: persistence.clone(), }); + let refresher_mode = match (args.strict, args.streaming) { + (_, true) => FeatureRefresherMode::Streaming, + (true, _) => FeatureRefresherMode::Strict, + _ => FeatureRefresherMode::Dynamic, + }; let feature_config = FeatureRefreshConfig::new( Duration::seconds(args.features_refresh_interval_seconds as i64), - args.streaming, - args.strict, + refresher_mode, app_name.to_string(), ); let feature_refresher = Arc::new(FeatureRefresher::new( diff --git a/server/src/http/feature_refresher.rs b/server/src/http/feature_refresher.rs index fbb4a3d0..f169a2ed 100644 --- a/server/src/http/feature_refresher.rs +++ b/server/src/http/feature_refresher.rs @@ -86,24 +86,28 @@ fn client_application_from_token_and_name( } } +#[derive(Eq, PartialEq)] +pub enum FeatureRefresherMode { + Dynamic, + Streaming, + Strict, +} + pub struct FeatureRefreshConfig { features_refresh_interval: chrono::Duration, - strict: bool, - streaming: bool, + mode: FeatureRefresherMode, app_name: String, } impl FeatureRefreshConfig { pub fn new( features_refresh_interval: chrono::Duration, - strict: bool, - streaming: bool, + mode: FeatureRefresherMode, app_name: String, ) -> Self { Self { features_refresh_interval, - strict, - streaming, + mode, app_name, } } @@ -124,8 +128,8 @@ impl FeatureRefresher { engine_cache: engines, refresh_interval: config.features_refresh_interval, persistence, - strict: config.strict, - streaming: config.streaming, + strict: config.mode != FeatureRefresherMode::Dynamic, + streaming: config.mode == FeatureRefresherMode::Streaming, app_name: config.app_name, } }