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).

Methods

[]   all   by_fei   by_field   by_participant   by_wfid   delegate   do_not_thread   do_select   do_update   each   fetch   fetch_all   first   flunk   matches?   new   on_cancel   on_workitem   per_participant   per_participant_count   proceed   purge!   query   remove_workitem   reply   reserve   size   to_id   update   wi   wis  

Included Modules

LocalParticipant Enumerable

Public Class methods

Used by query when filtering workitems.

Public Instance methods

Given a fei (or its string version, a sid), returns the corresponding workitem (or nil).

Returns all the workitems stored in here.

by_fei(fei)

Alias for #[]

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.

Returns all workitems for the specified participant name

Return all workitems for the specified wfid

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.

No need for a separate thread when delivering to this participant.

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.

Iterates over the workitems stored in here.

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.

This is the method called by ruote when passing a workitem to this participant.

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.

Removes the workitem from the storage and replies to the engine.

Cleans this participant out completely

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.

(soon to be removed)

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
  +-------+            +----------+

Returns the count of workitems stored in this participant.

Used by client code when "saving" a workitem (fields may have changed). Calling update won‘t proceed the workitem.

Returns nil in case of success, true if the workitem is already gone and the newer version of the workitem if the workitem changed in the mean time.

Protected Instance methods

Given a few options and a block, returns all the workitems that match the block

Fetches a workitem in its raw form (Hash).

Fetches all the workitems. If there is a @store_name, will only fetch the workitems in that store.

Computes the id for the document representing the document in the storage.

[Validate]