Sha256: 95252d47ae0cafb3ce0fe37772b69e6d680cc113511089bb095af68340159761

Contents?: true

Size: 1.26 KB

Versions: 86

Compression:

Stored size: 1.26 KB

Contents

module SuckerPunch
  module Counter
    module Utilities
      def value
        @counter.value
      end

      def increment
        @counter.increment
      end

      def decrement
        @counter.decrement
      end
    end

    class Busy
      attr_reader :counter

      include Utilities

      COUNTER = Concurrent::Map.new do |hash, name|
        hash.compute_if_absent(name) { Concurrent::AtomicFixnum.new }
      end

      def self.clear
        COUNTER.clear
      end

      def initialize(queue_name)
        @counter = COUNTER[queue_name]
      end
    end

    class Processed
      attr_reader :counter

      include Utilities

      COUNTER = Concurrent::Map.new do |hash, name|
        hash.compute_if_absent(name) { Concurrent::AtomicFixnum.new }
      end

      def self.clear
        COUNTER.clear
      end

      def initialize(queue_name)
        @counter = COUNTER[queue_name]
      end
    end

    class Failed
      attr_reader :counter

      include Utilities

      COUNTER = Concurrent::Map.new do |hash, name|
        hash.compute_if_absent(name) { Concurrent::AtomicFixnum.new }
      end

      def self.clear
        COUNTER.clear
      end

      def initialize(queue_name)
        @counter = COUNTER[queue_name]
      end
    end
  end
end

Version data entries

86 entries across 86 versions & 2 rubygems

Version Path
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.2.9 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.2.8 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.2.7 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.2.6 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.2.5 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.2.4 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.2.3 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.2.2 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.2.1 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.2.0 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.1.99 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.1.98 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.1.97 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.1.96 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.1.95 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.1.94 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.1.93 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb
harbr-0.1.91 vendor/bundle/ruby/3.2.0/gems/sucker_punch-3.1.0/lib/sucker_punch/counter.rb