Class | OpenWFE::Extras::DbErrorJournal |
In: |
lib/openwfe/extras/expool/dberrorjournal.rb
|
Parent: | OpenWFE::ErrorJournal |
A database backed error journal.
(no synchronization needed it seems)
# File lib/openwfe/extras/expool/dberrorjournal.rb, line 109 109: def initialize (service_name, application_context) 110: 111: require 'openwfe/storage/yamlcustom' 112: # making sure this file has been required at this point 113: # this yamlcustom thing prevents the whole OpenWFE ecosystem 114: # to get serialized :) 115: 116: super 117: end
Returns the error log for a given workflow/process instance, the older error first.
# File lib/openwfe/extras/expool/dberrorjournal.rb, line 123 123: def get_error_log (wfid) 124: 125: wfid = extract_wfid wfid, true 126: errors = ProcessError.find_all_by_wfid wfid, :order => "id asc" 127: errors.collect { |e| e.owfe_error } 128: end
Returns a map wfid => error log, ie returns 1 error log for each workflow/process instance that encountered an error.
# File lib/openwfe/extras/expool/dberrorjournal.rb, line 142 142: def get_error_logs 143: 144: errors = ProcessError.find :all 145: 146: result = {} 147: 148: errors.each do |e| 149: (result[e.wfid] ||= []) << e.owfe_error 150: end 151: 152: result 153: end
Erases all the errors for one given workflow/process instance.
# File lib/openwfe/extras/expool/dberrorjournal.rb, line 133 133: def remove_error_log (wfid) 134: 135: ProcessError.destroy_all ["wfid = ?", wfid] 136: end
Removes a set of errors. This is used by the expool when resuming a previously broken process instance.
# File lib/openwfe/extras/expool/dberrorjournal.rb, line 159 159: def remove_errors (wfid, errors) 160: 161: errors = Array(errors) 162: 163: errors.each do |e| 164: ProcessError.delete e.db_id 165: end 166: end
This is the inner method used by the error journal to record a process error (instance of OpenWFE::ProcessError) that it observed in the expression pool.
This method will throw an exception in case of trouble with the database.
# File lib/openwfe/extras/expool/dberrorjournal.rb, line 178 178: def record_error (process_error) 179: 180: e = ProcessError.new 181: 182: e.wfid = process_error.wfid 183: e.svalue = process_error 184: 185: e.save! 186: end