Sha256: fa92f2bbdb4c8144fbd1fde44950ead8dd0a1f50f3183ffedaa25655100ed9f3

Contents?: true

Size: 570 Bytes

Versions: 3

Compression:

Stored size: 570 Bytes

Contents

# frozen_string_literal: true

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

      def met?(children, logger)
        if limit = @limits[children.last_generation]
          if worker = children.fresh_workers.find { |w| w.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

3 entries across 3 versions & 1 rubygems

Version Path
pitchfork-0.1.2 lib/pitchfork/refork_condition.rb
pitchfork-0.1.1 lib/pitchfork/refork_condition.rb
pitchfork-0.1.0 lib/pitchfork/refork_condition.rb