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

feat: streaming now enabled/disabled with runtime flag #605

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 7 additions & 3 deletions server/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -259,10 +259,14 @@ async fn build_edge(args: &EdgeArgs, app_name: &str) -> EdgeResult<EdgeInfo> {
unleash_client: unleash_client.clone(),
persistence: persistence.clone(),
});
let refresher_mode = match (args.strict, args.streaming) {
(_, true) => FeatureRefresherMode::Streaming,
(true, _) => FeatureRefresherMode::Strict,
_ => FeatureRefresherMode::Dynamic,
};
Comment on lines +262 to +266
Copy link
Contributor

@thomasheartman thomasheartman Dec 18, 2024

Choose a reason for hiding this comment

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

We could inline this, but this is ... probably clearer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, LGTM

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(
Expand Down
20 changes: 12 additions & 8 deletions server/src/http/feature_refresher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand All @@ -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,
}
}
Expand Down
Loading