class EbDeployer::EventPoller
Constants
- POLL_INTERVAL
Public Class Methods
new(event_source)
click to toggle source
# File lib/eb_deployer/event_poller.rb, line 6 def initialize(event_source) @event_source = event_source end
Public Instance Methods
get_anchor()
click to toggle source
# File lib/eb_deployer/event_poller.rb, line 10 def get_anchor @event_source.get_anchor end
poll(from_anchor) { |event| ... }
click to toggle source
# File lib/eb_deployer/event_poller.rb, line 14 def poll(from_anchor, &block) handled = Set.new loop do @event_source.fetch_events(from_anchor) do |events| # events from event source is latest first order to_be_handled = [] reached_anchor = false events.each do |event| if digest(event) == digest(from_anchor) reached_anchor = true end if !handled.include?(digest(event)) && !reached_anchor to_be_handled << event end end to_be_handled.reverse.each do |event| yield(event) handled << digest(event) end !reached_anchor end sleep POLL_INTERVAL end end
Private Instance Methods
digest(event)
click to toggle source
# File lib/eb_deployer/event_poller.rb, line 45 def digest(event) return nil unless event event = event.to_h if event.respond_to?(:to_h) JSON.dump(event) end