Logs the ruote engine history to the storage underlying the worker.
Warning : don't use this history implementation when the storage is HashStorage. It will fill up your memory... Keeping history for a transient ruote is a bit overkill (IMHO).
# File lib/ruote/log/storage_history.rb, line 39 def initialize (context, options={}) @context = context @options = options if @context.worker # only care about logging if there is a worker present @context.storage.add_type('history') @context.worker.subscribe(:all, self) end end
# File lib/ruote/log/storage_history.rb, line 76 def by_date (date) date = Time.parse(date.to_s).strftime('%Y-%m-%d') @context.storage.get_many('history', /!#{date}!/) end
# File lib/ruote/log/storage_history.rb, line 53 def by_process (wfid) @context.storage.get_many('history', /!#{wfid}$/) end
The history system doesn't implement purge! so that when purge! is called on the engine, the history is not cleared.
Call this dangerous clear! method to clean out any history file.
# File lib/ruote/log/storage_history.rb, line 92 def clear! @context.storage.purge_type!('history') end
This is the method called by the workqueue. Incoming engine events are 'processed' here.
# File lib/ruote/log/storage_history.rb, line 100 def notify (msg) msg = msg.dup # a shallow copy is sufficient si = if fei = msg['fei'] Ruote::FlowExpressionId.to_storage_id(fei) else msg['wfid'] || 'no_wfid' end _id = msg['_id'] msg['original_id'] = _id msg['_id'] = "#{_id}!#{si}" msg['type'] = 'history' msg['original_put_at'] = msg['put_at'] msg.delete('_rev') @context.storage.put(msg) end
Returns an array [ most recent date, oldest date ] (Time instances).
# File lib/ruote/log/storage_history.rb, line 61 def range ids = @context.storage.ids('history') #p ids.sort == ids fm = DATE_REGEX.match(ids.first)[1] lm = DATE_REGEX.match(ids.last)[1] first = Time.parse("#{fm} 00:00:00 UTC") last = Time.parse("#{lm} 00:00:00 UTC") + 24 * 3600 [ first, last ] end
Generated with the Darkfish Rdoc Generator 2.