diff --git a/launchdarkly-server-sdk/Cargo.toml b/launchdarkly-server-sdk/Cargo.toml index d122a81..2282ec8 100644 --- a/launchdarkly-server-sdk/Cargo.toml +++ b/launchdarkly-server-sdk/Cargo.toml @@ -20,16 +20,16 @@ features = ["event-compression"] chrono = "0.4.19" crossbeam-channel = "0.5.1" data-encoding = "2.3.2" -eventsource-client = { version = "0.13.0", default-features = false } +eventsource-client = { version = "0.14.0", default-features = false } futures = "0.3.12" lazy_static = "1.4.0" log = "0.4.14" -lru = { version = "0.12.0", default-features = false } +lru = { version = "0.13.0", default-features = false } ring = "0.17.5" launchdarkly-server-sdk-evaluation = "2.0.0" serde = { version = "1.0.132", features = ["derive"] } serde_json = { version = "1.0.73", features = ["float_roundtrip"] } -thiserror = "1.0" +thiserror = "2.0" tokio = { version = "1.17.0", features = ["rt-multi-thread"] } parking_lot = "0.12.0" tokio-stream = { version = "0.1.8", features = ["sync"] } @@ -37,7 +37,7 @@ moka = { version = "0.12.1", features = ["sync"] } uuid = {version = "1.2.2", features = ["v4"] } hyper = { version = "0.14.19", features = ["client", "http1", "http2", "tcp"] } hyper-rustls = { version = "0.24.1" , optional = true} -rand = "0.8" +rand = "0.9" flate2 = { version = "1.0.35", optional = true } [dev-dependencies] diff --git a/launchdarkly-server-sdk/src/events/dispatcher.rs b/launchdarkly-server-sdk/src/events/dispatcher.rs index 9d3ab3d..e208342 100644 --- a/launchdarkly-server-sdk/src/events/dispatcher.rs +++ b/launchdarkly-server-sdk/src/events/dispatcher.rs @@ -1,5 +1,5 @@ use crossbeam_channel::{bounded, select, tick, Receiver, Sender}; -use rand::thread_rng; +use rand::rng; use std::time::SystemTime; use launchdarkly_server_sdk_evaluation::Context; @@ -89,7 +89,7 @@ impl EventDispatcher { last_known_time: 0, disabled: false, thread_count: 5, - sampler: Box::new(ThreadRngSampler::new(thread_rng())), + sampler: Box::new(ThreadRngSampler::new(rng())), } } diff --git a/launchdarkly-server-sdk/src/migrations/migrator.rs b/launchdarkly-server-sdk/src/migrations/migrator.rs index b4b4ff0..d7d7ca8 100644 --- a/launchdarkly-server-sdk/src/migrations/migrator.rs +++ b/launchdarkly-server-sdk/src/migrations/migrator.rs @@ -6,7 +6,7 @@ use futures::future::join_all; use futures::future::BoxFuture; use futures::future::FutureExt; use launchdarkly_server_sdk_evaluation::Context; -use rand::thread_rng; +use rand::rng; use serde::Serialize; use crate::sampler::Sampler; @@ -219,7 +219,7 @@ where measure_errors, read_config, write_config, - sampler: Box::new(ThreadRngSampler::new(thread_rng())), + sampler: Box::new(ThreadRngSampler::new(rng())), } } diff --git a/launchdarkly-server-sdk/src/migrations/tracker.rs b/launchdarkly-server-sdk/src/migrations/tracker.rs index 2ff747f..547d294 100644 --- a/launchdarkly-server-sdk/src/migrations/tracker.rs +++ b/launchdarkly-server-sdk/src/migrations/tracker.rs @@ -4,7 +4,7 @@ use std::{ }; use launchdarkly_server_sdk_evaluation::{Context, Detail, Flag}; -use rand::thread_rng; +use rand::rng; use crate::{ events::event::{BaseEvent, EventFactory, MigrationOpEvent}, @@ -78,7 +78,7 @@ impl MigrationOpTracker { /// A callable is provided in case sampling rules do not require consistency checking to run. /// In this case, we can avoid the overhead of a function by not using the callable. pub fn consistent(&mut self, is_consistent: impl Fn() -> bool) { - if ThreadRngSampler::new(thread_rng()).sample(self.consistent_ratio.unwrap_or(1)) { + if ThreadRngSampler::new(rng()).sample(self.consistent_ratio.unwrap_or(1)) { self.consistent = Some(is_consistent()); } } diff --git a/launchdarkly-server-sdk/src/sampler.rs b/launchdarkly-server-sdk/src/sampler.rs index 1fe96d5..ce30646 100644 --- a/launchdarkly-server-sdk/src/sampler.rs +++ b/launchdarkly-server-sdk/src/sampler.rs @@ -24,7 +24,7 @@ impl Sampler for ThreadRngSampler { return true; } - self.rng.gen_ratio(1, ratio) + self.rng.random_ratio(1, ratio) } } @@ -36,13 +36,13 @@ mod tests { #[test] fn test_zero_is_false() { - let mut sampler = ThreadRngSampler::new(rand::thread_rng()); + let mut sampler = ThreadRngSampler::new(rand::rng()); assert!(!sampler.sample(0)); } #[test] fn test_one_is_true() { - let mut sampler = ThreadRngSampler::new(rand::thread_rng()); + let mut sampler = ThreadRngSampler::new(rand::rng()); assert!(sampler.sample(1)); }