class Xronor::Job
Constants
- DOM_INDEX
- DOW_INDEX
- POD_NAME_MAX_LENGTH
Attributes
command[R]
description[R]
name[R]
schedule[R]
Public Class Methods
new(name, description, schedule, command)
click to toggle source
# File lib/xronor/job.rb, line 8 def initialize(name, description, schedule, command) @name = name @description = description @schedule = schedule @command = command end
Public Instance Methods
cloud_watch_rule_name(prefix)
click to toggle source
# File lib/xronor/job.rb, line 36 def cloud_watch_rule_name(prefix) "#{prefix}#{@name}-#{hashcode}".gsub(/[^\.\-_A-Za-z0-9]/, "-").downcase end
cloud_watch_schedule()
click to toggle source
# File lib/xronor/job.rb, line 17 def cloud_watch_schedule cron_fields = @schedule.split(" ") if cron_fields[DOM_INDEX] == "*" && cron_fields[DOW_INDEX] == "*" cron_fields[DOW_INDEX] = "?" else cron_fields[DOM_INDEX] = "?" if cron_fields[DOM_INDEX] == "*" if cron_fields[DOW_INDEX] == "*" cron_fields[DOW_INDEX] = "?" else cron_fields[DOW_INDEX] = cron_fields[DOW_INDEX].to_i + 1 end end cron_fields << "*" # Year "cron(#{cron_fields.join(" ")})" end
k8s_pod_name()
click to toggle source
# File lib/xronor/job.rb, line 40 def k8s_pod_name @name.gsub(/[^\.\-A-Za-z0-9]/, "-").downcase[0...POD_NAME_MAX_LENGTH] end
Private Instance Methods
hashcode()
click to toggle source
# File lib/xronor/job.rb, line 46 def hashcode @hashcode ||= OpenSSL::Digest::SHA256.hexdigest("#{@name}\t#{@description}\t#{@schedule}\t#{@command}")[0..12] end