Sha256: e708038d4f768ea56e4391405c2637331fd80f70fe8f2346674079f0f439f141

Contents?: true

Size: 544 Bytes

Versions: 1

Compression:

Stored size: 544 Bytes

Contents

# frozen_string_literal: true

module Pitchfork
  module ReforkCondition
    class RequestsCount
      def initialize(request_counts)
        @limits = request_counts
      end

      def met?(worker, logger)
        if limit = @limits.fetch(worker.generation) { @limits.last }
          if worker.requests_count >= limit
            logger.info("worker=#{worker.nr} pid=#{worker.pid} processed #{worker.requests_count} requests, triggering a refork")
            return true
          end
        end
        false
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pitchfork-0.2.0 lib/pitchfork/refork_condition.rb