Skip to content
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

Question: any way to make it runtime agnostic? #2

Open
augustocdias opened this issue Mar 24, 2020 · 7 comments · May be fixed by #6
Open

Question: any way to make it runtime agnostic? #2

augustocdias opened this issue Mar 24, 2020 · 7 comments · May be fixed by #6

Comments

@augustocdias
Copy link

I see a lot of libraries starting to move to async/await, but being dependent on specific runtimes (either async-std or tokio) and this can become a mess when developers starts to need different libraries depending on different runtimes...

Also are you planning to merge it with the synchronous version or maintaining both in parallel?

@AlexPikalov
Copy link
Owner

AlexPikalov commented Mar 24, 2020

Hi @augustocdias ,

I totally agree with your point, dependency from any concrete runtime is definitely a weak point unless such runtime was blessed by a Rust core team. But I don't think such one exists. As you might noticed, so far the whole implementation is based on async-std, but after your question I think I'd like to invest if it's something I could implement. If you know about such attempts made by others I'd really appreciate any link or a contact point.

As for the plans in regards of maintenance, I didn't decide yet. I've just got the async version working literally this weekend. I'll be trying to maintain both with maybe a bigger focus on cdrs-async to make it more stable and possibly providing some of missing features. However, taking into consideration the fact that I'm the only one active and regular contributor to the sync version it may happen that one day I'll need to merge them or to archive some.

@augustocdias
Copy link
Author

augustocdias commented Mar 24, 2020

I'm not very experienced with it either, but a way I believe this could be accomplished is creating abstract traits for everything that demands the runtime. You could have have default structs implementing this traits for either runtime or multiple if you want. And a way to let the user use another runtime is creating constructors passing generic types of this trait in the entrypoints of the library.

For example:
In here, you would set the stream as a generic type and could have an implementation for async-std.
https://github.com/AlexPikalov/cdrs-async/blob/master/src/transport_tls.rs#L21

@AlexPikalov
Copy link
Owner

@augustocdias 👍
Will try it out! Will start from runtime specific things inventory. Will see how big is this dependency in fact.

@augustocdias
Copy link
Author

Let me know if I can help with something. With this quarantine I’m having some free time.

@augustocdias
Copy link
Author

Also maybe take a look into this crate

https://github.com/bastion-rs/agnostik

It claims to facilitate the job to make executor agnostic libraries.

@AlexPikalov
Copy link
Owner

Let me know if I can help with something. With this quarantine I’m having some free time.

@augustocdias Sorry for the delay. You can try to progress with the whole issue if you have time and is still interested in that.

@augustocdias
Copy link
Author

I'll try... I've pulled the code and setup the basic changes in the Cargo.toml and I can see already that it will be challenging 😅

@augustocdias augustocdias linked a pull request May 6, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants