Re: making Sequel play nice with eventmachine and em-mysql; async Sequel?

2008-12-07 Thread Aman Gupta
The approach I use in my projects it to combine Sequel's SQL generation with the em-mysqlasyncapi: EventedMysql.select( User.where(:age 10).limit(10).sql ) do |rows|   rows.each do |data|     user = User.load(data)     p user.age   end end You may be able to make this even

Re: making Sequel play nice with eventmachine and em-mysql; async Sequel?

2008-12-07 Thread Jeremy Evans
On Dec 7, 2:23 pm, Aman Gupta [EMAIL PROTECTED] wrote: You may be able to make this even nicer:   class Sequel::MySQL::Dataset     def execute(sql)       EventedMysql.select(sql){|r| yield r}     end   end   User.where(:age 10).limit(10).each{|user| p user.age} Not sure if that

Re: making Sequel play nice with eventmachine and em-mysql; async Sequel?

2008-11-19 Thread Chuck Remes
On Nov 18, 2008, at 4:49 PM, Aman Gupta wrote: In Eventmachine you would use EM::Deferrable for all of your Sequel calls. EM would handle spawning any ruby threads (green threads in MRI, native threads in JRuby). Then use #set_deferred_status in the Deferrable to notify your business logic

Re: making Sequel play nice with eventmachine and em-mysql; async Sequel?

2008-11-19 Thread Mark V
On Thu, Nov 20, 2008 at 3:06 AM, Chuck Remes [EMAIL PROTECTED] wrote: On Nov 18, 2008, at 4:49 PM, Aman Gupta wrote: In Eventmachine you would use EM::Deferrable for all of your Sequel calls. EM would handle spawning any ruby threads (green threads in MRI, native threads in JRuby). Then

making Sequel play nice with eventmachine and em-mysql; async Sequel?

2008-11-18 Thread None
Forgive me if this is a naive question. I has noobie. I'm developing a scalable distributed back end search system for a client, and using eventmachine to great effect thus far. However, we need database access, and that's where things start to get sticky. I can use em-mysql and mysqlplus to

Re: making Sequel play nice with eventmachine and em-mysql; async Sequel?

2008-11-18 Thread Jeremy Evans
On Nov 18, 9:36 am, None [EMAIL PROTECTED] wrote: Forgive me if this is a naive question.  I has noobie. I'm developing a scalable distributed back end search system for a client, and using eventmachine to great effect thus far.  However, we need database access, and that's where things

Re: making Sequel play nice with eventmachine and em-mysql; async Sequel?

2008-11-18 Thread Chuck Remes
On Nov 18, 2008, at 2:13 PM, Jeremy Evans wrote: On Nov 18, 9:36 am, None [EMAIL PROTECTED] wrote: Any ideas? Anyone else out there need anything like this? Not really. If you can spawn threads to deal with the database interactions, and just check those threads to see if they have

Re: making Sequel play nice with eventmachine and em-mysql; async Sequel?

2008-11-18 Thread None
Deferrables would certainly help towards the goal of clean code using one of the extant blocking ORMs (datamapper, activerecord, sequel), but it doesn't actually satisfy the need for achieving parallelism (see here for an excellent explanation of why:

Re: making Sequel play nice with eventmachine and em-mysql; async Sequel?

2008-11-18 Thread None
It seems that the only real solution so far is roll your own. Thanks for the help! On Nov 18, 3:13 pm, Jeremy Evans [EMAIL PROTECTED] wrote: On Nov 18, 9:36 am, None [EMAIL PROTECTED] wrote: Forgive me if this is a naive question.  I has noobie. I'm developing a scalable distributed back

Re: making Sequel play nice with eventmachine and em-mysql; async Sequel?

2008-11-18 Thread Aman Gupta
In Eventmachine you would use EM::Deferrable for all of your Sequel calls. EM would handle spawning any ruby threads (green threads in MRI, native threads in JRuby). Then use #set_deferred_status in the Deferrable to notify your business logic when the Sequel calls have completed. You're

Re: making Sequel play nice with eventmachine and em-mysql; async Sequel?

2008-11-18 Thread Jeremy Evans
On Nov 18, 2:49 pm, Aman Gupta [EMAIL PROTECTED] wrote: In Eventmachine you would use EM::Deferrable for all of your Sequel calls. EM would handle spawning any ruby threads (green threads in MRI, native threads in JRuby). Then use #set_deferred_status in the Deferrable to notify your