mirror of
https://github.com/tower-rs/tower.git
synced 2025-12-31 13:50:49 +00:00
`MakeBalance`'s use of `SmallRng` is problematic: since it clones the `SmallRng` between `Balance` instances, each instance will have the same state and produce an identical sequence of values. This probably isn't _dangerous_, though it is certainly unexpected. This change removes the `MakeBalance::from_rng` and `MakeBalanceLayer::from_rng` helpers. The `MakeBalance` service now uses the default RNG via `Balance::new`. `Balance::new` now creates its `SmallRng` from the `thread_rng` instead of the default entropy source, as the default entropy source may use the slower `getrandom`. From the [`rand` docs][from_entropy]: > In case the overhead of using getrandom to seed many PRNGs is an > issue, one may prefer to seed from a local PRNG, e.g. > from_rng(thread_rng()).unwrap(). Finally, this change updates the balnancer to the most recent version of `rand`, v0.8.0. [from_entropy]: https://docs.rs/rand/0.8.0/rand/trait.SeedableRng.html#method.from_entropy
23 lines
500 B
TOML
23 lines
500 B
TOML
[package]
|
|
name = "examples"
|
|
version = "0.0.0"
|
|
publish = false
|
|
edition = "2018"
|
|
|
|
# If you copy one of the examples into a new project, you should be using
|
|
# [dependencies] instead.
|
|
[dev-dependencies]
|
|
tower = { version = "0.4", path = "../tower", features = ["full"] }
|
|
tower-service = "0.3"
|
|
tokio = { version = "0.3", features = ["full"] }
|
|
rand = "0.8"
|
|
pin-project = "1.0"
|
|
futures = "0.3"
|
|
tracing = "0.1"
|
|
tracing-subscriber = "0.2"
|
|
hdrhistogram = "7"
|
|
|
|
[[example]]
|
|
name = "balance"
|
|
path = "balance.rs"
|