Sha256: defd6a4e566bce7eb6bdd55d2e5b86464c49c016c8f2e9bbe98b1d66affb9508
Contents?: true
Size: 953 Bytes
Versions: 30
Compression:
Stored size: 953 Bytes
Contents
module GarbageMan module Rack class Middleware def initialize(app) @app = app end @@ok_response = [200, {'Content-Length' => '0'}, ''] @@gc_response = [589, {'Content-Length' => '0'}, ''] def call(env) GarbageMan::Collector.instance.request_count += 1 if env['REQUEST_PATH'] == GarbageMan::Config.gc_health_check_request_path GarbageMan::Collector.instance.healthy? ? @@ok_response : @@gc_response else # this is not 100% preventable with nginx, nginx will still send requests while waiting for the health check response GarbageMan::Collector.instance.logger.debug("still receiving traffic even though I'm waiting to GC") if GarbageMan::Collector.instance.will_collect GarbageMan::Collector.instance.select_next_server if GarbageMan::Collector::instance.will_select_next_server @app.call(env) end end end end end
Version data entries
30 entries across 30 versions & 1 rubygems