Sha256: c6777bdfd6ab631188c779f751d5e2564dda6421eb1895f0b99f8c857716e1d6

Contents?: true

Size: 799 Bytes

Versions: 27

Compression:

Stored size: 799 Bytes

Contents

require 'active_support'
require 'active_support/core_ext/numeric'
require 'roo_on_rails/sidekiq/settings'

module RooOnRails
  module Sidekiq
    class QueueLatency
      extend Forwardable

      def_delegators :@queue, :size, :latency, :name
      attr_reader :queue

      def self.queues
        ::Sidekiq::Queue.all.each_with_object([]) do |q, array|
          array << new(q) if Settings.queues.include?(q.name.to_s)
        end
      end

      def initialize(queue)
        @queue = queue
      end

      def normalised_latency
        permitted_latency = Settings.permitted_latency_values[queue.name]
        return queue.latency.fdiv(permitted_latency).round(3) if permitted_latency
        raise("Cannot determine permitted latency for queue #{queue.name}")
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
roo_on_rails-2.2.2 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-2.2.1 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-2.2.0 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-2.1.2 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-2.1.0 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-2.0.0.pre.pre.2 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-2.0.0.pre.pre.1 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-1.22.0 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-1.21.0 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-1.20.0 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-1.19.0 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-1.18.0 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-1.17.0 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-1.16.2 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-1.16.1 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-1.16.0 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-1.15.0 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-1.14.0 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-1.13.1 lib/roo_on_rails/sidekiq/queue_latency.rb
roo_on_rails-1.13.0 lib/roo_on_rails/sidekiq/queue_latency.rb