lib/pitchfork/refork_condition.rb in pitchfork-0.1.2 vs lib/pitchfork/refork_condition.rb in pitchfork-0.2.0

- old
+ new

@@ -5,12 +5,12 @@ 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 } + 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