class MingleEvents::Poller
Public Class Methods
new(mingle_access, processors_by_project_identifier, state_dir=nil)
click to toggle source
Manages a full sweep of event processing across each processing pipeline configured for specified mingle projects. processors_by_project_identifier should be a hash where the keys are mingle project identifiers and the values are lists of event processors.
# File lib/mingle_events/poller.rb 8 def initialize(mingle_access, processors_by_project_identifier, state_dir=nil) 9 @mingle_access = mingle_access 10 @processors_by_project_identifier = processors_by_project_identifier 11 @state_dir = state_dir 12 end
Public Instance Methods
run_once()
click to toggle source
Run a single poll for each project configured with processor(s) and broadcast each event to each processor.
# File lib/mingle_events/poller.rb 16 def run_once 17 MingleEvents.log.info("MingleEvents::Poller about to poll once...") 18 @processors_by_project_identifier.each do |project_identifier, processors| 19 fetcher = ProjectEventFetcher.new(project_identifier, @mingle_access, @state_dir) 20 fetcher.set_current_state_to_now_if_no_current_state 21 latest_events = fetcher.fetch_latest.to_a 22 processors.each{|p| p.process_events(latest_events)} 23 end 24 end