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

Extract asynchronous I/O layer (e.g. for Celluloid::IO support) #272

Closed
tarcieri opened this issue Dec 13, 2015 · 14 comments
Closed

Extract asynchronous I/O layer (e.g. for Celluloid::IO support) #272

tarcieri opened this issue Dec 13, 2015 · 14 comments

Comments

@tarcieri
Copy link
Member

I'd like to use this as a master tracking ticket for all feature requests/regressions related to the asynchronous I/O layer/timeout implementation.

I think this is one of the most interesting parts of this gem (thanks @zanker) and the two of us have discussed extracting it into a separate gem:

https://github.com/zanker/socketry

The addition of this feature broke Celluloid::IO support. Once upon a time several people suggested to me Celluloid::IO support was the only interesting feature of this gem. I hope we've proved them wrong!

I would still like to support Celluloid::IO as a timeout backend, but it needs the work to add it to the existing timeout framework.

I am tagging this as a milestone 2.0 option for two options:

  1. I don't think anyone plans on working on it soon
  2. It would arguably be a breaking API change
@tarcieri tarcieri added this to the v2.0 milestone Dec 13, 2015
@zanker
Copy link
Contributor

zanker commented Dec 14, 2015

Yea I'd like to work on Socketry but it looks like I'll not have time for a while :(

@ches
Copy link

ches commented Dec 21, 2015

I was following #225 but without much familiarity with the history I feel a little short on context from the description of this new ticket—I've swiftly browsed what code exists in the Socketry repo, but since it lacks specs and a high-level README description at this point, would you guys mind expanding a little either there or here on it when you have time? I.e. what is the intended focus/scope of Socketry? From @tarcieri's remarks above it sounds to me something like "uniform interface abstraction layer for Ruby asynchronous I/O", but "Socket wrapper around Ruby" sounds a bit conceptually different from that, so not sure that I understand correctly.

Would the idea be that httprb uses the Socketry API, then adapters can be implemented for Socketry to be backed with Celluloid::IO, EventMachine, perhaps Cool.io if someone has a legacy case to support, etc.?

@tarcieri
Copy link
Member Author

@ches it'd basically be a wholesale extraction of the current timeout code, which has a synchronous API, but async I/O for implementing timeouts.

It would work with core Ruby and Celluloid::IO. It could not work with EventMachine and Cool.io, because they're callback-driven.

Right now it is very difficult to implement I/O with timeouts in Ruby without using core timeout.rb, which is unsafe due to its use of threads/Thread#raise.

The timeout code in this library implements them safely by using IO.select to wait for I/O readiness or a timeout.

Celluloid::IO does something similar using nio4r selectors.

@msufa
Copy link

msufa commented Jan 11, 2016

We've actually went for this gem strictly because of Celluloid::IO support, and seeing it removed from v1.0 is a major issue for us. I'm not looking for commitments, just some general info to have a good understanding of the situation. Is there any rough timeframe for v2.0? Are there any alternatives / workarounds for making the gem work with Celluloid::IO?

@zanker
Copy link
Contributor

zanker commented Jan 11, 2016

@tarcieri do you remember what broke with Celluloid::IO? I thought it was due to the timeout portions, we could just make a Celluloid timeout class for people to use I think.

@tarcieri
Copy link
Member Author

Yeah, we'd need a Celluloid::IO timeout backend

@zanker
Copy link
Contributor

zanker commented Jan 11, 2016

It's pretty easy to do, but I'm probably not going to have time to do it this week. I can take a look next week @msufa.

@msufa
Copy link

msufa commented Jan 11, 2016

Excellent! Thanks for the support and swift response @zanker

@ixti ixti modified the milestones: v2.0, v2.x May 5, 2016
@ccoenen
Copy link

ccoenen commented Aug 31, 2016

@zanker did you get around to looking at it? I'm currently trying to assess the near-future state of Celluloid Support for this gem.

@tarcieri
Copy link
Member Author

I've started working on it. I should have the basic pieces of it relatively soon

@tarcieri
Copy link
Member Author

tarcieri commented Sep 4, 2016

Here's a WIP: socketry/socketry#3

@tarcieri
Copy link
Member Author

Socketry is shaping up now: https://github.com/socketry/socketry

It's mostly feature complete at this point. Still a little work to do.

I started trying to convert http.rb to use it. Note that it only provides an equivalent of HTTP::Timeout::PerOperation, so HTTP::Timeout::Global will need to stay in this library. But that makes sense (I think), because those timeouts need to have knowledge of the request lifecycle.

@tetherit
Copy link

Thank you for the work on this. Is there any experimental version yet to try this out? -- If not, can you recommend any high level HTTP library that works inside of Celluloid::IO?

Socketry looks great, but presumably it is pure access to the socket rather than an HTTP library.

@tarcieri
Copy link
Member Author

You can try the socketry branch (from #377) although there's a bit more work involved to make it fully Celluloid::IO compatible.

@ixti ixti removed this from the v2.2 milestone Oct 14, 2018
@tarcieri tarcieri closed this as completed Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants