Sha256: 79b83655d2ef1a5e65b792b2788ca1425759c2e5225dedbbf691ada662cd7d22

Contents?: true

Size: 1.26 KB

Versions: 38

Compression:

Stored size: 1.26 KB

Contents

module Katello
  class EventQueue
    @event_types = {}

    def self.clear_events(event_type, object_id, on_or_earlier_than)
      Katello::Event.where(:in_progress => true, :object_id => object_id, :event_type => event_type).where('created_at <= ?', on_or_earlier_than).destroy_all
    end

    def self.next_event
      first = Katello::Event.where(:in_progress => false).order(:created_at => 'asc').limit(1)
      events = Katello::Event.where(:in_progress => false, :object_id => first.pluck(:object_id),
                                    :event_type => first.pluck(:event_type)).order(:created_at => 'asc')
      last = events.last
      events.update_all(:in_progress => true)
      last
    end

    def self.reset_in_progress
      Katello::Event.where(:in_progress => true).update_all(:in_progress => false)
    end

    def self.push_event(event_type, id)
      Event.create!(:event_type => event_type, :object_id => id)
    end

    def self.register_event(event_type, klass)
      @event_types[event_type] = klass.name
    end

    def self.supported_event_types
      @event_types.keys
    end

    def self.event_class(event_type)
      fail _("Invalid event_type %s") % event_type if @event_types[event_type].nil?
      @event_types[event_type].constantize
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

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