aws-sdk-rails 4.1.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +239 -0
- data/LICENSE.txt +12 -0
- data/VERSION +1 -1
- data/lib/aws/rails/action_mailbox/rspec.rb +6 -65
- data/lib/aws/rails/middleware/elastic_beanstalk_sqsd.rb +134 -0
- data/lib/aws/rails/notifications.rb +3 -6
- data/lib/aws/rails/railtie.rb +39 -40
- data/lib/aws-sdk-rails.rb +16 -8
- metadata +26 -152
- data/app/controllers/action_mailbox/ingresses/ses/inbound_emails_controller.rb +0 -79
- data/bin/aws_sqs_active_job +0 -6
- data/config/routes.rb +0 -8
- data/lib/action_dispatch/session/dynamodb_store.rb +0 -38
- data/lib/active_job/queue_adapters/sqs_adapter/params.rb +0 -78
- data/lib/active_job/queue_adapters/sqs_adapter.rb +0 -58
- data/lib/active_job/queue_adapters/sqs_async_adapter.rb +0 -39
- data/lib/aws/rails/action_mailbox/engine.rb +0 -21
- data/lib/aws/rails/action_mailbox/rspec/email.rb +0 -50
- data/lib/aws/rails/action_mailbox/rspec/subscription_confirmation.rb +0 -37
- data/lib/aws/rails/action_mailbox/s3_client.rb +0 -28
- data/lib/aws/rails/action_mailbox/sns_message_verifier.rb +0 -18
- data/lib/aws/rails/action_mailbox/sns_notification.rb +0 -99
- data/lib/aws/rails/middleware/ebs_sqs_active_job_middleware.rb +0 -118
- data/lib/aws/rails/ses_mailer.rb +0 -49
- data/lib/aws/rails/sesv2_mailer.rb +0 -60
- data/lib/aws/rails/sqs_active_job/configuration.rb +0 -184
- data/lib/aws/rails/sqs_active_job/deduplication.rb +0 -21
- data/lib/aws/rails/sqs_active_job/executor.rb +0 -77
- data/lib/aws/rails/sqs_active_job/job_runner.rb +0 -27
- data/lib/aws/rails/sqs_active_job/lambda_handler.rb +0 -63
- data/lib/aws/rails/sqs_active_job/poller.rb +0 -160
- data/lib/aws/rails/sqs_active_job.rb +0 -33
- data/lib/generators/aws_record/base.rb +0 -213
- data/lib/generators/aws_record/generated_attribute.rb +0 -138
- data/lib/generators/aws_record/model/USAGE +0 -24
- data/lib/generators/aws_record/model/model_generator.rb +0 -25
- data/lib/generators/aws_record/model/templates/model.erb +0 -48
- data/lib/generators/aws_record/model/templates/table_config.erb +0 -18
- data/lib/generators/aws_record/secondary_index.rb +0 -66
- data/lib/generators/dynamo_db/session_store_migration/USAGE +0 -13
- data/lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb +0 -48
- data/lib/generators/dynamo_db/session_store_migration/templates/dynamo_db_session_store.yml +0 -70
- data/lib/generators/dynamo_db/session_store_migration/templates/session_store_migration.erb +0 -9
- data/lib/tasks/aws_record/migrate.rake +0 -14
- data/lib/tasks/dynamo_db/session_store.rake +0 -10
metadata
CHANGED
@@ -1,240 +1,114 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sdk-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amazon Web Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: aws-
|
14
|
+
name: aws-actiondispatch-dynamodb
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: aws-
|
28
|
+
name: aws-actionmailbox-ses
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: aws-
|
42
|
+
name: aws-actionmailer-ses
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
- - ">="
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: 1.123.0
|
51
|
-
type: :runtime
|
52
|
-
prerelease: false
|
53
|
-
version_requirements: !ruby/object:Gem::Requirement
|
54
|
-
requirements:
|
55
|
-
- - "~>"
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: '1'
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 1.123.0
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: aws-sdk-ses
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '1'
|
68
|
-
- - ">="
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: 1.50.0
|
71
|
-
type: :runtime
|
72
|
-
prerelease: false
|
73
|
-
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
requirements:
|
75
|
-
- - "~>"
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '1'
|
78
|
-
- - ">="
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: 1.50.0
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
|
-
name: aws-sdk-sesv2
|
83
|
-
requirement: !ruby/object:Gem::Requirement
|
84
|
-
requirements:
|
85
|
-
- - "~>"
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '1'
|
88
|
-
- - ">="
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: 1.34.0
|
91
|
-
type: :runtime
|
92
|
-
prerelease: false
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - "~>"
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '1'
|
98
|
-
- - ">="
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
version: 1.34.0
|
101
|
-
- !ruby/object:Gem::Dependency
|
102
|
-
name: aws-sdk-sns
|
103
|
-
requirement: !ruby/object:Gem::Requirement
|
104
|
-
requirements:
|
105
|
-
- - "~>"
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
version: '1'
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 1.61.0
|
47
|
+
version: '0'
|
111
48
|
type: :runtime
|
112
49
|
prerelease: false
|
113
50
|
version_requirements: !ruby/object:Gem::Requirement
|
114
51
|
requirements:
|
115
52
|
- - "~>"
|
116
53
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
118
|
-
- - ">="
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
version: 1.61.0
|
54
|
+
version: '0'
|
121
55
|
- !ruby/object:Gem::Dependency
|
122
|
-
name: aws-
|
56
|
+
name: aws-activejob-sqs
|
123
57
|
requirement: !ruby/object:Gem::Requirement
|
124
58
|
requirements:
|
125
59
|
- - "~>"
|
126
60
|
- !ruby/object:Gem::Version
|
127
|
-
version: '
|
128
|
-
- - ">="
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: 1.56.0
|
61
|
+
version: '0'
|
131
62
|
type: :runtime
|
132
63
|
prerelease: false
|
133
64
|
version_requirements: !ruby/object:Gem::Requirement
|
134
65
|
requirements:
|
135
66
|
- - "~>"
|
136
67
|
- !ruby/object:Gem::Version
|
137
|
-
version: '
|
138
|
-
- - ">="
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
version: 1.56.0
|
68
|
+
version: '0'
|
141
69
|
- !ruby/object:Gem::Dependency
|
142
|
-
name:
|
143
|
-
requirement: !ruby/object:Gem::Requirement
|
144
|
-
requirements:
|
145
|
-
- - ">="
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
version: 7.0.0
|
148
|
-
type: :runtime
|
149
|
-
prerelease: false
|
150
|
-
version_requirements: !ruby/object:Gem::Requirement
|
151
|
-
requirements:
|
152
|
-
- - ">="
|
153
|
-
- !ruby/object:Gem::Version
|
154
|
-
version: 7.0.0
|
155
|
-
- !ruby/object:Gem::Dependency
|
156
|
-
name: concurrent-ruby
|
70
|
+
name: aws-record-rails
|
157
71
|
requirement: !ruby/object:Gem::Requirement
|
158
72
|
requirements:
|
159
73
|
- - "~>"
|
160
74
|
- !ruby/object:Gem::Version
|
161
|
-
version: '
|
162
|
-
- - ">="
|
163
|
-
- !ruby/object:Gem::Version
|
164
|
-
version: 1.3.1
|
75
|
+
version: '0'
|
165
76
|
type: :runtime
|
166
77
|
prerelease: false
|
167
78
|
version_requirements: !ruby/object:Gem::Requirement
|
168
79
|
requirements:
|
169
80
|
- - "~>"
|
170
81
|
- !ruby/object:Gem::Version
|
171
|
-
version: '
|
172
|
-
- - ">="
|
173
|
-
- !ruby/object:Gem::Version
|
174
|
-
version: 1.3.1
|
82
|
+
version: '0'
|
175
83
|
- !ruby/object:Gem::Dependency
|
176
84
|
name: railties
|
177
85
|
requirement: !ruby/object:Gem::Requirement
|
178
86
|
requirements:
|
179
87
|
- - ">="
|
180
88
|
- !ruby/object:Gem::Version
|
181
|
-
version: 7.
|
89
|
+
version: 7.1.0
|
182
90
|
type: :runtime
|
183
91
|
prerelease: false
|
184
92
|
version_requirements: !ruby/object:Gem::Requirement
|
185
93
|
requirements:
|
186
94
|
- - ">="
|
187
95
|
- !ruby/object:Gem::Version
|
188
|
-
version: 7.
|
189
|
-
description: Integrates the AWS Ruby
|
96
|
+
version: 7.1.0
|
97
|
+
description: Integrates the AWS SDK for Ruby with Ruby on Rails
|
190
98
|
email:
|
191
99
|
- aws-dr-rubygems@amazon.com
|
192
|
-
executables:
|
193
|
-
- aws_sqs_active_job
|
100
|
+
executables: []
|
194
101
|
extensions: []
|
195
102
|
extra_rdoc_files: []
|
196
103
|
files:
|
104
|
+
- CHANGELOG.md
|
105
|
+
- LICENSE.txt
|
197
106
|
- VERSION
|
198
|
-
- app/controllers/action_mailbox/ingresses/ses/inbound_emails_controller.rb
|
199
|
-
- bin/aws_sqs_active_job
|
200
|
-
- config/routes.rb
|
201
|
-
- lib/action_dispatch/session/dynamodb_store.rb
|
202
|
-
- lib/active_job/queue_adapters/sqs_adapter.rb
|
203
|
-
- lib/active_job/queue_adapters/sqs_adapter/params.rb
|
204
|
-
- lib/active_job/queue_adapters/sqs_async_adapter.rb
|
205
107
|
- lib/aws-sdk-rails.rb
|
206
|
-
- lib/aws/rails/action_mailbox/engine.rb
|
207
108
|
- lib/aws/rails/action_mailbox/rspec.rb
|
208
|
-
- lib/aws/rails/
|
209
|
-
- lib/aws/rails/action_mailbox/rspec/subscription_confirmation.rb
|
210
|
-
- lib/aws/rails/action_mailbox/s3_client.rb
|
211
|
-
- lib/aws/rails/action_mailbox/sns_message_verifier.rb
|
212
|
-
- lib/aws/rails/action_mailbox/sns_notification.rb
|
213
|
-
- lib/aws/rails/middleware/ebs_sqs_active_job_middleware.rb
|
109
|
+
- lib/aws/rails/middleware/elastic_beanstalk_sqsd.rb
|
214
110
|
- lib/aws/rails/notifications.rb
|
215
111
|
- lib/aws/rails/railtie.rb
|
216
|
-
- lib/aws/rails/ses_mailer.rb
|
217
|
-
- lib/aws/rails/sesv2_mailer.rb
|
218
|
-
- lib/aws/rails/sqs_active_job.rb
|
219
|
-
- lib/aws/rails/sqs_active_job/configuration.rb
|
220
|
-
- lib/aws/rails/sqs_active_job/deduplication.rb
|
221
|
-
- lib/aws/rails/sqs_active_job/executor.rb
|
222
|
-
- lib/aws/rails/sqs_active_job/job_runner.rb
|
223
|
-
- lib/aws/rails/sqs_active_job/lambda_handler.rb
|
224
|
-
- lib/aws/rails/sqs_active_job/poller.rb
|
225
|
-
- lib/generators/aws_record/base.rb
|
226
|
-
- lib/generators/aws_record/generated_attribute.rb
|
227
|
-
- lib/generators/aws_record/model/USAGE
|
228
|
-
- lib/generators/aws_record/model/model_generator.rb
|
229
|
-
- lib/generators/aws_record/model/templates/model.erb
|
230
|
-
- lib/generators/aws_record/model/templates/table_config.erb
|
231
|
-
- lib/generators/aws_record/secondary_index.rb
|
232
|
-
- lib/generators/dynamo_db/session_store_migration/USAGE
|
233
|
-
- lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb
|
234
|
-
- lib/generators/dynamo_db/session_store_migration/templates/dynamo_db_session_store.yml
|
235
|
-
- lib/generators/dynamo_db/session_store_migration/templates/session_store_migration.erb
|
236
|
-
- lib/tasks/aws_record/migrate.rake
|
237
|
-
- lib/tasks/dynamo_db/session_store.rake
|
238
112
|
homepage: https://github.com/aws/aws-sdk-rails
|
239
113
|
licenses:
|
240
114
|
- Apache-2.0
|
@@ -254,8 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
128
|
- !ruby/object:Gem::Version
|
255
129
|
version: '0'
|
256
130
|
requirements: []
|
257
|
-
rubygems_version: 3.5.
|
131
|
+
rubygems_version: 3.5.11
|
258
132
|
signing_key:
|
259
133
|
specification_version: 4
|
260
|
-
summary: AWS SDK for Ruby on Rails
|
134
|
+
summary: AWS SDK for Ruby on Rails Railtie
|
261
135
|
test_files: []
|
@@ -1,79 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aws/rails/action_mailbox/sns_notification'
|
4
|
-
|
5
|
-
module ActionMailbox
|
6
|
-
module Ingresses
|
7
|
-
module Ses
|
8
|
-
# Ingests inbound emails from Amazon SES/SNS and confirms subscriptions.
|
9
|
-
#
|
10
|
-
# Subscription requests must provide the following parameters in a JSON body:
|
11
|
-
# - +Message+: Notification content
|
12
|
-
# - +MessagId+: Notification unique identifier
|
13
|
-
# - +Timestamp+: iso8601 timestamp
|
14
|
-
# - +TopicArn+: Topic identifier
|
15
|
-
# - +Type+: Type of event ("Subscription")
|
16
|
-
#
|
17
|
-
# Inbound email events must provide the following parameters in a JSON body:
|
18
|
-
# - +Message+: Notification content
|
19
|
-
# - +MessagId+: Notification unique identifier
|
20
|
-
# - +Timestamp+: iso8601 timestamp
|
21
|
-
# - +SubscribeURL+: Topic identifier
|
22
|
-
# - +TopicArn+: Topic identifier
|
23
|
-
# - +Type+: Type of event ("SubscriptionConfirmation")
|
24
|
-
#
|
25
|
-
# All requests are authenticated by validating the provided AWS signature.
|
26
|
-
#
|
27
|
-
# Returns:
|
28
|
-
#
|
29
|
-
# - <tt>204 No Content</tt> if a request is successfully processed
|
30
|
-
# - <tt>401 Unauthorized</tt> if a request does not contain a valid signature
|
31
|
-
# - <tt>404 Not Found</tt> if the Amazon ingress has not been configured
|
32
|
-
# - <tt>422 Unprocessable Entity</tt> if a request provides invalid parameters
|
33
|
-
class InboundEmailsController < ActionMailbox::BaseController
|
34
|
-
before_action :verify_authenticity, :validate_topic, :confirm_subscription
|
35
|
-
|
36
|
-
def create
|
37
|
-
head :bad_request unless notification.message_content.present?
|
38
|
-
|
39
|
-
ActionMailbox::InboundEmail.create_and_extract_message_id!(notification.message_content)
|
40
|
-
head :no_content
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def verify_authenticity
|
46
|
-
head :bad_request unless notification.present?
|
47
|
-
head :unauthorized unless notification.verified?
|
48
|
-
end
|
49
|
-
|
50
|
-
def confirm_subscription
|
51
|
-
return unless notification.type == 'SubscriptionConfirmation'
|
52
|
-
return head :ok if notification.subscription_confirmed?
|
53
|
-
|
54
|
-
Rails.logger.error('SNS subscription confirmation request rejected.')
|
55
|
-
head :unprocessable_entity
|
56
|
-
end
|
57
|
-
|
58
|
-
def validate_topic
|
59
|
-
return if valid_topic == notification.topic
|
60
|
-
|
61
|
-
Rails.logger.warn("Ignoring unknown topic: #{topic}")
|
62
|
-
head :unauthorized
|
63
|
-
end
|
64
|
-
|
65
|
-
def notification
|
66
|
-
@notification ||= Aws::Rails::ActionMailbox::SnsNotification.new(request.raw_post)
|
67
|
-
end
|
68
|
-
|
69
|
-
def topic
|
70
|
-
@topic ||= notification.topic
|
71
|
-
end
|
72
|
-
|
73
|
-
def valid_topic
|
74
|
-
::Rails.configuration.action_mailbox.ses.subscribed_topic
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
data/bin/aws_sqs_active_job
DELETED
data/config/routes.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aws-sessionstore-dynamodb'
|
4
|
-
require 'action_dispatch/middleware/session/abstract_store'
|
5
|
-
|
6
|
-
module ActionDispatch
|
7
|
-
module Session
|
8
|
-
# Uses the Dynamo DB Session Store implementation to create a class that
|
9
|
-
# extends ActionDispatch::Session. Rails will create a :dynamodb_store
|
10
|
-
# configuration for session_store from this class name.
|
11
|
-
#
|
12
|
-
# This class will use the Rails secret_key_base unless otherwise provided.
|
13
|
-
#
|
14
|
-
# Configuration can also be provided in YAML files from Rails config, either
|
15
|
-
# in "config/session_store.yml" or "config/session_store/#\\{Rails.env}.yml".
|
16
|
-
# Configuration files that are environment-specific will take precedence.
|
17
|
-
#
|
18
|
-
# @see https://docs.aws.amazon.com/sdk-for-ruby/aws-sessionstore-dynamodb/api/Aws/SessionStore/DynamoDB/Configuration.html
|
19
|
-
class DynamodbStore < Aws::SessionStore::DynamoDB::RackMiddleware
|
20
|
-
include StaleSessionCheck
|
21
|
-
include SessionObject
|
22
|
-
|
23
|
-
def initialize(app, options = {})
|
24
|
-
options[:config_file] ||= config_file if File.exist?(config_file)
|
25
|
-
options[:secret_key] ||= Rails.application.secret_key_base
|
26
|
-
super
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def config_file
|
32
|
-
file = Rails.root.join("config/dynamo_db_session_store/#{Rails.env}.yml")
|
33
|
-
file = Rails.root.join('config/dynamo_db_session_store.yml') unless File.exist?(file)
|
34
|
-
file
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveJob
|
4
|
-
module QueueAdapters
|
5
|
-
class SqsAdapter
|
6
|
-
# == build request parameter of Aws::SQS::Client
|
7
|
-
class Params
|
8
|
-
class << self
|
9
|
-
def assured_delay_seconds(timestamp)
|
10
|
-
delay = (timestamp - Time.now.to_f).floor
|
11
|
-
delay = 0 if delay.negative?
|
12
|
-
raise ArgumentError, 'Unable to queue a job with a delay great than 15 minutes' if delay > 15.minutes
|
13
|
-
|
14
|
-
delay
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def initialize(job, body)
|
19
|
-
@job = job
|
20
|
-
@body = body || job.serialize
|
21
|
-
end
|
22
|
-
|
23
|
-
def queue_url
|
24
|
-
@queue_url ||= Aws::Rails::SqsActiveJob.config.queue_url_for(@job.queue_name)
|
25
|
-
end
|
26
|
-
|
27
|
-
def entry
|
28
|
-
if Aws::Rails::SqsActiveJob.fifo?(queue_url)
|
29
|
-
default_entry.merge(options_for_fifo)
|
30
|
-
else
|
31
|
-
default_entry
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def default_entry
|
38
|
-
{
|
39
|
-
message_body: Aws::Json.dump(@body),
|
40
|
-
message_attributes: message_attributes
|
41
|
-
}
|
42
|
-
end
|
43
|
-
|
44
|
-
def message_attributes
|
45
|
-
{
|
46
|
-
'aws_sqs_active_job_class' => {
|
47
|
-
string_value: @job.class.to_s,
|
48
|
-
data_type: 'String'
|
49
|
-
},
|
50
|
-
'aws_sqs_active_job_version' => {
|
51
|
-
string_value: Aws::Rails::VERSION,
|
52
|
-
data_type: 'String'
|
53
|
-
}
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
def options_for_fifo
|
58
|
-
options = {}
|
59
|
-
options[:message_deduplication_id] =
|
60
|
-
Digest::SHA256.hexdigest(Aws::Json.dump(deduplication_body))
|
61
|
-
|
62
|
-
message_group_id = @job.message_group_id if @job.respond_to?(:message_group_id)
|
63
|
-
message_group_id ||= Aws::Rails::SqsActiveJob.config.message_group_id
|
64
|
-
|
65
|
-
options[:message_group_id] = message_group_id
|
66
|
-
options
|
67
|
-
end
|
68
|
-
|
69
|
-
def deduplication_body
|
70
|
-
ex_dedup_keys = @job.excluded_deduplication_keys if @job.respond_to?(:excluded_deduplication_keys)
|
71
|
-
ex_dedup_keys ||= Aws::Rails::SqsActiveJob.config.excluded_deduplication_keys
|
72
|
-
|
73
|
-
@body.except(*ex_dedup_keys)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aws-sdk-sqs'
|
4
|
-
|
5
|
-
module ActiveJob
|
6
|
-
module QueueAdapters
|
7
|
-
# Set in rails config via config.active_job.queue_adapter = :sqs to use the SQS adapter
|
8
|
-
class SqsAdapter
|
9
|
-
def enqueue_after_transaction_commit?
|
10
|
-
true
|
11
|
-
end
|
12
|
-
|
13
|
-
def enqueue(job)
|
14
|
-
_enqueue(job)
|
15
|
-
end
|
16
|
-
|
17
|
-
def enqueue_at(job, timestamp)
|
18
|
-
delay = Params.assured_delay_seconds(timestamp)
|
19
|
-
_enqueue(job, nil, delay_seconds: delay)
|
20
|
-
end
|
21
|
-
|
22
|
-
def enqueue_all(jobs)
|
23
|
-
enqueued_count = 0
|
24
|
-
jobs.group_by(&:queue_name).each do |queue_name, same_queue_jobs|
|
25
|
-
queue_url = Aws::Rails::SqsActiveJob.config.queue_url_for(queue_name)
|
26
|
-
base_send_message_opts = { queue_url: queue_url }
|
27
|
-
|
28
|
-
same_queue_jobs.each_slice(10) do |chunk|
|
29
|
-
entries = chunk.map do |job|
|
30
|
-
entry = Params.new(job, nil).entry
|
31
|
-
entry[:id] = job.job_id
|
32
|
-
entry[:delay_seconds] = Params.assured_delay_seconds(job.scheduled_at) if job.scheduled_at
|
33
|
-
entry
|
34
|
-
end
|
35
|
-
|
36
|
-
send_message_opts = base_send_message_opts.deep_dup
|
37
|
-
send_message_opts[:entries] = entries
|
38
|
-
|
39
|
-
send_message_batch_result = Aws::Rails::SqsActiveJob.config.client.send_message_batch(send_message_opts)
|
40
|
-
enqueued_count += send_message_batch_result.successful.count
|
41
|
-
end
|
42
|
-
end
|
43
|
-
enqueued_count
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def _enqueue(job, body = nil, send_message_opts = {})
|
49
|
-
body ||= job.serialize
|
50
|
-
params = Params.new(job, body)
|
51
|
-
send_message_opts = send_message_opts.merge(params.entry)
|
52
|
-
send_message_opts[:queue_url] = params.queue_url
|
53
|
-
|
54
|
-
Aws::Rails::SqsActiveJob.config.client.send_message(send_message_opts)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aws-sdk-sqs'
|
4
|
-
require 'concurrent'
|
5
|
-
|
6
|
-
module ActiveJob
|
7
|
-
module QueueAdapters
|
8
|
-
# == Async adapter for Amazon SQS ActiveJob
|
9
|
-
#
|
10
|
-
# This adapter queues jobs asynchronously (ie non-blocking). Error handler can be configured
|
11
|
-
# with +Aws::Rails::SqsActiveJob.config.async_queue_error_handler+.
|
12
|
-
#
|
13
|
-
# To use this adapter, set up as:
|
14
|
-
#
|
15
|
-
# config.active_job.queue_adapter = :sqs_async
|
16
|
-
class SqsAsyncAdapter < SqsAdapter
|
17
|
-
private
|
18
|
-
|
19
|
-
def _enqueue(job, body = nil, send_message_opts = {})
|
20
|
-
# FIFO jobs must be queued in order, so do not queue async
|
21
|
-
queue_url = Aws::Rails::SqsActiveJob.config.queue_url_for(job.queue_name)
|
22
|
-
if Aws::Rails::SqsActiveJob.fifo?(queue_url)
|
23
|
-
super
|
24
|
-
else
|
25
|
-
# Serialize is called here because the job’s locale needs to be
|
26
|
-
# determined in this thread and not in some other thread.
|
27
|
-
body = job.serialize
|
28
|
-
Concurrent::Promises
|
29
|
-
.future { super }
|
30
|
-
.rescue do |e|
|
31
|
-
Rails.logger.error "Failed to queue job #{job}. Reason: #{e}"
|
32
|
-
error_handler = Aws::Rails::SqsActiveJob.config.async_queue_error_handler
|
33
|
-
error_handler&.call(e, job, send_message_opts)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
if defined?(ActionMailbox::Engine)
|
4
|
-
module Aws
|
5
|
-
module Rails
|
6
|
-
module ActionMailbox
|
7
|
-
# @api private
|
8
|
-
class Engine < ::Rails::Engine
|
9
|
-
config.action_mailbox.ses = ActiveSupport::OrderedOptions.new
|
10
|
-
config.action_mailbox.ses.s3_client_options ||= {}
|
11
|
-
|
12
|
-
initializer 'aws-sdk-rails.mount_engine' do |app|
|
13
|
-
app.routes.append do
|
14
|
-
mount Engine => '/'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Aws
|
4
|
-
module Rails
|
5
|
-
module ActionMailbox
|
6
|
-
module RSpec
|
7
|
-
# @api private
|
8
|
-
class Email
|
9
|
-
def initialize(authentic: true, topic: 'topic:arn:default', mail: default_mail, message_params: {})
|
10
|
-
@authentic = authentic
|
11
|
-
@topic = topic
|
12
|
-
@mail = mail
|
13
|
-
@message_params = message_params
|
14
|
-
end
|
15
|
-
|
16
|
-
def headers
|
17
|
-
{ 'content-type' => 'application/json' }
|
18
|
-
end
|
19
|
-
|
20
|
-
def url
|
21
|
-
'/rails/action_mailbox/ses/inbound_emails'
|
22
|
-
end
|
23
|
-
|
24
|
-
def params
|
25
|
-
{
|
26
|
-
'Type' => 'Notification',
|
27
|
-
'TopicArn' => @topic,
|
28
|
-
'Message' => message_json
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
def message_json
|
33
|
-
{
|
34
|
-
'notificationType' => 'Received',
|
35
|
-
'content' => @mail.encoded
|
36
|
-
}.merge(@message_params).to_json
|
37
|
-
end
|
38
|
-
|
39
|
-
def authentic?
|
40
|
-
@authentic
|
41
|
-
end
|
42
|
-
|
43
|
-
def default_mail
|
44
|
-
Mail.new
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|