Class: ESM::Request::Overseer

Inherits:
Object
  • Object
show all
Defined in:
lib/esm/model/request/overseer.rb

Class Method Summary collapse

Class Method Details

.dieObject



18
19
20
21
22
# File 'lib/esm/model/request/overseer.rb', line 18

def self.die
  return if @task.nil?

  @task.shutdown
end

.watchObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/esm/model/request/overseer.rb', line 6

def self.watch
  execution_interval = ESM.config.request_overseer.check_every

  @task = Concurrent::TimerTask.execute(execution_interval:) do
    ESM::Database.with_connection do
      ESM::Request.expired.destroy_all
    end
  end

  @task.add_observer(ErrorHandler.new)
end