linkerd2/proxy
Eliza Weisman fac845bdcd
proxy: Add a lazy version of ThreadRng (#936)
This is in preparation for landing the Tokio upgrade. 

In order to be generic over Tokio's current thread and threadpool executors,
a number of types in Conduit which were not previously `Send` are now required
to be `Send`. A majority of this work will be done in the main Tokio upgrade
PR, as it is in many cases not possible to make these types `Send` _without_
using the new Tokio API (in order to remove `Handle`s, etc.); however, I'm
factoring out everything possible and trying to land it in separate PRs.

The p2c load balancer constructed in `Outbound` is currently parameterized
over a random number generator. We currently construct it by getting the 
thread-local RNG, and passing it to the load balancer constructor. However,
the thread-local RNG is not `Send`. I've fixed this issue by creating a new
zero-sized empty struct type which implements `rand::Rng` simply by calling
`thread_rng()` every time its' called, and passing that to 
`choose::power_of_two_choices` instead. Since this is an empty type which 
contains no data, and the correct thread-local RNG is accessed whenever
the methods are called, this new type can trivially be `Send`. According to
the `rand` crate's documentation, this is the correct way to use `ThreadRng`
anyway:
> Retrieve the lazily-initialized thread-local random number generator, seeded
> by the system. Intended to be used in method chaining style, e.g. 
> `thread_rng().gen::<i32>()`.
> (from https://docs.rs/rand/0.4.2/rand/fn.thread_rng.html)

This shouldn't lead to any functional changes.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-05-11 17:26:23 -07:00
..
benches proxy: Fix metrics constructor in benches (#881) 2018-04-30 17:48:07 -07:00
controller-grpc proxy: Support destination label matching for tap (#817) 2018-04-19 17:58:45 -07:00
convert Prepare for the v0.3.0 release (#406) 2018-02-21 11:14:11 -08:00
futures-mpsc-lossy Prepare for the v0.3.0 release (#406) 2018-02-21 11:14:11 -08:00
router proxy/router: Implement LRU cache eviction (#925) 2018-05-10 19:06:31 -07:00
src proxy: Add a lazy version of ThreadRng (#936) 2018-05-11 17:26:23 -07:00
tests proxy: Make `outbound_updates_newer_services` test forward-compatible (#939) 2018-05-11 14:36:03 -07:00
Cargo.toml proxy: Parse units with duration configurations (#909) 2018-05-08 13:54:12 -07:00
Dockerfile proxy: Update to Rust 1.26.0 (#942) 2018-05-11 13:52:56 -07:00
assert_macro proxy: Unbreak process_start_time_seconds metric (#825) 2018-04-20 15:59:08 -07:00