Skip to content

Commit

Permalink
Fixed build with recent rng crate changes
Browse files Browse the repository at this point in the history
Signed-off-by: SableDB <[email protected]>
  • Loading branch information
sabledb-io committed Jan 27, 2025
1 parent 73ebb45 commit 4782aed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions libsabledb/src/replication/cluster_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ static START: Once = Once::new();
impl ClusterManager {
pub fn with_options(options: Arc<StdRwLock<ServerOptions>>) -> Self {
START.call_once(|| {
let mut rng = rand::thread_rng();
let us = rng.gen_range(5000000..10_000000);
let mut rng = rand::rng();
let us = rng.random_range(5000000..10_000000);
CHECK_PRIMARY_ALIVE_INTERVAL.store(us, Ordering::Relaxed);
tracing::info!(
"Check primary interval is set to {} microseconds",
Expand Down
8 changes: 4 additions & 4 deletions libsabledb/src/server/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ impl Worker {

// pick reporting interval for this worker to avoid all workers
// contesting for the same lock
let mut rng = rand::thread_rng();
let secs = rng.gen_range(1..3);
let nanos = rng.gen_range(0..u32::MAX);
let mut rng = rand::rng();
let secs = rng.random_range(1..3);
let nanos = rng.random_range(0..u32::MAX);

// Tick task should be triggered in a random time for every worker
let tick_interval_micros = rng.gen_range(100000..150000);
let tick_interval_micros = rng.random_range(100000..150000);

// create the TLS acceptor for this thread
let acceptor = if self
Expand Down
4 changes: 2 additions & 2 deletions libsabledb/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ pub fn choose_multiple_values(
options: &[usize],
allow_dups: bool,
) -> Result<VecDeque<usize>, SableError> {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
let mut chosen = Vec::<usize>::new();
if allow_dups {
for _ in 0..count {
Expand All @@ -643,7 +643,7 @@ pub fn choose_multiple_values(
break;
}

let pos = rng.gen_range(0..unique_values.len());
let pos = rng.random_range(0..unique_values.len());
let Some(val) = unique_values.get(pos) else {
return Err(SableError::OtherError(format!(
"Internal error: failed to read from vector (len: {}, pos: {})",
Expand Down

0 comments on commit 4782aed

Please sign in to comment.