-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove hyper fork #2
Conversation
Next steps: instead of `Send`ing the ResponseFuture we should instead `Send` the `hyper::Request` in Transaction
WeakCounter needed to make transaction_counter clean as we now drop the reference to the counter after sending the shutdown message
src/deliverable.rs
Outdated
|
||
impl Deliverable for mpsc::Sender<DeliveryResult> { | ||
fn complete(self, result: DeliveryResult) { | ||
let _ = self.send(result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if no one is listening, this will return an Error. Is that unimportant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, yeah it's unimportant because it's only used for the tests. I moved it over to the test mod, we don't really need to expose the Deliverable
impl for mpsc::Sender
anyways..
It's kind of opinionated since it doesn't handle an error and we only use it for tests, so it doesn't seem like we should automatically impl it right now.
This is because on the test server, hyper connects through IPv6 instead of IPv4
Reviewed 5 of 10 files at r1, 1 of 2 files at r2, 3 of 3 files at r3, 1 of 5 files at r4. src/config.rs, line 18 at r3 (raw file):
Does hyper 0.11 still handle DNS? Seems like we should be able to plugin a tokio/futures-compatible resolver library and eliminate this option. src/error.rs, line 9 at r3 (raw file):
The variants here need some explanation in doc comments. It would also be nice to expose a library src/error.rs, line 12 at r3 (raw file):
src/error.rs, line 33 at r3 (raw file):
This doesn't seem unreachable src/error.rs, line 43 at r3 (raw file):
Nor does this src/executor.rs, line 17 at r3 (raw file):
Reviewable says src/executor.rs, line 40 at r3 (raw file):
We should use a bounded channel here. The src/executor.rs, line 89 at r3 (raw file):
I find this whole How is hyper doing DNS? We must not use the built-in glibc I suppose we could actually implement our own src/executor.rs, line 159 at r3 (raw file):
I'm not a big fan of the src/lib.rs, line 26 at r3 (raw file):
Should these be made into integration tests that live in src/lib.rs, line 156 at r3 (raw file):
The addresses you have listed here are actually CloudFlare IP addresses. Rather than have a hardcoded list of IPs, we can use CloudFlare's list of IP ranges to check whether extern crate ipnet;
use std::io::{self, Read, BufRead};
use std::net::IpAddr;
use ipnet::{Contains, IpNet};
static CLOUDFLARE_NETS: &[&str] = &[
"103.21.244.0/22",
"103.22.200.0/22",
"103.31.4.0/22",
"104.16.0.0/12",
"108.162.192.0/18",
"131.0.72.0/22",
"141.101.64.0/18",
"162.158.0.0/15",
"172.64.0.0/13",
"173.245.48.0/20",
"188.114.96.0/20",
"190.93.240.0/20",
"197.234.240.0/22",
"198.41.128.0/17",
];
fn run() -> Result<(), Box<::std::error::Error>> {
let cloudflare_nets = CLOUDFLARE_NETS.iter()
.map(|net| net.parse::<IpNet>())
.collect::<Result<Vec<IpNet>, _>>()?;
let stdin = io::stdin();
let mut stdin = stdin.lock();
for line in stdin.lines() {
let line = line?;
match line.parse::<IpAddr>() {
Ok(addr) => {
let is_cf = cloudflare_nets
.iter()
.any(|net| net.contains(&addr));
if !is_cf {
println!("{}", line);
}
},
_ => {
eprintln!("Failed to parse {:?} as ip", line);
},
}
}
Ok(())
}
fn main() {
run().unwrap();
} src/pool.rs, line 60 at r3 (raw file):
Please document the conditions that would lead to these src/transaction.rs, line 58 at r3 (raw file):
Bounds are not necessary here src/transaction.rs, line 69 at r3 (raw file):
Bounds are not necessary here src/transaction.rs, line 84 at r3 (raw file):
I believe we can remove the src/transaction.rs, line 92 at r3 (raw file):
It's surprising to me that this is not modeled as a src/transaction.rs, line 146 at r3 (raw file):
What is the point of notifying the task here? Please add a comment. Maybe also a doc comment where the src/transaction.rs, line 164 at r3 (raw file):
Break long line src/transaction.rs, line 172 at r3 (raw file):
Is there any way to avoid the header clone? src/transaction.rs, line 186 at r3 (raw file):
Perhaps src/transaction.rs, line 208 at r3 (raw file):
Please add a test for transaction timeouts. This could be achieved by starting a local server which doesn't send a response. Comments from Reviewable |
Reviewed 4 of 5 files at r4. src/executor.rs, line 17 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
You pushed a fix for this during my review :P src/lib.rs, line 156 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Looks like you just added IPv6 addrs as well. The list of all addresses can be found at https://www.cloudflare.com/ips/ Comments from Reviewable |
Reviewed 2 of 2 files at r5. Cargo.toml, line 23 at r5 (raw file):
What is this about? Comments from Reviewable |
Review status: 7 of 9 files reviewed at latest revision, 22 unresolved discussions. Cargo.toml, line 23 at r5 (raw file): Previously, jwilm (Joe Wilm) wrote…
You can ignore this, I was investigating connection-reuse not seeming to work on the test server, but actually realized that it was because the src/executor.rs, line 89 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Ah okay, I followed the path down tokio-tls and it does resolve to net::ToSocketAddrs implementation. I will take a look at implementing our own TlsConnector with a Comments from Reviewable |
Review status: 7 of 9 files reviewed at latest revision, 22 unresolved discussions. src/executor.rs, line 89 at r3 (raw file): Previously, DarrenTsung (Darren Tsung) wrote…
Oops, I didn't realize I published this. I opened an issue on hyper to see what their input is: hyperium/hyper#1517 Comments from Reviewable |
Review status: 1 of 9 files reviewed at latest revision, 22 unresolved discussions. src/config.rs, line 18 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Yeah, hyper still handles DNS, see other comment. Will leave this open so we can remove this option. src/error.rs, line 9 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Refactored the error handling and added doc comments! There are two types of errors that I wanted to expose because only a subset of errors can happen during src/error.rs, line 12 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Renamed to src/error.rs, line 33 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Removed with error refactor src/error.rs, line 43 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Removed with error refactor src/executor.rs, line 17 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
:P src/executor.rs, line 40 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
UnboundedSender shouldn't block though, right? I mean, it can't block waiting for room as it's unbounded, so it should always be placing a message in the queue. We handle backpressure over the entire system with the src/executor.rs, line 159 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Yeah I don't know why I didn't use the pattern of dropping the handle as well. I put a note down that sending a shutdown would drop the handle, but I guess that doesn't account for users that cloned the Handle (if that was possible). I switched it over to dropping the handle. Thanks! src/lib.rs, line 26 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Good point, moved over! src/lib.rs, line 156 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Implemented this, thanks for the reference! src/pool.rs, line 60 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Refactored it with new fpool implementation, there are comments when we invalidate the thread because it failed to send now src/transaction.rs, line 58 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Removed R, thanks! src/transaction.rs, line 69 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Removed R src/transaction.rs, line 84 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Removed R + PhantomData, thanks! src/transaction.rs, line 92 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
That would work - as well as an src/transaction.rs, line 146 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Added comments + a doc comment. Basically the executor is waiting for the transactions to finish, but is never woken up if not notified by transactions finishing. src/transaction.rs, line 164 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Done! src/transaction.rs, line 172 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Unfortunately not if we want to return the Response as part of the DeliveryResult. Spoke to seanmonstar about this and possibly better handling in hyper 0.12. src/transaction.rs, line 186 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
I think the naming of the errors might be confusing, there's: Then there's also the types in src/transaction.rs, line 208 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
I have a test for timeout in the integration tests, see Comments from Reviewable |
Review status: 1 of 10 files reviewed at latest revision, 17 unresolved discussions. src/config.rs, line 18 at r3 (raw file): Previously, DarrenTsung (Darren Tsung) wrote…
Switched to a custom HttpConnector that uses c-ares DNS resolver. I tried with trust-dns first, but load testing revealed panics in the resolution flow. src/executor.rs, line 89 at r3 (raw file): Previously, DarrenTsung (Darren Tsung) wrote…
Switched to a custom HttpConnector that uses c-ares DNS resolver. I tried with trust-dns first, but load testing revealed panics in the resolution flow. Comments from Reviewable |
Creating the resolver and running with normal tokio-core was the issue.
Reviewed 1 of 8 files at r6, 4 of 8 files at r7, 6 of 6 files at r8. src/config.rs, line 18 at r3 (raw file): Previously, DarrenTsung (Darren Tsung) wrote…
We should work with the TrustDNS project to resolve whatever issues we are having. src/error.rs, line 42 at r7 (raw file):
In the standard library, the naming convention for this type of method is src/executor.rs, line 40 at r3 (raw file): Previously, DarrenTsung (Darren Tsung) wrote…
It's more about knowing worst-case how much memory this channel will use. src/executor.rs, line 65 at r8 (raw file):
We should prefer a doc comment rather than having unnecessary lines of code. src/pool.rs, line 67 at r8 (raw file):
It's a little surprising that the consumer is responsible for this. Maybe we could use an intermediate abstraction on the fpool? src/transaction.rs, line 92 at r3 (raw file): Previously, DarrenTsung (Darren Tsung) wrote…
How would that change where src/transaction.rs, line 146 at r3 (raw file): Previously, DarrenTsung (Darren Tsung) wrote…
Ah, I get it. Sounds good! Comments from Reviewable |
Review status: 9 of 10 files reviewed at latest revision, 7 unresolved discussions. src/config.rs, line 18 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Figured out that trying to run a ResolverFuture with tokio-core was causing the issue, moved over to src/error.rs, line 42 at r7 (raw file): Previously, jwilm (Joe Wilm) wrote…
Done src/executor.rs, line 40 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Right, good point. Actually in this case this channel is completely bounded by Along with that, the executor thread would immediately spawn the transaction as part of consuming it while it has the receiver. No chance it would be backlogged unless the receiver is dropped / thread doesn't get woken up, it just seems weird to add a failure case that shouldn't happen (given the in-variants of tokio / the channel type). src/executor.rs, line 65 at r8 (raw file): Previously, jwilm (Joe Wilm) wrote…
Done! src/pool.rs, line 67 at r8 (raw file): Previously, jwilm (Joe Wilm) wrote…
I guess we could wrap the fpool in some sort of type that handles it, but I'm not sure what this type would be left with? src/transaction.rs, line 92 at r3 (raw file): Previously, jwilm (Joe Wilm) wrote…
Because The transaction future that returns an Item=Response+Body, Error=Timeout/TransationError is the chained, generalized type Basically we have to have some type that has Item=(), Error=() because it needs to also impl Comments from Reviewable |
Reviewed 1 of 1 files at r9, 2 of 2 files at r10. Comments from Reviewable |
Use hyper 0.11 and associated libraries like tokio.
The flow of the project is largely unchanged to avoid having to refactor heavily downstream, but now we handle the threads ourselves with a RoundRobinPool and also use
Executor
s to receive messages viafutures::sync::mspc
from the pool thread.This change is