Module: Jets::Job::Dsl::RuleEvent
- Defined in:
- lib/jets/job/dsl/rule_event.rb
Instance Method Summary collapse
-
#cron(expression, props = {}) ⇒ Object
Public: Creates CloudWatch Event Rule.
-
#event_pattern(props) ⇒ Object
Deprecated methods, will be removed in the future.
-
#events_rule(props) ⇒ Object
Deprecated methods, will be removed in the future.
- #events_rule_definition ⇒ Object
-
#rate(expression, props = {}) ⇒ Object
Public: Creates CloudWatch Event Rule.
- #rule_description ⇒ Object
- #rule_event(props = {}) ⇒ Object
- #schedule_job(expression, props = {}) ⇒ Object
Instance Method Details
#cron(expression, props = {}) ⇒ Object
Public: Creates CloudWatch Event Rule
expression - The cron expression.
Examples
cron("0 */12 * * ? *")
cron("0 */12 * * ? *", description: "Hard job")
25 26 27 |
# File 'lib/jets/job/dsl/rule_event.rb', line 25 def cron(expression, props={}) schedule_job("cron(#{expression})", props) end |
#event_pattern(props) ⇒ Object
Deprecated methods, will be removed in the future
71 72 73 74 75 76 |
# File 'lib/jets/job/dsl/rule_event.rb', line 71 def event_pattern(props) puts "DEPRECATED: events_rule. Instead use rule_event. The events_rule will be removed in the future. Pausing for 5 seconds".color(:yellow) puts caller[0] sleep 5 rule_event(props) end |
#events_rule(props) ⇒ Object
Deprecated methods, will be removed in the future
63 64 65 66 67 68 |
# File 'lib/jets/job/dsl/rule_event.rb', line 63 def events_rule(props) puts "DEPRECATED: events_rule. Instead use rule_event. The events_rule will be removed in the future. Pausing for 5 seconds".color(:yellow) puts caller[0] sleep 5 rule_event(props) end |
#events_rule_definition ⇒ Object
57 58 59 60 |
# File 'lib/jets/job/dsl/rule_event.rb', line 57 def events_rule_definition resource = Jets::Cfn::Resource::Events::Rule.new(associated_properties) resource.definition # returns a definition to be added by associated_resources end |
#rate(expression, props = {}) ⇒ Object
Public: Creates CloudWatch Event Rule
expression - The rate expression.
Examples
rate("10 minutes")
rate("10 minutes", description: "Hard job")
12 13 14 |
# File 'lib/jets/job/dsl/rule_event.rb', line 12 def rate(expression, props={}) schedule_job("rate(#{expression})", props) end |
#rule_description ⇒ Object
52 53 54 55 |
# File 'lib/jets/job/dsl/rule_event.rb', line 52 def rule_description self.rule_counter += 1 "#{self.name} event rule #{rule_counter}" end |
#rule_event(props = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/jets/job/dsl/rule_event.rb', line 34 def rule_event(props={}) # detail should all be lowercase: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html # source should also all be lowercase if props.key?(:detail) # :description should be lowercased. It's a convenience property, and belongs at a higher level description = props.key?(:description) ? props.delete(:description) : rule_description rule_props = { EventPattern: props, Description: description } else # if props.key?(:event_pattern) props[:Description] ||= rule_description rule_props = props end with_fresh_properties(multiple_resources: false) do associated_properties(rule_props) # TODO: consider getting rid of @associated_properties concept resource(events_rule_definition) # add associated resource immediately end end |
#schedule_job(expression, props = {}) ⇒ Object
29 30 31 32 |
# File 'lib/jets/job/dsl/rule_event.rb', line 29 def schedule_job(expression, props={}) props = props.merge(ScheduleExpression: expression) rule_event(props) end |