Class: ConfigOMat::Op::NextTick

Inherits:
LifecycleVM::OpBase
  • Object
show all
Defined in:
lib/config_o_mat/configurator/op/next_tick.rb

Constant Summary collapse

PAUSE_INTERVAL =
1

Instance Method Summary collapse

Instance Method Details

#callObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/config_o_mat/configurator/op/next_tick.rb', line 29

def call
  self.run_count += 1

  SdNotify.watchdog

  if gc_compact > 0 && run_count % gc_compact == 0
    response = GC.compact
    logger&.info(:gc_compact, compact: response)
  end

  if gc_stat > 0 && run_count % gc_stat == 0
    response = GC.stat
    logger&.info(:gc_stat, stat: response)
  end

  # If we got here then our retry process has succeeded.
  self.retries_left = retry_count

  # I'm calling Kernel.sleep directly so that tests can easily stub it out.
  Kernel.sleep PAUSE_INTERVAL

  if Time.now.to_i - last_refresh_time > refresh_interval
    self.next_state = :refreshing_profiles
  else
    self.next_state = :running
  end
end