Sha256: 435cc764fcb1070789f7dc52cc2b0d8ea5ee32a55ff6ba58b152629c2d835401

Contents?: true

Size: 1.04 KB

Versions: 38

Compression:

Stored size: 1.04 KB

Contents

module Actions
  module Katello
    module EventQueue
      class PollerThread
        SLEEP_INTERVAL = 2
        cattr_accessor :instance

        def self.initialize(logger)
          self.instance ||= self.new(logger)
        end

        def self.close
          self.instance.close if self.instance
          self.instance = nil
        end

        def initialize(logger)
          @logger = logger
        end

        def close
          @thread.kill if @thread
        end

        def poll_for_events(suspended_action)
          @thread.kill if @thread
          @thread = Thread.new do
            loop do
              begin
                until (event = ::Katello::EventQueue.next_event).nil?
                  suspended_action.notify_queue_item(event.event_type, event.object_id, event.created_at) if event
                end

                sleep SLEEP_INTERVAL
              rescue => e
                suspended_action.notify_fatal(e)
                raise e
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
katello-3.5.2 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.6.0 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.6.0.1.rc2 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.6.0.rc2 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.6.0.rc1 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.5.1.1 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.5.1 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.5.0.1 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.5.0 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.5.0.rc2 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.5.0.rc1 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.4.5 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.4.4 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.4.2 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.4.1 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.4.0.2 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.4.0.1 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.3.2 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.4.0 app/lib/actions/katello/event_queue/poller_thread.rb
katello-3.4.0.rc2 app/lib/actions/katello/event_queue/poller_thread.rb