Skip to content

Commit

Permalink
bumpup versions (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n authored Jan 29, 2025
1 parent 22d255f commit 9aae65a
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 111 deletions.
19 changes: 10 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ rustdoc-args = ["--cfg", "docsrs"]
[workspace.dependencies]
auto_impl = "1"
atomic_refcell = "0.1"
agnostic-lite = { version = "0.3", features = ["time"] }
agnostic = "0.5"
# agnostic-lite = { version = "0.3", features = ["time"], path = "../agnostic/lite" }
# agnostic = { version = "0.5", path = "../agnostic/agnostic" }
agnostic-lite = { version = "0.4", features = ["time"] }
agnostic = "0.6"
# agnostic-lite = { version = "0.4", features = ["time"], path = "../agnostic/agnostic-lite" }
# agnostic = { version = "0.6", path = "../agnostic/agnostic" }
async-lock = "3"
async-channel = "2"
bytes = "1"
Expand All @@ -40,14 +40,15 @@ derive_more = { version = "1", features = ["full"] }
futures = "0.3"
indexmap = "2"
getifs = "0.2"
getrandom = "0.3"
metrics = "0.24"
nodecraft = { version = "0.4", features = [
nodecraft = { version = "0.5", features = [
"transformable",
"async",
"resolver",
"agnostic",
] }
# nodecraft = { version = "0.4", path = "../nodecraft", features = [
# nodecraft = { version = "0.5", path = "../nodecraft", features = [
# "transformable",
# "async",
# "resolver",
Expand All @@ -67,7 +68,7 @@ thiserror = "2"
tracing = "0.1"
viewit = "0.1.5"

memberlist-core = { version = "0.3", path = "core", default-features = false }
memberlist-net = { version = "0.3", path = "transports/net", default-features = false }
memberlist-core = { version = "0.4", path = "core", default-features = false }
memberlist-net = { version = "0.4", path = "transports/net", default-features = false }
memberlist-types = { version = "0.3", path = "types", default-features = false }
memberlist-quic = { version = "0.3", path = "transports/quic", default-features = false }
memberlist-quic = { version = "0.4", path = "transports/quic", default-features = false }
8 changes: 4 additions & 4 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "memberlist-core"
version = "0.3.1"
version = "0.4.0"
edition.workspace = true
license.workspace = true
repository.workspace = true
Expand Down Expand Up @@ -35,7 +35,7 @@ rkyv = ["dep:rkyv", "nodecraft/rkyv", "memberlist-types/rkyv"]
test = ["tracing-subscriber"]

[target.'cfg(target_family = "wasm")'.dependencies]
getrandom = { version = "0.2", features = ["js"] }
getrandom.workspace = true
once_cell = "1.17"

[target.'cfg(not(any(target_family = "wasm", windows)))'.dependencies]
Expand All @@ -60,7 +60,7 @@ transformable = { workspace = true, features = ["bytes1", "smol_str03"] }
paste.workspace = true
parking_lot = "0.12"
pin-project.workspace = true
rand = "0.8"
rand = "0.9"
scopeguard.workspace = true
smol_str.workspace = true
smallvec.workspace = true
Expand Down Expand Up @@ -91,7 +91,7 @@ tracing-subscriber = { version = "0.3", features = [
"tracing-log",
] }
agnostic = { workspace = true, features = ["net", "tokio"] }
rand = "0.8"
rand = "0.9"
tokio = { version = "1", features = ["full"] }
tokio-util = { version = "0.7", features = ["compat"] }
parking_lot = "0.12"
104 changes: 30 additions & 74 deletions core/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,88 +118,43 @@ where
pub(crate) node_map: HashMap<T::Id, usize>,
}

impl<T, D> rand::seq::SliceRandom for Members<T, D>
impl<T, D> core::ops::Index<usize> for Members<T, D>
where
D: Delegate<Id = T::Id, Address = <T::Resolver as AddressResolver>::ResolvedAddress>,
T: Transport,
{
type Item = Member<T, D>;
type Output = Member<T, D>;

fn choose<R>(&self, _rng: &mut R) -> Option<&Self::Item>
where
R: rand::Rng + ?Sized,
{
unreachable!()
}

fn choose_mut<R>(&mut self, _rng: &mut R) -> Option<&mut Self::Item>
where
R: rand::Rng + ?Sized,
{
unreachable!()
}

fn choose_multiple<R>(
&self,
_rng: &mut R,
_amount: usize,
) -> rand::seq::SliceChooseIter<Self, Self::Item>
where
R: rand::Rng + ?Sized,
{
unreachable!()
}

fn choose_weighted<R, F, B, X>(
&self,
_rng: &mut R,
_weight: F,
) -> Result<&Self::Item, rand::distributions::WeightedError>
where
R: rand::Rng + ?Sized,
F: Fn(&Self::Item) -> B,
B: rand::distributions::uniform::SampleBorrow<X>,
X: rand::distributions::uniform::SampleUniform
+ for<'a> core::ops::AddAssign<&'a X>
+ core::cmp::PartialOrd<X>
+ Clone
+ Default,
{
unreachable!()
fn index(&self, index: usize) -> &Self::Output {
&self.nodes[index]
}
}

fn choose_weighted_mut<R, F, B, X>(
&mut self,
_rng: &mut R,
_weight: F,
) -> Result<&mut Self::Item, rand::distributions::WeightedError>
where
R: rand::Rng + ?Sized,
F: Fn(&Self::Item) -> B,
B: rand::distributions::uniform::SampleBorrow<X>,
X: rand::distributions::uniform::SampleUniform
+ for<'a> core::ops::AddAssign<&'a X>
+ core::cmp::PartialOrd<X>
+ Clone
+ Default,
{
unreachable!()
impl<T, D> core::ops::IndexMut<usize> for Members<T, D>
where
D: Delegate<Id = T::Id, Address = <T::Resolver as AddressResolver>::ResolvedAddress>,
T: Transport,
{
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
&mut self.nodes[index]
}
}

fn choose_multiple_weighted<R, F, X>(
&self,
_rng: &mut R,
_amount: usize,
_weight: F,
) -> Result<rand::seq::SliceChooseIter<Self, Self::Item>, rand::distributions::WeightedError>
where
R: rand::Rng + ?Sized,
F: Fn(&Self::Item) -> X,
X: Into<f64>,
{
unreachable!()
impl<T, D> rand::seq::IndexedRandom for Members<T, D>
where
D: Delegate<Id = T::Id, Address = <T::Resolver as AddressResolver>::ResolvedAddress>,
T: Transport,
{
fn len(&self) -> usize {
self.nodes.len()
}
}

impl<T, D> rand::seq::SliceRandom for Members<T, D>
where
D: Delegate<Id = T::Id, Address = <T::Resolver as AddressResolver>::ResolvedAddress>,
T: Transport,
{
fn shuffle<R>(&mut self, rng: &mut R)
where
R: rand::Rng + ?Sized,
Expand All @@ -210,9 +165,9 @@ where
#[inline]
fn gen_index<R: rand::Rng + ?Sized>(rng: &mut R, ubound: usize) -> usize {
if ubound <= (u32::MAX as usize) {
rng.gen_range(0..ubound as u32) as usize
rng.random_range(0..ubound as u32) as usize
} else {
rng.gen_range(0..ubound)
rng.random_range(0..ubound)
}
}

Expand All @@ -231,8 +186,9 @@ where
&mut self,
_rng: &mut R,
_amount: usize,
) -> (&mut [Self::Item], &mut [Self::Item])
) -> (&mut [Self::Output], &mut [Self::Output])
where
Self::Output: Sized,
R: rand::Rng + ?Sized,
{
unreachable!()
Expand Down
13 changes: 7 additions & 6 deletions core/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,9 @@ where
let interval = self.inner.opts.push_pull_interval;
let this = self.clone();
// Use a random stagger to avoid syncronizing
let mut rng = rand::thread_rng();
let rand_stagger = Duration::from_millis(rng.gen_range(0..interval.as_millis() as u64));
let mut rng = rand::rng();

let rand_stagger = Duration::from_millis(rng.random_range(0..interval.as_millis() as u64));

<T::Runtime as RuntimeLite>::spawn(async move {
futures::select! {
Expand Down Expand Up @@ -1168,7 +1169,7 @@ where
.store(dead_idx as u32, Ordering::Release);

// Shuffle live nodes
memberlist.shuffle(&mut rand::thread_rng());
memberlist.shuffle(&mut rand::rng());
}

/// Invoked every GossipInterval period to broadcast our gossip
Expand Down Expand Up @@ -1385,7 +1386,7 @@ fn random_nodes<I, A>(
let mut i = 0;

while i < rounds && i < n {
let j = rand::random::<usize>() % (n - i) + i;
let j = (rand::random::<u64>() as usize) % (n - i) + i;
nodes.swap(i, j);
i += 1;
if i >= k && i >= rounds {
Expand All @@ -1399,8 +1400,8 @@ fn random_nodes<I, A>(

#[inline]
fn random_stagger(duration: Duration) -> Duration {
let mut rng = rand::thread_rng();
Duration::from_nanos(rng.gen_range(0..u64::MAX) % (duration.as_nanos() as u64))
let mut rng = rand::rng();
Duration::from_nanos(rng.random_range(0..u64::MAX) % (duration.as_nanos() as u64))
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions transports/net/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "memberlist-net"
version = "0.3.2"
version = "0.4.0"
edition.workspace = true
license.workspace = true
repository.workspace = true
Expand Down Expand Up @@ -61,7 +61,7 @@ dnssec-ring = ["dns", "nodecraft/dnssec-ring"]
dnssec = ["dns", "nodecraft/dnssec"]

[target.'cfg(target_family = "wasm")'.dependencies]
getrandom = { version = "0.2", features = ["js"] }
getrandom.workspace = true

[dependencies]
atomic_refcell.workspace = true
Expand All @@ -78,7 +78,7 @@ getifs.workspace = true
nodecraft = { workspace = true, features = ["async", "resolver", "agnostic"] }
peekable = { version = "0.2", features = ["future"] }
pin-project.workspace = true
rand = "0.8"
rand = "0.9"
memberlist-core.workspace = true
thiserror.workspace = true
tracing.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion transports/net/src/security.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn pkcs7decode(buf: &mut BytesMut) {
pub(super) fn write_header(dst: &mut BytesMut) -> [u8; NONCE_SIZE] {
// Add a random nonce
let mut nonce = [0u8; NONCE_SIZE];
rand::thread_rng().fill(&mut nonce);
rand::rng().fill(&mut nonce);
dst.put_slice(&nonce);

nonce
Expand Down
24 changes: 12 additions & 12 deletions transports/quic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "memberlist-quic"
version = "0.3.1"
version = "0.4.0"
edition.workspace = true
license.workspace = true
repository.workspace = true
Expand Down Expand Up @@ -31,17 +31,17 @@ smol = ["agnostic/smol"]

# enable DNS node address resolver
dns = ["nodecraft/dns", "agnostic/dns"]
dns-over-quic = ["dns", "nodecraft/dns-over-quic"]
dns-over-h3 = ["dns", "nodecraft/dns-over-h3"]
dns-over-https-rustls = ["dns", "nodecraft/dns-over-https-rustls"]
dns-over-rustls = ["dns", "nodecraft/dns-over-rustls"]
dns-over-openssl = ["dns", "nodecraft/dns-over-openssl"]
dns-over-native-tls = ["dns", "nodecraft/dns-over-native-tls"]
dns-webpki-roots = ["dns", "nodecraft/dns-webpki-roots"]
dns-native-certs = ["dns", "nodecraft/dns-native-certs"]
dnssec-openssl = ["dns", "nodecraft/dnssec-openssl"]
dnssec-ring = ["dns", "nodecraft/dnssec-ring"]
dnssec = ["dns", "nodecraft/dnssec"]
dns-over-quic = ["dns", "nodecraft/dns-over-quic", "agnostic/dns-over-quic"]
dns-over-h3 = ["dns", "nodecraft/dns-over-h3", "agnostic/dns-over-h3"]
dns-over-https-rustls = ["dns", "nodecraft/dns-over-https-rustls", "agnostic/dns-over-https-rustls"]
dns-over-rustls = ["dns", "nodecraft/dns-over-rustls", "agnostic/dns-over-rustls"]
dns-over-openssl = ["dns", "nodecraft/dns-over-openssl", "agnostic/dns-over-openssl"]
dns-over-native-tls = ["dns", "nodecraft/dns-over-native-tls", "agnostic/dns-over-native-tls"]
dns-webpki-roots = ["dns", "nodecraft/dns-webpki-roots", "agnostic/dns-webpki-roots"]
dns-native-certs = ["dns", "nodecraft/dns-native-certs", "agnostic/dns-native-certs"]
dnssec-openssl = ["dns", "nodecraft/dnssec-openssl", "agnostic/dnssec-openssl"]
dnssec-ring = ["dns", "nodecraft/dnssec-ring", "agnostic/dnssec-ring"]
dnssec = ["dns", "nodecraft/dnssec", "agnostic/dnssec"]

# enable test feature
test = ["memberlist-core/test", "rcgen"]
Expand Down
4 changes: 2 additions & 2 deletions transports/quic/src/stream_layer/quinn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
time::{Duration, Instant},
};

use agnostic::{net::Net, Runtime};
use agnostic::Runtime;
use bytes::Bytes;
use futures::{AsyncReadExt, AsyncWriteExt};
use memberlist_core::transport::{TimeoutableReadStream, TimeoutableWriteStream};
Expand Down Expand Up @@ -70,7 +70,7 @@ impl<R: Runtime> StreamLayer for Quinn<R> {
self.opts.endpoint_config.clone(),
Some(self.opts.server_config.clone()),
sock,
Arc::new(<R::Net as Net>::Quinn::default()),
Arc::new(R::quinn()),
)?);

let local_addr = endpoint.local_addr()?;
Expand Down

0 comments on commit 9aae65a

Please sign in to comment.