Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions launchdarkly-server-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ 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"] }
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]
Expand Down
4 changes: 2 additions & 2 deletions launchdarkly-server-sdk/src/events/dispatcher.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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())),
}
}

Expand Down
4 changes: 2 additions & 2 deletions launchdarkly-server-sdk/src/migrations/migrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -219,7 +219,7 @@ where
measure_errors,
read_config,
write_config,
sampler: Box::new(ThreadRngSampler::new(thread_rng())),
sampler: Box::new(ThreadRngSampler::new(rng())),
}
}

Expand Down
4 changes: 2 additions & 2 deletions launchdarkly-server-sdk/src/migrations/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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());
}
}
Expand Down
6 changes: 3 additions & 3 deletions launchdarkly-server-sdk/src/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<R: Rng> Sampler for ThreadRngSampler<R> {
return true;
}

self.rng.gen_ratio(1, ratio)
self.rng.random_ratio(1, ratio)
}
}

Expand All @@ -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));
}

Expand Down