Class: Ambo::Tasks::Periodic

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/ambo/tasks/periodic.rb

Overview

Small utility class for creating periodic tasks that automatically reschedule themselves. Internally, this class uses the Concurrent::ScheduledTask class.

Instance Method Summary collapse

Constructor Details

#initialize(options, state, &block) ⇒ Periodic


11
12
13
14
15
16
17
18
# File 'lib/ambo/tasks/periodic.rb', line 11

def initialize(options, state, &block)
  @options = options
  @block = block

  @last_sent = state.last_sent

  schedule!
end

Instance Method Details

#cancelObject


20
21
22
# File 'lib/ambo/tasks/periodic.rb', line 20

def cancel
  @current_task&.cancel
end