Sha256: 767d004fd596a5fa27eab9e881b98791c162f64d37c4c9793144c49e352c9e5e

Contents?: true

Size: 1.5 KB

Versions: 30

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

require 'sentry/cron/monitor_schedule'

module Sentry
  module Cron
    class MonitorConfig
      # The monitor schedule configuration
      # @return [MonitorSchedule::Crontab, MonitorSchedule::Interval]
      attr_accessor :schedule

      # How long (in minutes) after the expected checkin time will we wait
      # until we consider the checkin to have been missed.
      # @return [Integer, nil]
      attr_accessor :checkin_margin

      # How long (in minutes) is the checkin allowed to run for in in_progress
      # before it is considered failed.
      # @return [Integer, nil]
      attr_accessor :max_runtime

      # tz database style timezone string
      # @return [String, nil]
      attr_accessor :timezone

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

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

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

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

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

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
sentry-ruby-core-5.19.0 lib/sentry/cron/monitor_config.rb
sentry-ruby-5.19.0 lib/sentry/cron/monitor_config.rb
sentry-ruby-core-5.18.2 lib/sentry/cron/monitor_config.rb
sentry-ruby-5.18.2 lib/sentry/cron/monitor_config.rb
sentry-ruby-core-5.18.1 lib/sentry/cron/monitor_config.rb
sentry-ruby-5.18.1 lib/sentry/cron/monitor_config.rb
sentry-ruby-5.18.0 lib/sentry/cron/monitor_config.rb
sentry-ruby-core-5.18.0 lib/sentry/cron/monitor_config.rb
sentry-ruby-core-5.17.3 lib/sentry/cron/monitor_config.rb
sentry-ruby-5.17.3 lib/sentry/cron/monitor_config.rb
sentry-ruby-5.17.2 lib/sentry/cron/monitor_config.rb
sentry-ruby-core-5.17.2 lib/sentry/cron/monitor_config.rb
sentry-ruby-core-5.17.1 lib/sentry/cron/monitor_config.rb
sentry-ruby-5.17.1 lib/sentry/cron/monitor_config.rb
sentry-ruby-5.17.0 lib/sentry/cron/monitor_config.rb
sentry-ruby-core-5.17.0 lib/sentry/cron/monitor_config.rb
sentry-ruby-core-5.16.1 lib/sentry/cron/monitor_config.rb
sentry-ruby-5.16.1 lib/sentry/cron/monitor_config.rb
sentry-ruby-5.16.0 lib/sentry/cron/monitor_config.rb
sentry-ruby-core-5.16.0 lib/sentry/cron/monitor_config.rb