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_field   by_participant   by_wfid   cancel   consume   do_not_thread   each   fetch   fetch_all   first   matches?   new   purge!   query   reply   size   to_id   update  

Included Modules

LocalParticipant Enumerable

Attributes

context  [RW] 

Public Class methods

Used by query when filtering workitems.

Public Instance methods

Returns all the workitems stored in here.

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

Removes the document/workitem from the storage

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

Iterates over the workitems stored in here.

A convenience method (especially when testing), returns the first (only ?) workitem in the participant.

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.

Note : the criteria is AND only, you‘ll have to do ORs (aggregation) by yourself.

Removes the workitem from the in-memory hash and replies to the engine.

Returns the count of workitems stored in this participant.

update(workitem)

Alias for consume

Protected Instance methods

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]