aatxe / irc

the irc crate – usable, async IRC for Rust
Mozilla Public License 2.0
528 stars 97 forks source link

Tokio refactor: preserve ability to specify custom reactor #156

Open theduke opened 5 years ago

theduke commented 5 years ago

The 0.14 branch only allows creating a client with the global default reactor.

While this is fine for most use cases and is a nicer API, it should always be optionally possible to still specify the Reactor manually by passing in a Handle.

This came up quite a bit in the tokio refactor RFCs, I can dig out the issue if required.

But there should definitely be an additional method that still allows specifying the handle if you don't want to use the global default.

freddyb commented 4 years ago

I'm running into a similar problem with a project of mine, where I'd like to reuse an existing actor across multiple consumers (e.g., rust-irc and hyper). Currently on the 0.13 branch, I start my irc clients first using a reactor from IrcReactor::new()and use that reactor's inner_handle() to then .spawn() my webserver on it.

Ideally, I'd like to retain the mechanism that creates a new reactor from within irc or consume a custom reactor when registering a client with a handler.

If you think this is useful to others, I'd try writing a pull request, but I think I'll need a bit of handholding. I don't know where to start :)

aatxe commented 4 years ago

Hi @freddyb, I believe the 0.14 update has already circumvented the need for that as it's more in line with the more modern approach in the newer versions of tokio. In particular, we no longer have an IRC reactor at all (instead using async/await and the default tokio executor most of the time).