Sha256: 148b9f3fd5c1e868f690fa6845c3a8e1d4945bf995721a795d8c2f6ed7355c3f
Contents?: true
Size: 825 Bytes
Versions: 2
Compression:
Stored size: 825 Bytes
Contents
module Bluepill class Trigger @implementations = {} def self.inherited(klass) @implementations[klass.name.split('::').last.underscore.to_sym] = klass end def self.[](name) @implementations[name] end attr_accessor :process, :logger def initialize(process, options = {}) self.process = process self.logger = options[:logger] end def notify(transition) raise "Implement in subclass" end def dispatch!(event) self.process.dispatch!(event) end def schedule_event(event, delay) # TODO: maybe wrap this in a ScheduledEvent class with methods like cancel Thread.new do sleep delay self.logger.info("Retrying from flapping") process.dispatch!(event) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bluepill-0.0.4 | lib/bluepill/trigger.rb |
bluepill-0.0.3 | lib/bluepill/trigger.rb |