jets 1.8.6 → 1.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/lib/jets/booter.rb +1 -1
- data/lib/jets/job/dsl.rb +10 -11
- data/lib/jets/job/dsl/rule_event.rb +75 -0
- data/lib/jets/lambda/dsl.rb +4 -0
- data/lib/jets/version.rb +1 -1
- metadata +3 -3
- data/lib/jets/job/dsl/cloudwatch_event.rb +0 -81
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0431191b2ee4bd922dfbb1d04ded0d27c80b9d7f5fbe5b8ed0d82fb818805f06'
|
4
|
+
data.tar.gz: 7be272e9d21a1d65d0bfe1cbcce921f8492f37af1763fb183e06909f17cb830a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e57ef81615d661a25d12e0503fd77b5622cdf2f78c837835aefdb6e26a261882b29b4b8c6226c1ede13561680986064a91dbe3ccb18c4df895ab30d5448acf0
|
7
|
+
data.tar.gz: a67756c55f8c52ff1f90279da7ed9dc156f5dbba676c5139b7c951aa5dde01a77c61fc576f85fa60ad8be24658e405d162105cc98f4a0a5dfff89c9ca47f8167
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,12 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
|
5
5
|
|
6
|
+
## [1.8.7]
|
7
|
+
- #204 from CodingAnarchy/boot-missing-env
|
8
|
+
- #205 rename to rule_event
|
9
|
+
- add ref helper method
|
10
|
+
- deprecate: events_rule and event_pattern
|
11
|
+
|
6
12
|
## [1.8.6]
|
7
13
|
- #202 fix on_aws detection when using cloud9 hostname. Fixes #201
|
8
14
|
- user friendly error message when s3 bucket name has already been taken
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Ruby and Lambda splat out a baby and that child's name is [Jets](http://rubyonje
|
|
11
11
|
|
12
12
|
**Upgrading**: If you are upgrading Jets, please check on the [Upgrading Notes](http://rubyonjets.com/docs/upgrading/).
|
13
13
|
|
14
|
-
## What is Jets?
|
14
|
+
## What is Ruby on Jets?
|
15
15
|
|
16
16
|
Jets is a Ruby Serverless Framework. Jets allows you to create serverless applications with a beautiful language: Ruby. It includes everything required to build an application and deploy it to AWS Lambda.
|
17
17
|
|
data/lib/jets/booter.rb
CHANGED
@@ -112,7 +112,7 @@ class Jets::Booter
|
|
112
112
|
ActiveRecord::Tasks::DatabaseTasks.database_configuration = db_configs
|
113
113
|
|
114
114
|
current_config = db_configs[Jets.env]
|
115
|
-
if current_config.
|
115
|
+
if current_config.blank?
|
116
116
|
abort("ERROR: config/database.yml exists but no environment section configured for #{Jets.env}")
|
117
117
|
end
|
118
118
|
# Using ActiveRecord rake tasks outside of Rails, so we need to set up the
|
data/lib/jets/job/dsl.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/core_ext/class'
|
3
|
+
|
1
4
|
# Jets::Job::Base < Jets::Lambda::Functions
|
2
5
|
# Both Jets::Job::Base and Jets::Lambda::Functions have Dsl modules included.
|
3
6
|
# So the Jets::Job::Dsl overrides some of the Jets::Lambda::Functions behavior.
|
@@ -8,12 +11,12 @@
|
|
8
11
|
#
|
9
12
|
module Jets::Job::Dsl
|
10
13
|
extend ActiveSupport::Concern
|
11
|
-
autoload :CloudwatchEvent, "jets/job/dsl/cloudwatch_event"
|
12
14
|
autoload :DynamodbEvent, "jets/job/dsl/dynamodb_event"
|
13
15
|
autoload :EventSourceMapping, "jets/job/dsl/event_source_mapping" # base for sqs_event, etc
|
14
16
|
autoload :IotEvent, "jets/job/dsl/iot_event"
|
15
17
|
autoload :KinesisEvent, "jets/job/dsl/kinesis_event"
|
16
18
|
autoload :LogEvent, "jets/job/dsl/log_event"
|
19
|
+
autoload :RuleEvent, "jets/job/dsl/rule_event"
|
17
20
|
autoload :S3Event, "jets/job/dsl/s3_event"
|
18
21
|
autoload :SnsEvent, "jets/job/dsl/sns_event"
|
19
22
|
autoload :SqsEvent, "jets/job/dsl/sqs_event"
|
@@ -22,29 +25,25 @@ module Jets::Job::Dsl
|
|
22
25
|
class << self
|
23
26
|
include Jets::AwsServices
|
24
27
|
|
25
|
-
include CloudwatchEvent
|
26
28
|
include DynamodbEvent
|
27
29
|
include EventSourceMapping
|
28
30
|
include IotEvent
|
29
31
|
include KinesisEvent
|
30
32
|
include LogEvent
|
33
|
+
include RuleEvent
|
31
34
|
include S3Event
|
32
35
|
include SnsEvent
|
33
36
|
include SqsEvent
|
34
37
|
|
35
|
-
#
|
36
|
-
|
37
|
-
|
38
|
-
state
|
39
|
-
schedule_expression
|
40
|
-
]
|
41
|
-
define_associated_properties(ASSOCIATED_PROPERTIES)
|
42
|
-
alias_method :desc, :description
|
38
|
+
# Used to provide a little more identifiable event rule auto-descriptions
|
39
|
+
class_attribute :rule_counter
|
40
|
+
self.rule_counter = 0
|
43
41
|
|
42
|
+
# TODO: Get rid of default_associated_resource_definition concept.
|
43
|
+
# Also gets rid of the need to keep track of running @associated_properties too.
|
44
44
|
def default_associated_resource_definition(meth)
|
45
45
|
events_rule_definition
|
46
46
|
end
|
47
|
-
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Jets::Job::Dsl
|
2
|
+
module RuleEvent
|
3
|
+
# Public: Creates CloudWatch Event Rule
|
4
|
+
#
|
5
|
+
# expression - The rate expression.
|
6
|
+
#
|
7
|
+
# Examples
|
8
|
+
#
|
9
|
+
# rate("10 minutes")
|
10
|
+
# rate("10 minutes", description: "Hard job")
|
11
|
+
#
|
12
|
+
def rate(expression, props={})
|
13
|
+
schedule_job("rate(#{expression})", props)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Public: Creates CloudWatch Event Rule
|
17
|
+
#
|
18
|
+
# expression - The cron expression.
|
19
|
+
#
|
20
|
+
# Examples
|
21
|
+
#
|
22
|
+
# cron("0 */12 * * ? *")
|
23
|
+
# cron("0 */12 * * ? *", description: "Hard job")
|
24
|
+
#
|
25
|
+
def cron(expression, props={})
|
26
|
+
schedule_job("cron(#{expression})", props)
|
27
|
+
end
|
28
|
+
|
29
|
+
def schedule_job(expression, props={})
|
30
|
+
props = props.merge(schedule_expression: expression)
|
31
|
+
rule_event(props)
|
32
|
+
end
|
33
|
+
|
34
|
+
def rule_event(props={})
|
35
|
+
if props.key?(:detail)
|
36
|
+
description = props.key?(:description) ? props.delete(:description) : rule_description
|
37
|
+
rule_props = { event_pattern: props, description: description }
|
38
|
+
else # if props.key?(:event_pattern)
|
39
|
+
props[:description] ||= rule_description
|
40
|
+
rule_props = props
|
41
|
+
end
|
42
|
+
|
43
|
+
with_fresh_properties(multiple_resources: false) do
|
44
|
+
associated_properties(rule_props) # TODO: consider getting rid of @associated_properties concept
|
45
|
+
resource(events_rule_definition) # add associated resource immediately
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def rule_description
|
50
|
+
self.rule_counter += 1
|
51
|
+
"#{self.name} event rule #{rule_counter}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def events_rule_definition
|
55
|
+
resource = Jets::Resource::Events::Rule.new(associated_properties)
|
56
|
+
resource.definition # returns a definition to be added by associated_resources
|
57
|
+
end
|
58
|
+
|
59
|
+
# Deprecated methods, will be removed in the future
|
60
|
+
def events_rule(props)
|
61
|
+
puts "DEPRECATED: events_rule. Instead use rule_event. The events_rule will be removed in the future. Pausing for 5 seconds".color(:yellow)
|
62
|
+
puts caller[0]
|
63
|
+
sleep 5
|
64
|
+
rule_event(props)
|
65
|
+
end
|
66
|
+
# Deprecated methods, will be removed in the future
|
67
|
+
|
68
|
+
def event_pattern(props)
|
69
|
+
puts "DEPRECATED: events_rule. Instead use rule_event. The events_rule will be removed in the future. Pausing for 5 seconds".color(:yellow)
|
70
|
+
puts caller[0]
|
71
|
+
sleep 5
|
72
|
+
rule_event(props)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/jets/lambda/dsl.rb
CHANGED
data/lib/jets/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -701,12 +701,12 @@ files:
|
|
701
701
|
- lib/jets/job.rb
|
702
702
|
- lib/jets/job/base.rb
|
703
703
|
- lib/jets/job/dsl.rb
|
704
|
-
- lib/jets/job/dsl/cloudwatch_event.rb
|
705
704
|
- lib/jets/job/dsl/dynamodb_event.rb
|
706
705
|
- lib/jets/job/dsl/event_source_mapping.rb
|
707
706
|
- lib/jets/job/dsl/iot_event.rb
|
708
707
|
- lib/jets/job/dsl/kinesis_event.rb
|
709
708
|
- lib/jets/job/dsl/log_event.rb
|
709
|
+
- lib/jets/job/dsl/rule_event.rb
|
710
710
|
- lib/jets/job/dsl/s3_event.rb
|
711
711
|
- lib/jets/job/dsl/sns_event.rb
|
712
712
|
- lib/jets/job/dsl/sqs_event.rb
|
@@ -1,81 +0,0 @@
|
|
1
|
-
module Jets::Job::Dsl
|
2
|
-
module CloudwatchEvent
|
3
|
-
# Public: Creates CloudWatch Event Rule
|
4
|
-
#
|
5
|
-
# expression - The rate expression.
|
6
|
-
#
|
7
|
-
# Examples
|
8
|
-
#
|
9
|
-
# rate("10 minutes")
|
10
|
-
# rate("10 minutes", description: "Hard job")
|
11
|
-
#
|
12
|
-
def rate(expression, props={})
|
13
|
-
schedule_job("rate(#{expression})", props)
|
14
|
-
end
|
15
|
-
|
16
|
-
# Public: Creates CloudWatch Event Rule
|
17
|
-
#
|
18
|
-
# expression - The cron expression.
|
19
|
-
#
|
20
|
-
# Examples
|
21
|
-
#
|
22
|
-
# cron("0 */12 * * ? *")
|
23
|
-
# cron("0 */12 * * ? *", description: "Hard job")
|
24
|
-
#
|
25
|
-
def cron(expression, props={})
|
26
|
-
schedule_job("cron(#{expression})", props)
|
27
|
-
end
|
28
|
-
|
29
|
-
def schedule_job(expression, props={})
|
30
|
-
with_fresh_properties(multiple_resources: false) do
|
31
|
-
props = props.merge(schedule_expression: expression)
|
32
|
-
associated_properties(props)
|
33
|
-
resource(events_rule_definition) # add associated resource immediately
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def event_pattern(details={}, props={})
|
38
|
-
with_fresh_properties(multiple_resources: false) do
|
39
|
-
props = props.merge(event_pattern: details)
|
40
|
-
associated_properties(props)
|
41
|
-
resource(events_rule_definition) # add associated resource immediately
|
42
|
-
end
|
43
|
-
add_descriptions # useful: generic description in the Event Rule console
|
44
|
-
end
|
45
|
-
|
46
|
-
def events_rule(props={})
|
47
|
-
with_fresh_properties(multiple_resources: false) do
|
48
|
-
associated_properties(props)
|
49
|
-
resource(events_rule_definition) # add associated resource immediately
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# Works with eager definitions
|
54
|
-
def add_descriptions
|
55
|
-
numbered_resources = []
|
56
|
-
n = 1
|
57
|
-
@associated_resources.map do |associated|
|
58
|
-
# definition = associated.definition
|
59
|
-
# puts "associated #{associated.inspect}"
|
60
|
-
# puts "definition #{definition.inspect}"
|
61
|
-
|
62
|
-
# logical_id = definition.keys.first
|
63
|
-
# attributes = definition.values.first
|
64
|
-
|
65
|
-
logical_id = associated.logical_id
|
66
|
-
attributes = associated.attributes
|
67
|
-
|
68
|
-
attributes[:properties][:description] ||= "#{self.name} Event Rule #{n}"
|
69
|
-
new_definition = { "#{logical_id}" => attributes }
|
70
|
-
numbered_resources << Jets::Resource::Associated.new(new_definition)
|
71
|
-
n += 1
|
72
|
-
end
|
73
|
-
@associated_resources = numbered_resources
|
74
|
-
end
|
75
|
-
|
76
|
-
def events_rule_definition
|
77
|
-
resource = Jets::Resource::Events::Rule.new(associated_properties)
|
78
|
-
resource.definition # returns a definition to be added by associated_resources
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|