Class | OpenWFE::YamlFileExpressionStorage |
In: |
lib/openwfe/expool/yamlexpstorage.rb
|
Parent: | YamlFileStorage |
YAML expression storage. Expressions (atomic pieces of process instances) are stored in a hierarchy of YAML files.
# File lib/openwfe/expool/yamlexpstorage.rb, line 66 66: def initialize (service_name, application_context) 67: 68: super service_name, application_context, '/expool' 69: 70: observe_expool 71: end
Returns nil (if the path doesn‘t match an stored expression path) or an array [ workflow_instance_id, expression_id, expression_name ].
This is a class method (not an instance one).
# File lib/openwfe/expool/yamlexpstorage.rb, line 160 160: def self.split_file_path (path) 161: 162: md = path.match %r{.*/(.*)__([\d.]*)_(.*).yaml} 163: return nil unless md 164: [ md[1], md[2], md[3] ] 165: end
# File lib/openwfe/expool/yamlexpstorage.rb, line 109 109: def fetch_root (wfid) 110: 111: fei = FlowExpressionId.new 112: fei.wfid = wfid 113: fei.expid = "0" 114: fei.expression_name = "process-definition" 115: 116: root = self[fei] 117: 118: return root if root 119: 120: # 121: # direct hit missed, scanning... 122: 123: each_object_path(compute_dir_path(wfid)) do |p| 124: 125: a = self.class.split_file_path p 126: next unless a 127: 128: next unless a[0] == wfid 129: 130: fexp = load_object p 131: 132: return fexp if fexp.is_a?(DefineExpression) 133: end 134: 135: nil 136: end
Find expressions matching various criteria. (See Engine#list_process_status for an explanation)
# File lib/openwfe/expool/yamlexpstorage.rb, line 77 77: def find_expressions (options) 78: 79: wfid_prefix = options[:wfid_prefix] 80: wfid_regex = nil 81: wfid_regex = Regexp.new("^"+wfid_prefix) if wfid_prefix 82: 83: options.delete :wfid_prefix 84: # no need to check this in further does_match? calls 85: 86: result = [] 87: 88: each_object_path do |path| 89: 90: unless path.match /\/engine_environment.yaml$/ 91: a = self.class.split_file_path path 92: next unless a 93: # not an expression file 94: 95: wfid = a[0] 96: next if wfid_regex and (not wfid_regex.match(wfid)) 97: end 98: 99: fexp = load_object path 100: 101: next unless does_match?(options, fexp) 102: 103: result << fexp 104: end 105: 106: result 107: end
Returns a human-readable list of the current YAML file paths. (one expression per path).
# File lib/openwfe/expool/yamlexpstorage.rb, line 142 142: def to_s 143: 144: s = "\n\n==== #{self.class} ====" 145: s << "\n" 146: each_object_path do |path| 147: s << path 148: s << "\n" 149: end 150: s << "==== . ====\n" 151: s 152: end
# File lib/openwfe/expool/yamlexpstorage.rb, line 169 169: def compute_dir_path (wfid) 170: 171: wfid = FlowExpressionId.to_parent_wfid wfid 172: 173: a_wfid = get_wfid_generator.split_wfid wfid 174: 175: @basepath + a_wfid[-2] + "/" + a_wfid[-1] + "/" 176: end
# File lib/openwfe/expool/yamlexpstorage.rb, line 178 178: def compute_file_path (fei) 179: 180: return @basepath + "/engine_environment.yaml" \ 181: if fei.workflow_instance_id == "0" 182: 183: wfid = fei.parent_workflow_instance_id 184: 185: compute_dir_path(wfid) + 186: fei.workflow_instance_id + "__" + 187: fei.expression_id + "_" + 188: fei.expression_name + ".yaml" 189: end