-
Notifications
You must be signed in to change notification settings - Fork 600
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
Making the library executor agnostic (making Tokio optional) #280
Comments
Hi, I have bumped into the same issue as well. Apparently release 0.13.0 was executor-agnostic, is this a breaking change? This requirement is not stated in the latest release notes. |
redis is currently executor agnostic, but not reactor agnostic. So you can supply your own |
I would like to help with that if you like, but I would need some initial description of what to change. If you think I can help, let me know. |
Since there isn't a good |
Ok, thanks! Then, for what I understand:
With these 2, TcpStream/UnixStream would be possible to be given when the AsyncRead/AsyncWrite trait is required. Is my understanding correct? |
Yes, you will need newtype wrappers and implement it on that but otherwise that is the gist of it. |
To be clear, the reason that we need to go through tokio is that we use tokio's |
Would it be possible to make these optimizations optional? Would it be very complex? |
Yes and maybe. I don't have an need for async-std support myself so I haven't given it any deeper thought than figuring out a way to support it. |
I'm looking at the code in https://github.com/mitsuhiko/redis-rs/blob/master/src/aio.rs and I can see that there is a type that abstract the connection type called enum ActualConnection {
TcpTokio(Buffered<TcpStream>),
#[cfg(unix)]
UnixTokio(Buffered<UnixStream>),
TcpAsyncStd(Buffered<async_std::net::TcpStream>),
#[cfg(unix)]
UnixAsyncStd(Buffered<async_std::net::UnixStream>),
} And then make the correct trait implementation over each one. What I don't have clear is how that would allow the futures to use the correct type depending of the reactor. I'm having some problems wrapping my head around this. Even if I make a wrapping type that implements Tokio traits for async_std's TcpStream, how is the code going to choose the correct implementation? A feature flag maybe can help (?) |
I would change https://docs.rs/redis/0.15.1/redis/struct.Client.html#method.get_async_connection into
Feature flags would be useful to enable/disable one async implementation or the other but it shouldn't be need otherwise (see above). For instance, tokio support can be disabled with #272 |
oook, that is more clear now, thank you. Then, if I do what I described in #280 (comment) and I implement 2 methods, the developer will be the one responsible of knowing what method to use (tokio/asynct_std). How would it be in the case of libraries using radis-rs under the hood? I guess they will need to push the decision to the developer as well, as they cannot make assumptions. Moreover, splitting that method would be a breaking change. If you are ok with that, I will start. |
Yeah, there might be a better API if instead the caller supplied the #272 forces a breaking change anyway so 🤷♂ |
Do you want my branch to be forked form Marwes:combine-4 or from master? |
Might be better to use combine-4 as it touches part of what you need to change. It shouldn't change really, just waiting in review. |
Ok. Then I will try to work on this this week. :) |
I was playing with the code a bit and seems that async_std doesn't allow to compose BufferRead and BufferWrite together. I see the type
Any idea of how can I proceed here? I can remove the Buffers for now until we find some solution. |
Conicidentally I pushed some changes to the combine-4 branch which removes the |
Ok!. I will rebase and continue from there :) |
I think I have something. I'm trying to test it but I have this error in the latest commit of the combine-4 branch
|
Pushed a fix (removed a rogue |
There you go #281 :) |
I was playing on my branch to to merge both async test files in one. I have everything working except a test that is hanging forever "dont_panic_on_closed_multiplexed_connection". In any case, this is independent of the Pull Request, as in there everything is working. |
Fix flakey test.
* Python: add ZINTERCARD command (redis-rs#280) * Update PR link in CHANGELOG * PR suggestions * Align docs and cross-slot tests with recent changes * Fix crossslot test
Hi!
I was developing a library using this one and I found out that the futures returned by redis-rs required tokio to be executed.
As example, this test in my own library https://github.com/Couragium/rsmq_async :
I get this on
cargo test
:I'm not very into how futures work internally, but, is there any way for this library to return a future that doesn't require an specific executor?
Edit: Btw, great work with this library!
The text was updated successfully, but these errors were encountered: