Class: Dynflow::PersistenceAdapters::Sequel
- Includes:
- Algebrick::TypeCheck
- Defined in:
- lib/dynflow/persistence_adapters/sequel.rb
Constant Summary collapse
- MAX_RETRIES =
10
- RETRY_DELAY =
1
- META_DATA =
{ execution_plan: %w(state result started_at ended_at real_time execution_time), action: [], step: %w(state started_at ended_at real_time execution_time action_id progress_done progress_weight) }
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
Attributes inherited from Abstract
Instance Method Summary collapse
- #filtering_by ⇒ Object
- #find_execution_plans(options = {}) ⇒ Object
-
#initialize(config) ⇒ Sequel
constructor
A new instance of Sequel.
- #load_action(execution_plan_id, action_id) ⇒ Object
- #load_execution_plan(execution_plan_id) ⇒ Object
- #load_step(execution_plan_id, step_id) ⇒ Object
- #ordering_by ⇒ Object
- #pagination? ⇒ Boolean
- #save_action(execution_plan_id, action_id, value) ⇒ Object
- #save_execution_plan(execution_plan_id, value) ⇒ Object
- #save_step(execution_plan_id, step_id, value) ⇒ Object
- #to_hash ⇒ Object
Methods inherited from Abstract
Constructor Details
#initialize(config) ⇒ Sequel
Returns a new instance of Sequel.
33 34 35 36 |
# File 'lib/dynflow/persistence_adapters/sequel.rb', line 33 def initialize(config) @db = initialize_db config migrate_db end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
15 16 17 |
# File 'lib/dynflow/persistence_adapters/sequel.rb', line 15 def db @db end |
Instance Method Details
#filtering_by ⇒ Object
21 22 23 |
# File 'lib/dynflow/persistence_adapters/sequel.rb', line 21 def filtering_by META_DATA.fetch :execution_plan end |
#find_execution_plans(options = {}) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/dynflow/persistence_adapters/sequel.rb', line 38 def find_execution_plans( = {}) data_set = filter(order(paginate(table(:execution_plan), ), ), ) data_set.map do |record| HashWithIndifferentAccess.new(MultiJson.load(record[:data])) end end |
#load_action(execution_plan_id, action_id) ⇒ Object
62 63 64 |
# File 'lib/dynflow/persistence_adapters/sequel.rb', line 62 def load_action(execution_plan_id, action_id) load :action, execution_plan_uuid: execution_plan_id, id: action_id end |
#load_execution_plan(execution_plan_id) ⇒ Object
46 47 48 |
# File 'lib/dynflow/persistence_adapters/sequel.rb', line 46 def load_execution_plan(execution_plan_id) load :execution_plan, uuid: execution_plan_id end |
#load_step(execution_plan_id, step_id) ⇒ Object
54 55 56 |
# File 'lib/dynflow/persistence_adapters/sequel.rb', line 54 def load_step(execution_plan_id, step_id) load :step, execution_plan_uuid: execution_plan_id, id: step_id end |
#ordering_by ⇒ Object
25 26 27 |
# File 'lib/dynflow/persistence_adapters/sequel.rb', line 25 def ordering_by META_DATA.fetch :execution_plan end |
#pagination? ⇒ Boolean
17 18 19 |
# File 'lib/dynflow/persistence_adapters/sequel.rb', line 17 def pagination? true end |
#save_action(execution_plan_id, action_id, value) ⇒ Object
66 67 68 |
# File 'lib/dynflow/persistence_adapters/sequel.rb', line 66 def save_action(execution_plan_id, action_id, value) save :action, { execution_plan_uuid: execution_plan_id, id: action_id }, value end |
#save_execution_plan(execution_plan_id, value) ⇒ Object
50 51 52 |
# File 'lib/dynflow/persistence_adapters/sequel.rb', line 50 def save_execution_plan(execution_plan_id, value) save :execution_plan, { uuid: execution_plan_id }, value end |
#save_step(execution_plan_id, step_id, value) ⇒ Object
58 59 60 |
# File 'lib/dynflow/persistence_adapters/sequel.rb', line 58 def save_step(execution_plan_id, step_id, value) save :step, { execution_plan_uuid: execution_plan_id, id: step_id }, value end |
#to_hash ⇒ Object
70 71 72 73 74 |
# File 'lib/dynflow/persistence_adapters/sequel.rb', line 70 def to_hash { execution_plans: table(:execution_plan).all, steps: table(:step).all, actions: table(:action).all } end |