A purpose-built proxy for the Linkerd service mesh. Written in Rust.
Go to file
Eliza Weisman 57c8504899 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
.github Add a newline to dco.yml (#254) 2018-02-01 15:16:02 -08:00
proxy proxy: Add a lazy version of ThreadRng (#936) 2018-05-11 17:26:23 -07:00
CONTRIBUTING.md Add contributing doc and DCO file (#88) 2017-12-22 14:54:27 -08:00
Cargo.lock proxy: Parse units with duration configurations (#909) 2018-05-08 13:54:12 -07:00
Cargo.toml proxy: improve graceful shutdown process (#684) 2018-04-10 14:15:37 -07:00
DCO Add contributing doc and DCO file (#88) 2017-12-22 14:54:27 -08:00
LICENSE Introducing Conduit, the ultralight service mesh 2017-12-05 00:24:55 +00:00