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 use #set_deferred_status in the >>> Deferrable to notify your business logic when the Sequel calls have >>> completed. >> >> You're confusing EM.defer with EM::Deferrable. EM::Deferrable has >> nothing to do with threads, it simply stores a list of callbacks to >> invoke when a certain state is reached. EM.defer uses a ruby >> threadpool of 20 threads and provides a second callback to receive >> notifications when code running in the thread has executed. >> >> The approach I use in my projects it to combine Sequel's SQL >> generation with the em-mysql async api: >> >> EventedMysql.select( User.where(:age > 10).limit(10).sql ) do |rows| >> rows.each do |data| >> user = User.load(data) >> p user.age >> end >> end > > Aman, > > thanks for the correction. I've been away from EM for a while so I'm a > bit rusty with the API. >
I'm a little rusty on Aquarium, but from memory one might be able to have it invoke some method(s) around Sequel's methods of interest; Model or Dataset, etc., eg. before/after CRUD. This could be the cleanest way to make Sequel event driven? You'd probably still need to use EM's deferrable. Again from memory you could define 'aspects' for methods belonging to instances of particular classes. One word of caution if implementing reusable aspects, i.e. include some aspect mixin: take care to include just before the class is 'end'ed - see the examples. Largely speculation, but HTH? Mark > cr > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~----------~----~----~----~------~----~------~--~---
