Class: WorkerKiller::RufusScheduler::OOMLimiter

Inherits:
BaseLimiter
  • Object
show all
Defined in:
lib/worker_killer/rufus_scheduler/oom_limiter.rb

Overview

Register rufus process killer by RAM usage.

Instance Attribute Summary

Attributes inherited from BaseLimiter

#frequency, #job_filter, #killer, #limiter, #scheduler, #timeout

Instance Method Summary collapse

Methods inherited from BaseLimiter

#check_after_job?, #register, register, #run_check

Constructor Details

#initialize(scheduler:, frequency:, timeout:, logger: nil, job_filter: nil, **limiter_kwargs) ⇒ OOMLimiter

Returns a new instance of OOMLimiter.

Parameters:

  • scheduler (Rufus::Scheduler)
  • limiter_kwargs (Hash)
  • frequency (Integer, nil)
  • timeout (Integer)
  • logger (Logger, nil) (defaults to: nil)
  • job_filter (Proc, nil) (defaults to: nil)

    when frequency=null, used to select which jobs should be counted



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/worker_killer/rufus_scheduler/oom_limiter.rb', line 13

def initialize(scheduler:, frequency:, timeout:, logger: nil, job_filter: nil, **limiter_kwargs)
  # when frequency parameter used to set how often check should be run, check_cycle is not needed.
  limiter = ::WorkerKiller::MemoryLimiter.new(check_cycle: 1, **limiter_kwargs)
  super(
    scheduler: scheduler,
    frequency: frequency,
    timeout: timeout,
    limiter: limiter,
    logger: logger,
    job_filter: job_filter
  )
end