aws-sdk-rails 3.11.0 → 3.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6ff9a7f26db95b0ae83526c594bb985b991da455979daf7d2a6ea92be0a5187
4
- data.tar.gz: bbb91361034021720e0f43058777b530212d6c43d489f23999b636dd7e187edb
3
+ metadata.gz: 43528604142d01e2ddcddf37ae598a08c11744aa3a9ccc6757dbc7d1932d3546
4
+ data.tar.gz: 7977e087f6372fc8326193dad744f908cda1d2174fc6f817e9cfe48b286a5cfb
5
5
  SHA512:
6
- metadata.gz: a28a3bf351332f237ef4ce23bbcdb6115ac41468d14dd3d2e1eb76c7a395c33697c9f8c55412fdad3a2b4fc63cbf7dca350243bdf5651743a7ccadfb9adebb0a
7
- data.tar.gz: 80076e9047b439cdbd4fe8fe2da651b3cc9d23ed3346fb22c32724b9b3e00463dd77a52f99934bfe26c79ce6d9cc9a17d74fdf6683c9dc5b85e52c40a80f0d9d
6
+ metadata.gz: 2ceda136ba4f7077b6608787528f2ae97b9ceb3169d9c67f101105e7e512dc8000cdb3bf09e5f96b786544bdb427eb15cc0df6571ecc544f5b1603c51cc034b8
7
+ data.tar.gz: 1fdb53b5fdc4a752643deb9e360988983ad939cce6ada4a8ce3bc68122959c44c7ca6f98d55987172c4d559d9d010ec652b482576bf12b4e496193b183aa236e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.11.0
1
+ 3.13.0
@@ -20,13 +20,13 @@ module ActiveJob
20
20
  # FIFO jobs must be queued in order, so do not queue async
21
21
  queue_url = Aws::Rails::SqsActiveJob.config.queue_url_for(job.queue_name)
22
22
  if Aws::Rails::SqsActiveJob.fifo?(queue_url)
23
- super(job, body, send_message_opts)
23
+ super
24
24
  else
25
25
  # Serialize is called here because the job’s locale needs to be
26
26
  # determined in this thread and not in some other thread.
27
27
  body = job.serialize
28
28
  Concurrent::Promises
29
- .future { super(job, body, send_message_opts) }
29
+ .future { super }
30
30
  .rescue do |e|
31
31
  Rails.logger.error "Failed to queue job #{job}. Reason: #{e}"
32
32
  error_handler = Aws::Rails::SqsActiveJob.config.async_queue_error_handler
@@ -85,7 +85,15 @@ module Aws
85
85
  end
86
86
 
87
87
  def app_runs_in_docker_container?
88
- @app_runs_in_docker_container ||= `[ -f /proc/1/cgroup ] && cat /proc/1/cgroup` =~ /docker/
88
+ @app_runs_in_docker_container ||= in_docker_container_with_cgroup1? || in_docker_container_with_cgroup2?
89
+ end
90
+
91
+ def in_docker_container_with_cgroup1?
92
+ File.exist?('/proc/1/cgroup') && File.read('/proc/1/cgroup') =~ %r{/docker/}
93
+ end
94
+
95
+ def in_docker_container_with_cgroup2?
96
+ File.exist?('/proc/self/mountinfo') && File.read('/proc/self/mountinfo') =~ %r{/docker/containers/}
89
97
  end
90
98
 
91
99
  def default_gw_ips
@@ -9,43 +9,26 @@ module Aws
9
9
  class Executor
10
10
  DEFAULTS = {
11
11
  min_threads: 0,
12
- max_threads: Concurrent.processor_count,
12
+ max_threads: Integer(Concurrent.available_processor_count || Concurrent.processor_count),
13
13
  auto_terminate: true,
14
14
  idletime: 60, # 1 minute
15
- fallback_policy: :caller_runs # slow down the producer thread
16
- # TODO: Consider catching the exception and sleeping instead of using :caller_runs
15
+ fallback_policy: :abort # Concurrent::RejectedExecutionError must be handled
17
16
  }.freeze
18
17
 
19
18
  def initialize(options = {})
20
19
  @executor = Concurrent::ThreadPoolExecutor.new(DEFAULTS.merge(options))
21
20
  @retry_standard_errors = options[:retry_standard_errors]
22
21
  @logger = options[:logger] || ActiveSupport::Logger.new($stdout)
22
+ @task_complete = Concurrent::Event.new
23
23
  end
24
24
 
25
25
  def execute(message)
26
- @executor.post(message) do |message|
27
- begin
28
- job = JobRunner.new(message)
29
- @logger.info("Running job: #{job.id}[#{job.class_name}]")
30
- job.run
31
- message.delete
32
- rescue Aws::Json::ParseError => e
33
- @logger.error "Unable to parse message body: #{message.data.body}. Error: #{e}."
34
- rescue StandardError => e
35
- job_msg = job ? "#{job.id}[#{job.class_name}]" : 'unknown job'
36
- @logger.info "Error processing job #{job_msg}: #{e}"
37
- @logger.debug e.backtrace.join("\n")
38
-
39
- if @retry_standard_errors && !job.exception_executions?
40
- @logger.info(
41
- 'retry_standard_errors is enabled and job has not ' \
42
- "been retried by Rails. Leaving #{job_msg} in the queue."
43
- )
44
- else
45
- message.delete
46
- end
47
- end
48
- end
26
+ post_task(message)
27
+ rescue Concurrent::RejectedExecutionError
28
+ # no capacity, wait for a task to complete
29
+ @task_complete.reset
30
+ @task_complete.wait
31
+ retry
49
32
  end
50
33
 
51
34
  def shutdown(timeout = nil)
@@ -60,6 +43,34 @@ module Aws
60
43
  'passes.'
61
44
  end
62
45
  end
46
+
47
+ private
48
+
49
+ def post_task(message)
50
+ @executor.post(message) do |message|
51
+ job = JobRunner.new(message)
52
+ @logger.info("Running job: #{job.id}[#{job.class_name}]")
53
+ job.run
54
+ message.delete
55
+ rescue Aws::Json::ParseError => e
56
+ @logger.error "Unable to parse message body: #{message.data.body}. Error: #{e}."
57
+ rescue StandardError => e
58
+ job_msg = job ? "#{job.id}[#{job.class_name}]" : 'unknown job'
59
+ @logger.info "Error processing job #{job_msg}: #{e}"
60
+ @logger.debug e.backtrace.join("\n")
61
+
62
+ if @retry_standard_errors && !job.exception_executions?
63
+ @logger.info(
64
+ 'retry_standard_errors is enabled and job has not ' \
65
+ "been retried by Rails. Leaving #{job_msg} in the queue."
66
+ )
67
+ else
68
+ message.delete
69
+ end
70
+ ensure
71
+ @task_complete.set
72
+ end
73
+ end
63
74
  end
64
75
  end
65
76
  end
@@ -39,8 +39,8 @@ module Aws
39
39
  end
40
40
 
41
41
  def self.to_message_attributes(record)
42
- record['messageAttributes'].each_with_object({}) do |(key, value), acc|
43
- acc[key] = {
42
+ record['messageAttributes'].transform_values do |value|
43
+ {
44
44
  string_value: value['stringValue'],
45
45
  binary_value: value['binaryValue'],
46
46
  string_list_values: ['stringListValues'],
@@ -53,12 +53,10 @@ module AwsRecord
53
53
 
54
54
  def parse_attributes!
55
55
  self.attributes = (attributes || []).map do |attr|
56
- begin
57
- GeneratedAttribute.parse(attr)
58
- rescue ArgumentError => e
59
- @parse_errors << e
60
- next
61
- end
56
+ GeneratedAttribute.parse(attr)
57
+ rescue ArgumentError => e
58
+ @parse_errors << e
59
+ next
62
60
  end
63
61
  self.attributes = attributes.compact
64
62
 
@@ -167,28 +165,26 @@ module AwsRecord
167
165
 
168
166
  def parse_gsis!
169
167
  @gsis = (options['gsi'] || []).map do |raw_idx|
170
- begin
171
- idx = SecondaryIndex.parse(raw_idx)
168
+ idx = SecondaryIndex.parse(raw_idx)
169
+
170
+ attributes = self.attributes.select { |attr| attr.name == idx.hash_key }
171
+ if attributes.empty?
172
+ @parse_errors << ArgumentError.new("Could not find attribute #{idx.hash_key} for gsi #{idx.name} hkey")
173
+ next
174
+ end
172
175
 
173
- attributes = self.attributes.select { |attr| attr.name == idx.hash_key }
176
+ if idx.range_key
177
+ attributes = self.attributes.select { |attr| attr.name == idx.range_key }
174
178
  if attributes.empty?
175
- @parse_errors << ArgumentError.new("Could not find attribute #{idx.hash_key} for gsi #{idx.name} hkey")
179
+ @parse_errors << ArgumentError.new("Could not find attribute #{idx.range_key} for gsi #{idx.name} rkey")
176
180
  next
177
181
  end
178
-
179
- if idx.range_key
180
- attributes = self.attributes.select { |attr| attr.name == idx.range_key }
181
- if attributes.empty?
182
- @parse_errors << ArgumentError.new("Could not find attribute #{idx.range_key} for gsi #{idx.name} rkey")
183
- next
184
- end
185
- end
186
-
187
- idx
188
- rescue ArgumentError => e
189
- @parse_errors << e
190
- next
191
182
  end
183
+
184
+ idx
185
+ rescue ArgumentError => e
186
+ @parse_errors << e
187
+ next
192
188
  end
193
189
 
194
190
  @gsis = @gsis.compact
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.0
4
+ version: 3.13.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-03-01 00:00:00.000000000 Z
11
+ date: 2024-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-record
@@ -102,16 +102,16 @@ dependencies:
102
102
  name: concurrent-ruby
103
103
  requirement: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - "~>"
105
+ - - ">="
106
106
  - !ruby/object:Gem::Version
107
- version: '1'
107
+ version: 1.3.1
108
108
  type: :runtime
109
109
  prerelease: false
110
110
  version_requirements: !ruby/object:Gem::Requirement
111
111
  requirements:
112
- - - "~>"
112
+ - - ">="
113
113
  - !ruby/object:Gem::Version
114
- version: '1'
114
+ version: 1.3.1
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: railties
117
117
  requirement: !ruby/object:Gem::Requirement
@@ -191,14 +191,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
- version: '2.3'
194
+ version: '2.5'
195
195
  required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  requirements:
197
197
  - - ">="
198
198
  - !ruby/object:Gem::Version
199
199
  version: '0'
200
200
  requirements: []
201
- rubygems_version: 3.4.1
201
+ rubygems_version: 3.5.5
202
202
  signing_key:
203
203
  specification_version: 4
204
204
  summary: AWS SDK for Ruby on Rails Plugin