Class | Ruote::StorageParticipant |
In: |
lib/ruote/part/storage_participant.rb
|
Parent: | Object |
A participant that stores the workitem in the same storage used by the engine and the worker(s).
part = engine.register_participant 'alfred', Ruote::StorageParticipant # ... a bit later puts "workitems still open : " part.each do |workitem| puts "#{workitem.fei.wfid} - #{workitem.fields['params']['task']}" end # ... when done with a workitem part.reply(workitem) # this will remove the workitem from the storage and hand it back # to the engine
Does not thread by default (the engine will not spawn a dedicated thread to handle the delivery to this participant, the workitem will get stored via the main engine thread and basta).
field : returns all the workitems with the given field name present.
field and value : returns all the workitems with the given field name and the given value for that field.
Warning : only some storages are optimized for such queries (like CouchStorage), the others will load all the workitems and then filter them.
Delegates a currently owned workitem to a new owner.
Fails if the workitem can‘t be found, belongs to noone, or if the workitem passed as argument is out of date (got modified in the mean time).
It‘s OK to delegate to nil, thus freeing the workitem.
See reserve for an an explanation of the reserve/delegate/proceed flow.
Added for groups.google.com/forum/?fromgroups#!topic/openwferu-users/5bpV2yfKwM0
Makes sure the workitem get saved to the storage. Fails if the workitem is already gone. Returns nil in case of success.
A convenience method (especially when testing), returns the first (only ?) workitem in the participant.
Removes the workitem and hands it back to the flow with an error to raise for the participant expression that emitted the workitem.
Removes the document/workitem from the storage.
Warning: this method is called by the engine (worker), i.e. not by you.
Mostly a test method. Returns a Hash were keys are participant names and values are lists of workitems.
Mostly a test method. Returns a Hash were keys are participant names and values are integers, the count of workitems for a given participant name.
Queries the store participant for workitems.
Some examples :
part.query(:wfid => @wfid).size part.query('place' => 'nara').size part.query('place' => 'heiankyou').size part.query(:wfid => @wfid, :place => 'heiankyou').size
There are two ‘reserved’ criterion : ‘wfid’ and ‘participant’ (‘participant_name’ as well). The rest of the criteria are considered constraints for fields.
‘offset’ and ‘limit’ are reserved as well. They should prove useful for pagination. ‘skip’ can be used instead of ‘offset’.
Note : the criteria is AND only, you‘ll have to do ORs (aggregation) by yourself.
Claims a workitem. Returns the [updated] workitem if successful.
Returns nil if the workitem is already reserved.
Fails if the workitem can‘t be found, is gone, or got modified elsewhere.
Here is a mini-diagram explaining the reserve/delegate/proceed flow:
in delegate(nil) delegate(other) | +---------------+ +------+ v v | | v +-------+ reserve +----------+ proceed | ready | ---------> | reserved | ---------> out +-------+ +----------+
Given a few options and a block, returns all the workitems that match the block