From bcf88334cdac8c3231702f5902ba86c0ee0ec7c1 Mon Sep 17 00:00:00 2001 From: Christopher Kolstad Date: Wed, 15 Jan 2025 18:45:37 +0100 Subject: [PATCH 01/10] chore(ci): set source folder to be files, not git --- .github/workflows/build-debug-docker-with-chef.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-debug-docker-with-chef.yaml b/.github/workflows/build-debug-docker-with-chef.yaml index 0cb805be..1033f9b3 100644 --- a/.github/workflows/build-debug-docker-with-chef.yaml +++ b/.github/workflows/build-debug-docker-with-chef.yaml @@ -114,6 +114,7 @@ jobs: ./docker-bake.hcl /tmp/bake-meta.json targets: image + source: . set: | *.tags= *.platform=${{ matrix.platform }} From bf124780e63071765650c376d4e8a2076c6d729d Mon Sep 17 00:00:00 2001 From: sjaanus Date: Wed, 15 Jan 2025 14:15:56 +0200 Subject: [PATCH 02/10] feat: start logging diff comparing with delta --- Cargo.lock | 26 ++++++++-- server/Cargo.toml | 5 +- server/src/http/refresher/delta_refresher.rs | 51 ++++++++++++++++++-- 3 files changed, 71 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bcf89a59..422db6b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1495,6 +1495,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + [[package]] name = "digest" version = "0.10.7" @@ -2469,6 +2475,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "json-structural-diff" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e878e36a8a44c158505c2c818abdc1350413ad83dcb774a0459f6a7ef2b65cbf" +dependencies = [ + "difflib", + "regex", + "serde_json", +] + [[package]] name = "language-tags" version = "0.3.2" @@ -4555,6 +4572,7 @@ dependencies = [ "futures-core", "iter_tools", "itertools 0.14.0", + "json-structural-diff", "lazy_static", "maplit", "num_cpus", @@ -4593,9 +4611,9 @@ dependencies = [ [[package]] name = "unleash-types" -version = "0.15.3" +version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ead505b176bd504c31815a4804d305789c3cbd6f89e932d118cd0830a955f0" +checksum = "7e00ce8bb376d199edf068d04756f9cee78a561dbdb4cf49ebcad35cb452e3d5" dependencies = [ "base64 0.22.1", "chrono", @@ -4608,9 +4626,9 @@ dependencies = [ [[package]] name = "unleash-yggdrasil" -version = "0.14.5" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b92adb844a4723d5eed3fc757dccd37f03ac5eaeef59f2be4de5aa0962b223b8" +checksum = "c7658e226f9bc375aaeb408321f7d7803a4d4d58b297e40fb8ea72930671cb06" dependencies = [ "chrono", "convert_case 0.6.0", diff --git a/server/Cargo.toml b/server/Cargo.toml index 007ea3cd..fada3835 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -47,6 +47,7 @@ futures = "0.3.31" futures-core = "0.3.31" iter_tools = "0.24.0" itertools = "0.14.0" +json-structural-diff = "0.2.0" lazy_static = "1.5.0" num_cpus = "1.16.0" opentelemetry = { version = "0.27.1", features = ["trace", "metrics"] } @@ -94,8 +95,8 @@ tokio-stream = { version = "0.1.17" } tracing = { version = "0.1.41", features = ["log"] } tracing-subscriber = { version = "0.3.19", features = ["json", "env-filter"] } ulid = "1.1.4" -unleash-types = { version = "0.15.3", features = ["openapi", "hashes"] } -unleash-yggdrasil = { version = "0.14.5" } +unleash-types = { version = "0.15.4", features = ["openapi", "hashes"] } +unleash-yggdrasil = { version = "0.14.6" } utoipa = { version = "5.3.1", features = ["actix_extras", "chrono"] } utoipa-swagger-ui = { version = "8.1.1", features = ["actix-web"] } [dev-dependencies] diff --git a/server/src/http/refresher/delta_refresher.rs b/server/src/http/refresher/delta_refresher.rs index 972d5052..ec5b1021 100644 --- a/server/src/http/refresher/delta_refresher.rs +++ b/server/src/http/refresher/delta_refresher.rs @@ -1,11 +1,15 @@ +use std::fs::File; +use std::io::Write; use actix_web::http::header::EntityTag; +use json_structural_diff::JsonDiff; use reqwest::StatusCode; +use serde_json::Value; use tracing::{debug, info, warn}; use unleash_types::client_features::{ClientFeaturesDelta}; use unleash_yggdrasil::EngineState; use crate::error::{EdgeError, FeatureError}; -use crate::types::{ClientFeaturesDeltaResponse, ClientFeaturesRequest, EdgeToken, TokenRefresh}; +use crate::types::{ClientFeaturesDeltaResponse, ClientFeaturesRequest, ClientFeaturesResponse, EdgeToken, TokenRefresh}; use crate::http::refresher::feature_refresher::FeatureRefresher; use crate::tokens::cache_key; @@ -47,14 +51,14 @@ impl FeatureRefresher { } pub async fn refresh_single_delta(&self, refresh: TokenRefresh) { - let features_result = self + let delta_result = self .unleash_client .get_client_features_delta(ClientFeaturesRequest { api_key: refresh.token.token.clone(), - etag: refresh.etag, + etag: refresh.etag.clone(), }) .await; - match features_result { + match delta_result { Ok(delta_response) => match delta_response { ClientFeaturesDeltaResponse::NoUpdate(tag) => { debug!("No update needed. Will update last check time with {tag}"); @@ -62,7 +66,8 @@ impl FeatureRefresher { } ClientFeaturesDeltaResponse::Updated(features, etag) => { self.handle_client_features_delta_updated(&refresh.token, features, etag) - .await + .await; + self.compare_delta_cache(&refresh).await; } }, Err(e) => { @@ -111,6 +116,42 @@ impl FeatureRefresher { } } } + + async fn compare_delta_cache(&self, + refresh: &TokenRefresh, + ) { + let features_result = self + .unleash_client + .get_client_features(ClientFeaturesRequest { + api_key: refresh.token.token.clone(), + etag: refresh.clone().etag, + }) + .await; + + let key = cache_key(&refresh.token); + if let Some(delta_features) = self.features_cache.get(&key).as_ref() { + if let Ok(ClientFeaturesResponse::Updated(features, _etag)) = features_result { + let d_features = &delta_features.features; + let o_features = features.features; + + let delta_json = serde_json::to_value(&d_features).unwrap(); + let old_json = serde_json::to_value(&o_features).unwrap(); + + let delta_json_len = delta_json.to_string().len(); + let old_json_len = old_json.to_string().len(); + + if delta_json_len == old_json_len { + println!("The JSON structures are identical."); + } else { + debug!("Structural differences found:"); + debug!("Length of delta_json: {}", delta_json_len); + debug!("Length of old_json: {}", old_json_len); + let diff = JsonDiff::diff(&delta_json, &old_json, false); + debug!("{:?}", diff.diff.unwrap()); + } + } + } + } } From 28b0b9220c3962d25ae14aef0c7950b90b6eca22 Mon Sep 17 00:00:00 2001 From: sjaanus Date: Wed, 15 Jan 2025 14:27:37 +0200 Subject: [PATCH 03/10] feat: start logging diff comparing with delta --- server/src/builder.rs | 1 + server/src/cli.rs | 4 ++ server/src/http/refresher/delta_refresher.rs | 37 +++++++++---------- .../src/http/refresher/feature_refresher.rs | 6 +++ 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/server/src/builder.rs b/server/src/builder.rs index f6130ec5..e4a849e6 100644 --- a/server/src/builder.rs +++ b/server/src/builder.rs @@ -271,6 +271,7 @@ async fn build_edge( refresher_mode, client_meta_information, args.delta, + args.delta_diff ); let feature_refresher = Arc::new(FeatureRefresher::new( unleash_client, diff --git a/server/src/cli.rs b/server/src/cli.rs index e4b6108e..d826b4a1 100644 --- a/server/src/cli.rs +++ b/server/src/cli.rs @@ -221,6 +221,10 @@ pub struct EdgeArgs { #[clap(long, env, default_value_t = false, requires = "strict")] pub delta: bool, + /// If set to true, it compares features payload with delta payload and logs diff. This is experimental feature and might and change. Requires strict mode + #[clap(long, env, default_value_t = false, requires = "strict")] + pub delta_diff: bool, + /// Sets a remote write url for prometheus metrics, if this is set, prometheus metrics will be written upstream #[clap(long, env)] pub prometheus_remote_write_url: Option, diff --git a/server/src/http/refresher/delta_refresher.rs b/server/src/http/refresher/delta_refresher.rs index ec5b1021..8962cc7f 100644 --- a/server/src/http/refresher/delta_refresher.rs +++ b/server/src/http/refresher/delta_refresher.rs @@ -1,17 +1,17 @@ -use std::fs::File; -use std::io::Write; use actix_web::http::header::EntityTag; use json_structural_diff::JsonDiff; use reqwest::StatusCode; -use serde_json::Value; use tracing::{debug, info, warn}; -use unleash_types::client_features::{ClientFeaturesDelta}; +use unleash_types::client_features::ClientFeaturesDelta; use unleash_yggdrasil::EngineState; use crate::error::{EdgeError, FeatureError}; -use crate::types::{ClientFeaturesDeltaResponse, ClientFeaturesRequest, ClientFeaturesResponse, EdgeToken, TokenRefresh}; use crate::http::refresher::feature_refresher::FeatureRefresher; use crate::tokens::cache_key; +use crate::types::{ + ClientFeaturesDeltaResponse, ClientFeaturesRequest, ClientFeaturesResponse, EdgeToken, + TokenRefresh, +}; impl FeatureRefresher { async fn handle_client_features_delta_updated( @@ -117,9 +117,7 @@ impl FeatureRefresher { } } - async fn compare_delta_cache(&self, - refresh: &TokenRefresh, - ) { + async fn compare_delta_cache(&self, refresh: &TokenRefresh) { let features_result = self .unleash_client .get_client_features(ClientFeaturesRequest { @@ -141,11 +139,11 @@ impl FeatureRefresher { let old_json_len = old_json.to_string().len(); if delta_json_len == old_json_len { - println!("The JSON structures are identical."); + info!("The JSON structures are identical."); } else { - debug!("Structural differences found:"); - debug!("Length of delta_json: {}", delta_json_len); - debug!("Length of old_json: {}", old_json_len); + info!("Structural differences found:"); + info!("Length of delta_json: {}", delta_json_len); + info!("Length of old_json: {}", old_json_len); let diff = JsonDiff::diff(&delta_json, &old_json, false); debug!("{:?}", diff.diff.unwrap()); } @@ -154,10 +152,13 @@ impl FeatureRefresher { } } - #[cfg(feature = "delta")] #[cfg(test)] mod tests { + use crate::feature_cache::FeatureCache; + use crate::http::refresher::feature_refresher::FeatureRefresher; + use crate::http::unleash_client::{ClientMetaInformation, UnleashClient}; + use crate::types::EdgeToken; use actix_http::header::IF_NONE_MATCH; use actix_http::HttpService; use actix_http_test::{test_server, TestServer}; @@ -168,10 +169,6 @@ mod tests { use chrono::Duration; use dashmap::DashMap; use std::sync::Arc; - use crate::feature_cache::FeatureCache; - use crate::http::refresher::feature_refresher::FeatureRefresher; - use crate::http::unleash_client::{ClientMetaInformation, UnleashClient}; - use crate::types::EdgeToken; use unleash_types::client_features::{ ClientFeature, ClientFeatures, ClientFeaturesDelta, Constraint, Operator, Segment, }; @@ -195,7 +192,7 @@ mod tests { strict: false, streaming: false, delta: true, - client_meta_information:ClientMetaInformation::test_config(), + client_meta_information: ClientMetaInformation::test_config(), }); let features = ClientFeatures { version: 2, @@ -311,8 +308,8 @@ mod tests { ))), |_| AppConfig::default(), )) - .tcp() + .tcp() }) - .await + .await } } diff --git a/server/src/http/refresher/feature_refresher.rs b/server/src/http/refresher/feature_refresher.rs index 3f647937..3a4ea172 100644 --- a/server/src/http/refresher/feature_refresher.rs +++ b/server/src/http/refresher/feature_refresher.rs @@ -52,6 +52,7 @@ pub struct FeatureRefresher { pub streaming: bool, pub client_meta_information: ClientMetaInformation, pub delta: bool, + pub delta_diff: bool, } impl Default for FeatureRefresher { @@ -67,6 +68,7 @@ impl Default for FeatureRefresher { streaming: false, client_meta_information: Default::default(), delta: false, + delta_diff: false, } } } @@ -105,6 +107,7 @@ pub struct FeatureRefreshConfig { mode: FeatureRefresherMode, client_meta_information: ClientMetaInformation, delta: bool, + delta_diff: bool, } impl FeatureRefreshConfig { @@ -113,12 +116,14 @@ impl FeatureRefreshConfig { mode: FeatureRefresherMode, client_meta_information: ClientMetaInformation, delta: bool, + delta_diff: bool, ) -> Self { Self { features_refresh_interval, mode, client_meta_information, delta, + delta_diff } } } @@ -142,6 +147,7 @@ impl FeatureRefresher { streaming: config.mode == FeatureRefresherMode::Streaming, client_meta_information: config.client_meta_information, delta: config.delta, + delta_diff: config.delta_diff, } } From b607dff1a457613d2c4d88012aeb34df3cfe01db Mon Sep 17 00:00:00 2001 From: sjaanus Date: Wed, 15 Jan 2025 14:52:50 +0200 Subject: [PATCH 04/10] feat: start logging diff comparing with delta --- server/src/http/refresher/delta_refresher.rs | 42 +--------------- .../src/http/refresher/feature_refresher.rs | 50 ++++++++++++++++--- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/server/src/http/refresher/delta_refresher.rs b/server/src/http/refresher/delta_refresher.rs index 8962cc7f..ced52809 100644 --- a/server/src/http/refresher/delta_refresher.rs +++ b/server/src/http/refresher/delta_refresher.rs @@ -1,5 +1,4 @@ use actix_web::http::header::EntityTag; -use json_structural_diff::JsonDiff; use reqwest::StatusCode; use tracing::{debug, info, warn}; use unleash_types::client_features::ClientFeaturesDelta; @@ -8,10 +7,7 @@ use unleash_yggdrasil::EngineState; use crate::error::{EdgeError, FeatureError}; use crate::http::refresher::feature_refresher::FeatureRefresher; use crate::tokens::cache_key; -use crate::types::{ - ClientFeaturesDeltaResponse, ClientFeaturesRequest, ClientFeaturesResponse, EdgeToken, - TokenRefresh, -}; +use crate::types::{ClientFeaturesDeltaResponse, ClientFeaturesRequest, EdgeToken, TokenRefresh}; impl FeatureRefresher { async fn handle_client_features_delta_updated( @@ -67,7 +63,6 @@ impl FeatureRefresher { ClientFeaturesDeltaResponse::Updated(features, etag) => { self.handle_client_features_delta_updated(&refresh.token, features, etag) .await; - self.compare_delta_cache(&refresh).await; } }, Err(e) => { @@ -116,40 +111,6 @@ impl FeatureRefresher { } } } - - async fn compare_delta_cache(&self, refresh: &TokenRefresh) { - let features_result = self - .unleash_client - .get_client_features(ClientFeaturesRequest { - api_key: refresh.token.token.clone(), - etag: refresh.clone().etag, - }) - .await; - - let key = cache_key(&refresh.token); - if let Some(delta_features) = self.features_cache.get(&key).as_ref() { - if let Ok(ClientFeaturesResponse::Updated(features, _etag)) = features_result { - let d_features = &delta_features.features; - let o_features = features.features; - - let delta_json = serde_json::to_value(&d_features).unwrap(); - let old_json = serde_json::to_value(&o_features).unwrap(); - - let delta_json_len = delta_json.to_string().len(); - let old_json_len = old_json.to_string().len(); - - if delta_json_len == old_json_len { - info!("The JSON structures are identical."); - } else { - info!("Structural differences found:"); - info!("Length of delta_json: {}", delta_json_len); - info!("Length of old_json: {}", old_json_len); - let diff = JsonDiff::diff(&delta_json, &old_json, false); - debug!("{:?}", diff.diff.unwrap()); - } - } - } - } } #[cfg(feature = "delta")] @@ -192,6 +153,7 @@ mod tests { strict: false, streaming: false, delta: true, + delta_diff : false, client_meta_information: ClientMetaInformation::test_config(), }); let features = ClientFeatures { diff --git a/server/src/http/refresher/feature_refresher.rs b/server/src/http/refresher/feature_refresher.rs index 3a4ea172..c62bce8a 100644 --- a/server/src/http/refresher/feature_refresher.rs +++ b/server/src/http/refresher/feature_refresher.rs @@ -6,6 +6,7 @@ use chrono::Utc; use dashmap::DashMap; use eventsource_client::Client; use futures::TryStreamExt; +use json_structural_diff::JsonDiff; use reqwest::StatusCode; use tracing::{debug, info, warn}; use unleash_types::client_features::{ClientFeatures}; @@ -18,9 +19,7 @@ use crate::filters::{filter_client_features, FeatureFilterSet}; use crate::http::headers::{ UNLEASH_APPNAME_HEADER, UNLEASH_CLIENT_SPEC_HEADER, UNLEASH_INSTANCE_ID_HEADER, }; -use crate::types::{ - build, EdgeResult, TokenType, TokenValidationStatus, -}; +use crate::types::{build, ClientFeaturesDeltaResponse, EdgeResult, TokenType, TokenValidationStatus}; use crate::{ persistence::EdgePersistence, tokens::{cache_key, simplify}, @@ -347,7 +346,9 @@ impl FeatureRefresher { ); match serde_json::from_str(&event.data) { - Ok(features) => { refresher.handle_client_features_updated(&token, features, None).await; } + Ok(features) => { + refresher.handle_client_features_updated(&token, features, None).await; + } Err(e) => { warn!("Could not parse features response to internal representation: {e:?}"); } } @@ -399,6 +400,40 @@ impl FeatureRefresher { Ok(()) } + async fn compare_delta_cache(&self, refresh: &TokenRefresh) { + let delta_result = self + .unleash_client + .get_client_features_delta(ClientFeaturesRequest { + api_key: refresh.token.token.clone(), + etag: refresh.etag.clone(), + }) + .await; + + let key = cache_key(&refresh.token); + if let Some(client_features) = self.features_cache.get(&key).as_ref() { + if let Ok(ClientFeaturesDeltaResponse::Updated(delta_features, _etag)) = delta_result { + let c_features = &client_features.features; + let d_features = delta_features.updated; + + let delta_json = serde_json::to_value(&d_features).unwrap(); + let client_json = serde_json::to_value(&c_features).unwrap(); + + let delta_json_len = delta_json.to_string().len(); + let client_json_len = client_json.to_string().len(); + + if delta_json_len == client_json_len { + info!("The JSON structures are identical."); + } else { + info!("Structural differences found:"); + info!("Length of delta_json: {}", delta_json_len); + info!("Length of old_json: {}", client_json_len); + let diff = JsonDiff::diff(&delta_json, &client_json, false); + debug!("{:?}", diff.diff.unwrap()); + } + } + } + } + pub async fn start_refresh_features_background_task(&self) { if self.streaming { loop { @@ -476,7 +511,7 @@ impl FeatureRefresher { .unleash_client .get_client_features(ClientFeaturesRequest { api_key: refresh.token.token.clone(), - etag: refresh.etag, + etag: refresh.etag.clone(), }) .await; @@ -488,7 +523,10 @@ impl FeatureRefresher { } ClientFeaturesResponse::Updated(features, etag) => { self.handle_client_features_updated(&refresh.token, features, etag) - .await + .await; + if cfg!(feature = "delta") && self.delta_diff { + self.compare_delta_cache(&refresh).await; + } } }, Err(e) => { From 1ad7436285ad68ae4d5c2eeecd669b2f3b4495a7 Mon Sep 17 00:00:00 2001 From: sjaanus Date: Wed, 15 Jan 2025 15:06:03 +0200 Subject: [PATCH 05/10] Fix --- server/src/builder.rs | 1 + server/src/client_api.rs | 1 + server/src/http/refresher/feature_refresher.rs | 4 ++-- server/tests/streaming_test.rs | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/server/src/builder.rs b/server/src/builder.rs index e4a849e6..23c36d1b 100644 --- a/server/src/builder.rs +++ b/server/src/builder.rs @@ -388,6 +388,7 @@ mod tests { prometheus_username: None, streaming: false, delta: false, + delta_diff: false, }; let result = build_edge( diff --git a/server/src/client_api.rs b/server/src/client_api.rs index a19c9367..8b331110 100644 --- a/server/src/client_api.rs +++ b/server/src/client_api.rs @@ -1024,6 +1024,7 @@ mod tests { streaming: false, client_meta_information: ClientMetaInformation::test_config(), delta: false, + delta_diff: false, }); let token_validator = Arc::new(TokenValidator { unleash_client: unleash_client.clone(), diff --git a/server/src/http/refresher/feature_refresher.rs b/server/src/http/refresher/feature_refresher.rs index c62bce8a..a496b9e7 100644 --- a/server/src/http/refresher/feature_refresher.rs +++ b/server/src/http/refresher/feature_refresher.rs @@ -415,8 +415,8 @@ impl FeatureRefresher { let c_features = &client_features.features; let d_features = delta_features.updated; - let delta_json = serde_json::to_value(&d_features).unwrap(); - let client_json = serde_json::to_value(&c_features).unwrap(); + let delta_json = serde_json::to_value(d_features).unwrap(); + let client_json = serde_json::to_value(c_features).unwrap(); let delta_json_len = delta_json.to_string().len(); let client_json_len = client_json.to_string().len(); diff --git a/server/tests/streaming_test.rs b/server/tests/streaming_test.rs index 8ca9e674..88ccb211 100644 --- a/server/tests/streaming_test.rs +++ b/server/tests/streaming_test.rs @@ -212,6 +212,7 @@ mod streaming_test { strict: true, dynamic: false, delta: false, + delta_diff:false, prometheus_remote_write_url: None, prometheus_push_interval: 60, prometheus_username: None, From 5d4f25f57a032e7ded309d985fd6227c115b0b02 Mon Sep 17 00:00:00 2001 From: sjaanus Date: Wed, 15 Jan 2025 15:11:21 +0200 Subject: [PATCH 06/10] Fix --- server/src/http/refresher/feature_refresher.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/server/src/http/refresher/feature_refresher.rs b/server/src/http/refresher/feature_refresher.rs index a496b9e7..1a512b6a 100644 --- a/server/src/http/refresher/feature_refresher.rs +++ b/server/src/http/refresher/feature_refresher.rs @@ -346,9 +346,7 @@ impl FeatureRefresher { ); match serde_json::from_str(&event.data) { - Ok(features) => { - refresher.handle_client_features_updated(&token, features, None).await; - } + Ok(features) => { refresher.handle_client_features_updated(&token, features, None).await; } Err(e) => { warn!("Could not parse features response to internal representation: {e:?}"); } } @@ -422,7 +420,7 @@ impl FeatureRefresher { let client_json_len = client_json.to_string().len(); if delta_json_len == client_json_len { - info!("The JSON structures are identical."); + info!("The JSON structure lengths are identical."); } else { info!("Structural differences found:"); info!("Length of delta_json: {}", delta_json_len); From 603fa487b00753ecd1a95c2512a93092d26d9924 Mon Sep 17 00:00:00 2001 From: sjaanus Date: Wed, 15 Jan 2025 16:25:31 +0200 Subject: [PATCH 07/10] Fix --- server/src/http/refresher/delta_refresher.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/server/src/http/refresher/delta_refresher.rs b/server/src/http/refresher/delta_refresher.rs index ced52809..fecafa30 100644 --- a/server/src/http/refresher/delta_refresher.rs +++ b/server/src/http/refresher/delta_refresher.rs @@ -1,13 +1,13 @@ use actix_web::http::header::EntityTag; use reqwest::StatusCode; use tracing::{debug, info, warn}; -use unleash_types::client_features::ClientFeaturesDelta; +use unleash_types::client_features::{ClientFeaturesDelta}; use unleash_yggdrasil::EngineState; use crate::error::{EdgeError, FeatureError}; +use crate::types::{ClientFeaturesDeltaResponse, ClientFeaturesRequest, EdgeToken, TokenRefresh}; use crate::http::refresher::feature_refresher::FeatureRefresher; use crate::tokens::cache_key; -use crate::types::{ClientFeaturesDeltaResponse, ClientFeaturesRequest, EdgeToken, TokenRefresh}; impl FeatureRefresher { async fn handle_client_features_delta_updated( @@ -62,7 +62,7 @@ impl FeatureRefresher { } ClientFeaturesDeltaResponse::Updated(features, etag) => { self.handle_client_features_delta_updated(&refresh.token, features, etag) - .await; + .await } }, Err(e) => { @@ -113,13 +113,10 @@ impl FeatureRefresher { } } + #[cfg(feature = "delta")] #[cfg(test)] mod tests { - use crate::feature_cache::FeatureCache; - use crate::http::refresher::feature_refresher::FeatureRefresher; - use crate::http::unleash_client::{ClientMetaInformation, UnleashClient}; - use crate::types::EdgeToken; use actix_http::header::IF_NONE_MATCH; use actix_http::HttpService; use actix_http_test::{test_server, TestServer}; @@ -130,6 +127,10 @@ mod tests { use chrono::Duration; use dashmap::DashMap; use std::sync::Arc; + use crate::feature_cache::FeatureCache; + use crate::http::refresher::feature_refresher::FeatureRefresher; + use crate::http::unleash_client::{ClientMetaInformation, UnleashClient}; + use crate::types::EdgeToken; use unleash_types::client_features::{ ClientFeature, ClientFeatures, ClientFeaturesDelta, Constraint, Operator, Segment, }; @@ -270,8 +271,8 @@ mod tests { ))), |_| AppConfig::default(), )) - .tcp() + .tcp() }) - .await + .await } } From 52dfa39282d688539521318c1fae045793f20fa9 Mon Sep 17 00:00:00 2001 From: sjaanus Date: Wed, 15 Jan 2025 16:27:08 +0200 Subject: [PATCH 08/10] Fix --- server/src/http/refresher/delta_refresher.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/http/refresher/delta_refresher.rs b/server/src/http/refresher/delta_refresher.rs index fecafa30..35fbb7f6 100644 --- a/server/src/http/refresher/delta_refresher.rs +++ b/server/src/http/refresher/delta_refresher.rs @@ -51,7 +51,7 @@ impl FeatureRefresher { .unleash_client .get_client_features_delta(ClientFeaturesRequest { api_key: refresh.token.token.clone(), - etag: refresh.etag.clone(), + etag: refresh.etag, }) .await; match delta_result { From 6ed30eaa9d5514ff74c0181c754e55c89378dc8d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Jan 2025 03:26:54 +0000 Subject: [PATCH 09/10] dep-update: bump aws-sdk-s3 from 1.68.0 to 1.69.0 (#668) Bumps [aws-sdk-s3](https://github.com/awslabs/aws-sdk-rust) from 1.68.0 to 1.69.0. - [Release notes](https://github.com/awslabs/aws-sdk-rust/releases) - [Commits](https://github.com/awslabs/aws-sdk-rust/commits) --- updated-dependencies: - dependency-name: aws-sdk-s3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 149 +++++++++++++++++++++++++++++++++++++++------- server/Cargo.toml | 2 +- 2 files changed, 127 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bcf89a59..4fd145bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -554,9 +554,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.5.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16d1aa50accc11a4b4d5c50f7fb81cc0cf60328259c587d0e6b0f11385bde46" +checksum = "bee7643696e7fdd74c10f9eb42848a87fe469d35eae9c3323f80aa98f350baac" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -580,9 +580,9 @@ dependencies = [ [[package]] name = "aws-sdk-s3" -version = "1.68.0" +version = "1.69.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5ddf1dc70287dc9a2f953766a1fe15e3e74aef02fd1335f2afa475c9b4f4fc" +checksum = "0a88f1c30e4ffa2464f910297c24736ff68cca9e8d2b7d52596b54efd99b9c1e" dependencies = [ "aws-credential-types", "aws-runtime", @@ -681,9 +681,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.2.6" +version = "1.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d3820e0c08d0737872ff3c7c1f21ebbb6693d832312d6152bf18ef50a5471c2" +checksum = "690118821e46967b3c4501d67d7d52dd75106a9c54cf36cefa1985cedbe94e05" dependencies = [ "aws-credential-types", "aws-smithy-eventstream", @@ -710,9 +710,9 @@ dependencies = [ [[package]] name = "aws-smithy-async" -version = "1.2.3" +version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427cb637d15d63d6f9aae26358e1c9a9c09d5aa490d64b09354c8217cfef0f28" +checksum = "fa59d1327d8b5053c54bf2eaae63bf629ba9e904434d0835a28ed3c0ed0a614e" dependencies = [ "futures-util", "pin-project-lite", @@ -721,15 +721,16 @@ dependencies = [ [[package]] name = "aws-smithy-checksums" -version = "0.60.13" +version = "0.62.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba1a71073fca26775c8b5189175ea8863afb1c9ea2cceb02a5de5ad9dfbaa795" +checksum = "f2f45a1c384d7a393026bc5f5c177105aa9fa68e4749653b985707ac27d77295" dependencies = [ "aws-smithy-http", "aws-smithy-types", "bytes", "crc32c", "crc32fast", + "crc64fast-nvme", "hex", "http 0.2.12", "http-body 0.4.6", @@ -742,9 +743,9 @@ dependencies = [ [[package]] name = "aws-smithy-eventstream" -version = "0.60.5" +version = "0.60.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cef7d0a272725f87e51ba2bf89f8c21e4df61b9e49ae1ac367a6d69916ef7c90" +checksum = "8b18559a41e0c909b77625adf2b8c50de480a8041e5e4a3f5f7d177db70abc5a" dependencies = [ "aws-smithy-types", "bytes", @@ -753,9 +754,9 @@ dependencies = [ [[package]] name = "aws-smithy-http" -version = "0.60.11" +version = "0.60.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8bc3e8fdc6b8d07d976e301c02fe553f72a39b7a9fea820e023268467d7ab6" +checksum = "7809c27ad8da6a6a68c454e651d4962479e81472aa19ae99e59f9aba1f9713cc" dependencies = [ "aws-smithy-eventstream", "aws-smithy-runtime-api", @@ -774,9 +775,9 @@ dependencies = [ [[package]] name = "aws-smithy-json" -version = "0.61.1" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee4e69cc50921eb913c6b662f8d909131bb3e6ad6cb6090d3a39b66fc5c52095" +checksum = "623a51127f24c30776c8b374295f2df78d92517386f77ba30773f15a30ce1422" dependencies = [ "aws-smithy-types", ] @@ -793,9 +794,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.7.6" +version = "1.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a05dd41a70fc74051758ee75b5c4db2c0ca070ed9229c3df50e9475cda1cb985" +checksum = "865f7050bbc7107a6c98a397a9fcd9413690c27fa718446967cf03b2d3ac517e" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -837,9 +838,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.2.11" +version = "1.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38ddc9bd6c28aeb303477170ddd183760a956a03e083b3902a990238a7e3792d" +checksum = "a28f6feb647fb5e0d5b50f0472c19a7db9462b74e2fec01bb0b44eedcc834e97" dependencies = [ "base64-simd", "bytes", @@ -872,9 +873,9 @@ dependencies = [ [[package]] name = "aws-types" -version = "1.3.3" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5221b91b3e441e6675310829fd8984801b772cb1546ef6c0e54dec9f1ac13fef" +checksum = "b0df5a18c4f951c645300d365fec53a61418bcf4650f604f85fe2a665bfaa0c2" dependencies = [ "aws-credential-types", "aws-smithy-async", @@ -1071,6 +1072,25 @@ dependencies = [ "log", ] +[[package]] +name = "cbindgen" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fce8dd7fcfcbf3a0a87d8f515194b49d6135acab73e18bd380d1d93bb1a15eb" +dependencies = [ + "clap", + "heck 0.4.1", + "indexmap 2.6.0", + "log", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn 2.0.87", + "tempfile", + "toml", +] + [[package]] name = "cc" version = "1.1.30" @@ -1146,7 +1166,7 @@ version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "syn 2.0.87", @@ -1267,6 +1287,21 @@ dependencies = [ "libc", ] +[[package]] +name = "crc" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + [[package]] name = "crc16" version = "0.4.0" @@ -1291,6 +1326,16 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crc64fast-nvme" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5e2ee08013e3f228d6d2394116c4549a6df77708442c62d887d83f68ef2ee37" +dependencies = [ + "cbindgen", + "crc", +] + [[package]] name = "crossbeam-utils" version = "0.8.20" @@ -1922,6 +1967,12 @@ dependencies = [ "foldhash", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "heck" version = "0.5.0" @@ -3737,6 +3788,15 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "serde_spanned" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -4319,6 +4379,40 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +dependencies = [ + "indexmap 2.6.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tower" version = "0.5.2" @@ -5081,6 +5175,15 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "winnow" +version = "0.6.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" +dependencies = [ + "memchr", +] + [[package]] name = "write16" version = "1.0.0" diff --git a/server/Cargo.toml b/server/Cargo.toml index 007ea3cd..c5b3b9b7 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -35,7 +35,7 @@ ahash = "0.8.11" anyhow = "1.0.95" async-trait = "0.1.85" aws-config = { version = "1.5.13", features = ["behavior-version-latest"] } -aws-sdk-s3 = { version = "1.68.0", features = ["behavior-version-latest"] } +aws-sdk-s3 = { version = "1.69.0", features = ["behavior-version-latest"] } base64 = "0.22.1" chrono = { version = "0.4.39", features = ["serde"] } cidr = "0.3.0" From 65e14211f7ea63761fccaffab15996c943d69c21 Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Thu, 16 Jan 2025 08:55:58 +0200 Subject: [PATCH 10/10] Update server/src/cli.rs Co-authored-by: Christopher Kolstad --- server/src/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/cli.rs b/server/src/cli.rs index d826b4a1..693d4999 100644 --- a/server/src/cli.rs +++ b/server/src/cli.rs @@ -221,7 +221,7 @@ pub struct EdgeArgs { #[clap(long, env, default_value_t = false, requires = "strict")] pub delta: bool, - /// If set to true, it compares features payload with delta payload and logs diff. This is experimental feature and might and change. Requires strict mode + /// If set to true, it compares features payload with delta payload and logs diff. This is experimental feature and might change. Requires strict mode #[clap(long, env, default_value_t = false, requires = "strict")] pub delta_diff: bool,