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
Synchronous resolver is not Send + Sync #227
Comments
Yeah…even the base |
It is cloneable. Does clone not facilitate your needs? |
No, |
FWIW, we require |
So you may be bumping into some areas where I haven't had any strong use cases, and so don't have any good examples at the moment. We don't have any yet, but perhaps you wouldn't mind creating an example that we could put into To your specific issue. You may need to use I haven't worked much with |
Basically, the synchronous and asynchronous implementations can't share "business logic" code. They can share parsers and other pure logic, but the internal |
I've filed tokio-rs/tokio-core#265 to help improve Tokio's documentation about this problem. |
We might be able to "fix" the SyncClient to use a thread-local Core, tokio-rs/tokio-core#212 , or something similar. If we remove btw, is my above post about using |
I'm not thrilled about those changes to tokio…Rust the language doesn't have a runtime that needs initialized (IIRC, the main reason green threads were dropped pre-1.0) and I don't think a lazily initialized one is good either. Crates certainly shouldn't be relying on such global, implicit behavior IMO.
Possibly, I'll need to test it. I also might not be able to practically use it if creating and destroying |
You could potentially (I haven't done this) just stick the |
Eh, the extra complexity there probably makes it easier to just stick with |
I think it's reasonable to put thread-local |
I'd really rather not have a library setting up threads underneath me. |
(Without it being something the library is meant to do, like |
Thread locals don’t set up a new thread, they associate static context to the current thread. This would allow a single Core per thread to exist, without any work by the user of the lib. No new thread creation at all. edit: the #245 doesn't use ThreadLocal, but does create a new Core on each Sync request. |
Do you really need the sync resolver to be [Edit: s/ |
I think I should be able to achieve both with the current implementation... |
Using |
When making a complex type |
Though, the point is good. I'd love to be able to remove |
First, I mixed up Second, I think I was confused about whether I think it shouldn't cost much (nothing?) to make the async types It is reasonable to either ask the users of the synchronous API to use |
Also, if we make the async API |
Let me fix the current issues in the PR, which is just to make it Send at the moment, if it ends up looking like it's too much cost internally, then we can decide what other options we have. |
I've run into some issues with OpenSSL in the current PR. It will most likely effect NativeTLS as well. There are two options moving forward, only support Rustls for client TLS, or requrie I'm also not a fan of the implementation in that PR at the moment, especially for TCP, which will require re-connections for each DNS request. I might try a different direction tomorrow. |
Ok, #245 is the path forward on this. If anyone is interested in the changes, please look at that PR. It makes the Resolver and Client Send+Sync, without any static information or shared Core's. If you have feedback please file it soon, otherwise I'll merge this in, and it will be incorporated in the next release. By the way, the only supported SyncClient TLS implementation will be Rustls after this change. For the others, the tokio variants will be required. |
This is due to its embedding of the async Reactor from Tokio. This means that for my
Send + Sync
structure, I need to instead create a resolver on each call instead of being able to amortize it to be constructed just once.The text was updated successfully, but these errors were encountered: