Hello again,

I looked into reserve method as you suggested and it ended up to be perfect 
place to implement affinity for workers. I also reverted storage 
participant to being single threaded so worker is mopnopolized by 
participants and long running participants queue up.

I patched Sequel::Storage with following code:
<<CODE

    def reserve(doc)
      allowed_to_process?(doc) && super
    end

    def allowed_to_process?(doc)
      if doc['workitem'] && doc['workitem']['fields'] && 
doc['workitem']['fields']['params']
        !doc['workitem']['fields']['params']['long'] || 
!REGISTRY[:worker_skip_long]
      else
        true
      end

    end
<<CODE
 
I created to rake tasks run_worker and run_worker_long. In second task I 
set the registry key to true so it processes the long running tasks. 

I know it does not look too elegant and I am monkey patching sequel 
storage, but for now it works perfectly and gives me ability to call 
participant and give it an affinity for long running tasks.
For example:
<<PDEF

Ruote.process_definition :name => 'test', :revision => '0.1' do
  sequence do
    alice :task => 'clean car'
    bob :task => 'sell car', :long => true
  end
end

<<PDEF

Will be processed by any worker until it hits participant bob. Once it hits 
bob, only worker that does not skip long running tasks will accept that 
participant.

Thanks,
Iuri
 


-- 
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en

Reply via email to