Sha256: 3a79987875fbce4193cfdc22c89021df3cc1a0ad3f4fd038236150df1daa28d9
Contents?: true
Size: 879 Bytes
Versions: 1
Compression:
Stored size: 879 Bytes
Contents
require 'worker_killer/memory_limiter' require 'worker_killer/count_limiter' module WorkerKiller class Middleware attr_reader :limiter, :killer, :reaction def initialize(app, killer:, klass:, reaction: nil, **opts) @app = app @killer = killer @reaction = reaction || proc do |l, k| k.kill(l.started_at) end @limiter = klass.new(opts) end def call(env) response = @app.call(env) reaction.call(limiter, killer) if limiter.check response end class RequestsLimiter < ::WorkerKiller::Middleware def initialize(app, **opts) super(app, klass: ::WorkerKiller::CountLimiter, **opts) end end class OOMLimiter < ::WorkerKiller::Middleware def initialize(app, **opts) super(app, klass: ::WorkerKiller::MemoryLimiter, **opts) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
worker_killer-0.1.1.39838 | lib/worker_killer/middleware.rb |