-
-
Notifications
You must be signed in to change notification settings - Fork 216
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
Support socketry/async #210
Comments
Just to assist with this, here is code for a slightly different slack gem: https://gist.github.com/ioquatix/c24f107e2cc7f48e571a37e8e93b0cda?ts=2 |
Reactors isolate and block on nested tasks. It is possible to start one and manually handle it like you do with EM, but I suggest you just use This also checks for leaked IO, and gracefully times out the spec if you end up in a situation where your I/O operation would never complete. Happy to discuss further. |
Just gave you some feedback on the code. It's a great start and I look forward to seeing how it ends up. Thanks for your hard work implementing this. |
I've been thinking about a good way forward for this gem. One thing to consider is that you also want APIs like I suggest you continue with the next release supporting different models for concurrency. However, on your next major release (0.13), I suggest you go all in, removing EM, Celluloid, etc, and using |
I opened #220. There're many people with production celluloid and EM, and by forcing them to choose a newer library in a client like slack-ruby-client we're making life very difficult for a lot of people. This client has to keep up with the Slack API, and that either means lots of forks over the older version of everyone upgrades. There's likely a better without breaking everyone to support async http requests. That said I am also aware that these other libraries are unmaintained and it's mostly busy work to move forward with all. Finally, what happens when the next best async library pops up? :) Cause you know, ruby concurrency, EM, Celluloid, Async ... we've seen a few. |
@ioquatix Thanks for the code review on dblock@6e07782#commitcomment-30295386! My integration tests are still failing, but the sample bot works, I'll get to it soon. |
Understood. I think we should make it drop in compatible 0.12.x release which doesn't change the existing concurrency model. I think 0.12.x can continue to exist for a while.
Yes, as suggested, we could remove this in 0.13.x and adjust the concurrency model accordingly.
Here is my opinion on this. The main reason why a lot of these libraries have "died" is because they were unmaintainable by design.
|
N.B. Even thought EventMachine reached 1.0, it felt like to me it was never completely stable. Celluloid never reached 1.0, it got stuck in limbo and will never escape. In contrast, a stable, bug-free, 1.0 release of |
You can read a little bit more about it here: https://github.com/socketry/async#motivation |
Also, the funny thing about I wrote some article about this here: https://www.codeotaku.com/journal/2018-06/asynchronous-ruby/index |
Thanks for the details @ioquatix. You're absolutely correct about these points, but there's still human factor. There're only 4 contributors to async and you're 99% of the code. That said adoption is everything and I am happy to recommend async rn. |
There's an important point about deprecating other async libraries in, say 0.13, that I think you've missed. To keep up with the slack API this library needs updates. So if the last version that supports celluloid is 0.12, everyone who wants a newer api will have to upgrade to async. Seems unnecessary as supporting these many concurrency libraries is little overhead. |
Those are all good points. You'll need to make a decision at some point what kind of concurrency model you want. Right now you are using one thread per connection, but if you want to support more connections you'll need to change the model to something more in-line with how async works. Making celluloid work that way is probably impossible, making EventMachine work that way might be possible. I think if you drop support for anything, it should be Celluloid. At least EventMachine is maintained these days. One interesting aspect of this is considering how to write a library without factoring in concurrency. It turn out it is at least somewhat possible. I wrote |
How would that look compared to what we have in this PR? Maybe open a new issue so we don't lose the info? |
So, the main point is, that right now you have integration specs which are heavily geared towards using multiple threads. This is apparent based on the implementation of I think this is fine for how the code currently works. Going forward, you need to be more agnostic towards how this works. I would like to believe this is just a problem with the specs, but it might be more difficult. If a user is using EventMachine or Async, in theory it should be concurrent. You can start a connection and it should work without any explicit threads. I would suggest that you actually remove Thread from the def start_async(client, task: ::Async.Task.current)
task.async do
client.run_loop
end
end This is actually idiomatic and the best way to do it. In order to support this though, you can't then call |
Just FYI, while the EM reactor runs on a background thread, Async doesn't support this:
|
Looks like celluloid-io is no longer maintained. Support https://github.com/socketry/async, maybe make it default?
The text was updated successfully, but these errors were encountered: