RestClient + EventMachine


James Fairbairn <james@...>
 

Hello,

Back in June Cyril Mougel asked:

RestClient use Net::Http to request the web. But there are some try to
use em-http-request instead ?

to which Adam Wiggins replied:

If you're writing an evented program in EventMachine, using a blocking
library like RestClient is a no-go.

I too wanted to use a Net::HTTP-dependent library non-blockingly in
EventMachine (in my case right_aws), so I wrote em-net-http
(http://rubygems.org/gems/em-net-http). It monkeypatches Net::HTTP so
that it uses em-http-request under the hood (only if the EM reactor is
running), while preserving the (blocking) API of Net::HTTP through the
magic of Fibers.

Caveat: it's brand new and not very exhaustively tested. :)

Good luck! Let me know how it goes....

Thanks,
James


Archiloque <code@...>
 

Thanks, I'll givre it a try aas it may be handy, btw did you tested it with jruby ?

A.

Le 22 août 2010 à 02:12, James Fairbairn <james@...> a écrit :

Hello,

Back in June Cyril Mougel asked:

RestClient use Net::Http to request the web. But there are some try to
use em-http-request instead ?

to which Adam Wiggins replied:

If you're writing an evented program in EventMachine, using a blocking
library like RestClient is a no-go.

I too wanted to use a Net::HTTP-dependent library non-blockingly in
EventMachine (in my case right_aws), so I wrote em-net-http
(http://rubygems.org/gems/em-net-http). It monkeypatches Net::HTTP so
that it uses em-http-request under the hood (only if the EM reactor is
running), while preserving the (blocking) API of Net::HTTP through the
magic of Fibers.

Caveat: it's brand new and not very exhaustively tested. :)

Good luck! Let me know how it goes....

Thanks,
James


James Fairbairn <james@...>
 

On 26 Aug 2010, at 23:28, Archiloque wrote:

Thanks, I'll givre it a try aas it may be handy, btw did you tested it with jruby ?
No, I haven't tested it with JRuby. Let me know how it goes! It uses Fibers though, which are implemented with threads in Java, meaning more memory and context switch overhead than you'd see in MRI.