Class: Sentry::Cron::MonitorConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/sentry/cron/monitor_config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schedule, checkin_margin: nil, max_runtime: nil, timezone: nil) ⇒ MonitorConfig

Returns a new instance of MonitorConfig.



26
27
28
29
30
31
# File 'lib/sentry/cron/monitor_config.rb', line 26

def initialize(schedule, checkin_margin: nil, max_runtime: nil, timezone: nil)
  @schedule = schedule
  @checkin_margin = checkin_margin
  @max_runtime = max_runtime
  @timezone = timezone
end

Instance Attribute Details

#checkin_marginInteger?

How long (in minutes) after the expected checkin time will we wait until we consider the checkin to have been missed.

Returns:

  • (Integer, nil)


15
16
17
# File 'lib/sentry/cron/monitor_config.rb', line 15

def checkin_margin
  @checkin_margin
end

#max_runtimeInteger?

How long (in minutes) is the checkin allowed to run for in in_progress before it is considered failed.

Returns:

  • (Integer, nil)


20
21
22
# File 'lib/sentry/cron/monitor_config.rb', line 20

def max_runtime
  @max_runtime
end

#scheduleMonitorSchedule::Crontab, MonitorSchedule::Interval

The monitor schedule configuration



10
11
12
# File 'lib/sentry/cron/monitor_config.rb', line 10

def schedule
  @schedule
end

#timezoneString?

tz database style timezone string

Returns:

  • (String, nil)


24
25
26
# File 'lib/sentry/cron/monitor_config.rb', line 24

def timezone
  @timezone
end

Class Method Details

.from_crontab(crontab, **options) ⇒ Object



33
34
35
# File 'lib/sentry/cron/monitor_config.rb', line 33

def self.from_crontab(crontab, **options)
  new(MonitorSchedule::Crontab.new(crontab), **options)
end

.from_interval(num, unit, **options) ⇒ Object



37
38
39
40
41
# File 'lib/sentry/cron/monitor_config.rb', line 37

def self.from_interval(num, unit, **options)
  return nil unless MonitorSchedule::Interval::VALID_UNITS.include?(unit)

  new(MonitorSchedule::Interval.new(num, unit), **options)
end

Instance Method Details

#to_hashObject



43
44
45
46
47
48
49
50
# File 'lib/sentry/cron/monitor_config.rb', line 43

def to_hash
  {
    schedule: schedule.to_hash,
    checkin_margin: checkin_margin,
    max_runtime: max_runtime,
    timezone: timezone
  }.compact
end