[Backgroundrb-devel] State of backgroundrb (dupe?)

Morten Primdahl primdahl at mac.com
Sat Mar 22 11:28:10 EDT 2008


Hi,

I found that instead of using a custom "result" method, I can get the  
result data from the worker by using register_status and ask_status -  
but is this how it's meant to work? The status methods are not  
"reserved" (semantically) for progress notifications? It's not  
possible to retrieve data from a worker by a custom method, or is my  
approach incorrect?

Thanks.

Morten


On Mar 21, 2008, at 9:49 PM, Morten Primdahl wrote:
>
> On Mar 21, 2008, at 9:28 PM, Kit Plummer wrote:
>> I too have been fine with the 1.0.3 stuff.  New dependencies...but,  
>> no
>> big deal.
>>
>> I'm curious though...what else is there?  If you were to go looking
>> what would you find?
>
> Then I'd be looking for a queuing mechanism of sorts, inspiration  
> here:
> http://nubyonrails.com/articles/about-this-blog-beanstalk-messaging-queue
>
> And a question, the API has changed some since the version I use, and
> I have a little problems getting my most basic example to work in the
> console - when I attempt to read the result, I get nil. Can anyone
> spot what may be wrong:
>
> class ReverseWorker < BackgrounDRb::MetaWorker
>   set_worker_name :reverse_worker
>   def create(args = nil)
>     # this method is called, when worker is loaded for the first time
>   end
>
>   def reverse(arg = 'missing')
>     @result = arg.reverse
>   end
>
>   def result
>     @result
>   end
> end
>
> flake:zendesk morten$ script/console
> Loading development environment (Rails 2.0.2)
>>> key = MiddleMan.new_worker(:worker => :reverse_worker, :job_key =>
> '123')
> {:type=>:start_worker, :worker=>:reverse_worker, :job_key=>"123"}
>
> => "123"
>>> MiddleMan.worker(:reverse_worker, key).reverse('Hello')
> {:type
> =
>>
> :do_work
> , :data
> =
>>
> "Hello
> ", :worker 
> =>:reverse_worker, :worker_method=>:reverse, :job_key=>"123"}
>
> => nil
>>> MiddleMan.worker(:reverse_worker, key).result
> {:type
> =
>>
> :do_work
> , :worker=>:reverse_worker, :worker_method=>:result, :job_key=>"123"}
>
> => nil
>
> Odd isn't it? The debug log:
>
> 00000006:	type:start_worker:
>                                   worker:reverse_worker:
>                                                         job_key123
> {:type=>:start_worker, :job_key=>"123", :worker=>:reverse_worker}
> 00000009{
> :	type:
>              do_work:	data"
> Hello:
>       worker:reverse_worker:worker_method:
>                                           reverse:
>                                                   job_key123
> {:type
> =
>>
> :do_work
> , :job_key
> =
>>
> "123
> ", :worker_method=>:reverse, :worker=>:reverse_worker, :data=>"Hello"}
> 00000008{	:	type:
>                              do_work:
>
> worker:reverse_worker:worker_method:
>                                                                          result
> :
>                                                                                 job_key123
> {:type
> =
>>
> :do_work
> , :job_key=>"123", :worker_method=>:result, :worker=>:reverse_worker}
>
> Br,
>
> Morten
>
>
>
>
>
>
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel



More information about the Backgroundrb-devel mailing list