Class: Wakame::Trigger

Inherits:
Object
  • Object
show all
Includes:
AttributeHelper, FilterChain
Defined in:
lib/wakame/trigger.rb

Constant Summary

Constants included from AttributeHelper

AttributeHelper::CONVERT_CLASSES, AttributeHelper::PRIMITIVE_CLASSES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AttributeHelper

#dump_attrs

Methods included from FilterChain

included, #run_filter

Instance Attribute Details

#rule_engineObject (readonly)

Returns the value of attribute rule_engine.



8
9
10
# File 'lib/wakame/trigger.rb', line 8

def rule_engine
  @rule_engine
end

Instance Method Details

#agent_monitorObject



21
22
23
# File 'lib/wakame/trigger.rb', line 21

def agent_monitor
  @rule_engine.agent_monitor
end

#bind_engine(rule_engine) ⇒ Object



25
26
27
# File 'lib/wakame/trigger.rb', line 25

def bind_engine(rule_engine)
  @rule_engine = rule_engine
end

#cleanupObject



49
50
# File 'lib/wakame/trigger.rb', line 49

def cleanup
end

#command_queueObject



9
10
11
# File 'lib/wakame/trigger.rb', line 9

def command_queue
  @rule_engine.command_queue
end

#masterObject



17
18
19
# File 'lib/wakame/trigger.rb', line 17

def master
  @rule_engine.master
end

#register_hooksObject



46
47
# File 'lib/wakame/trigger.rb', line 46

def register_hooks
end

#service_clusterObject



13
14
15
# File 'lib/wakame/trigger.rb', line 13

def service_cluster
  @rule_engine.service_cluster
end

#trigger_action(action) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/wakame/trigger.rb', line 29

def trigger_action(action)
  found = rule_engine.active_jobs.find { |id, job|
    job[:src_rule].class == self.class
  }

  if found
    Wakame.log.warn("#{self.class}: Exisiting Job \"#{found[:job_id]}\" was kicked from this rule and it's still running. Skipping...")
    raise CancelActionError
  end

  rule_engine.create_job_context(self, action)
  action.bind_triggered_rule(self)
  
  rule_engine.run_action(action)
  action.job_id
end