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
68 69 70 71 72 73 |
# File 'lib/jets/job/dsl/rule_event.rb', line 68 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
60 61 62 63 64 65 |
# File 'lib/jets/job/dsl/rule_event.rb', line 60 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
54 55 56 57 |
# File 'lib/jets/job/dsl/rule_event.rb', line 54 def events_rule_definition resource = Jets::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
49 50 51 52 |
# File 'lib/jets/job/dsl/rule_event.rb', line 49 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 |
# File 'lib/jets/job/dsl/rule_event.rb', line 34 def rule_event(props={}) if props.key?(:detail) description = props.key?(:description) ? props.delete(:description) : rule_description rule_props = { event_pattern: 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(schedule_expression: expression) rule_event(props) end |