active_elastic_job 2.0.1 → 3.0.0.alpha

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
- SHA1:
3
- metadata.gz: 98e8fc2ff4cbd08606241083c7e3ceccd8108108
4
- data.tar.gz: f55ec5c86259ab8c9439afab8692e0b546a71114
2
+ SHA256:
3
+ metadata.gz: 76f95bc2f952a3d57402a5c41428e02f4662725e2c784d547c75ce8081edbf31
4
+ data.tar.gz: 495df5d131344373516e77507461861a72007387adb6dde0a5c8a0274e535bf5
5
5
  SHA512:
6
- metadata.gz: 9896471a6018a88efe19c55508c748456aabb3d84656adf710915323a0c19e86b776df934874cfdeee5a2f3ec4e2a68360b7c6c7a171d6ad64a12ef42b6baee9
7
- data.tar.gz: a14cb288a8c2392b6fafe0506c9355bf51d009097e8362de28bd761951c621b71716faf043b6a6c405d0813363410e9399e80b1dc3db9652c28f4efa32627bf6
6
+ metadata.gz: fb613b8ad89d5b86437bd831b28247e54c3adc54127bdb6264f5ccc0fda7d4d26ffaec5fa5e312e09d042c580e088bb74753601f3b4aa1c68d19505ac3d7f31f
7
+ data.tar.gz: 6149c28f1cce197d6722e83ca2927173133aca4b2d2afbb4803ff7b2191c3d314841c4e57c57cb3d7b1a6ea43e889e7029b09ccf5f125379d4d3f26e3340aeda
@@ -8,20 +8,31 @@ Gem::Specification.new do |spec|
8
8
  spec.platform = Gem::Platform::RUBY
9
9
  spec.name = 'active_elastic_job'
10
10
  spec.version = ActiveElasticJob.version
11
- spec.authors = ['Tawan Sierek']
12
- spec.email = ['tawan@sierek.com']
11
+ spec.authors = ['Tawan Sierek', 'Joey Paris']
12
+ spec.email = ['tawan@sierek.com', 'mail@joeyparis.me']
13
13
  spec.summary = 'Active Elastic Job is a simple to use Active Job backend for Rails applications deployed on the Amazon Elastic Beanstalk platform.'
14
14
  spec.description = 'Run background jobs / tasks of Rails applications deployed in Amazon Elastic Beanstalk environments. Active Elastic Job is an Active Job backend which is easy to setup. No need for customised container commands or other workarounds.'
15
15
  spec.license = 'MIT'
16
- spec.homepage = 'https://github.com/tawan/active-elastic-job'
16
+ spec.homepage = 'https://github.com/active-elastic-job/active-elastic-job'
17
17
 
18
18
  spec.files = Dir.glob('lib/**/*') + [ 'active-elastic-job.gemspec' ]
19
19
  spec.executables = []
20
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.required_ruby_version = '>= 1.9.3'
23
+ spec.required_ruby_version = '>= 2.5'
24
24
 
25
- spec.add_dependency 'aws-sdk', '~> 2'
26
- spec.add_dependency 'rails', '>= 4.2'
25
+ spec.add_dependency 'aws-sdk-sqs', '~> 1'
26
+ spec.add_dependency 'rails', '>= 5.0', '<7'
27
+
28
+ spec.add_development_dependency 'benchmark-ips', '~> 2.8'
29
+ spec.add_development_dependency 'bundler', '~> 2.2'
30
+ spec.add_development_dependency 'byebug', '~> 11.1'
31
+ spec.add_development_dependency 'climate_control', '~> 0.2'
32
+ spec.add_development_dependency 'dotenv', '~> 2.7'
33
+ spec.add_development_dependency 'fuubar', '~> 2.5'
34
+ spec.add_development_dependency 'rdoc', '~> 6.3'
35
+ spec.add_development_dependency 'rspec', '~> 3.4'
36
+ spec.add_development_dependency 'sqlite3', '~> 1.4'
37
+ spec.add_development_dependency 'amazing_print', '~> 1.2'
27
38
  end
@@ -1,4 +1,4 @@
1
- require 'aws-sdk-core'
1
+ require 'aws-sdk-sqs'
2
2
  require 'active_elastic_job/version'
3
3
  require 'active_elastic_job/md5_message_digest_calculation'
4
4
  require 'active_job/queue_adapters/active_elastic_job_adapter'
@@ -25,7 +25,7 @@ module ActiveElasticJob
25
25
  { 'Content-Type'.freeze => 'text/plain'.freeze },
26
26
  [ 'Request forbidden!'.freeze ]
27
27
  ]
28
- DOCKER_HOST_IP = '172.17.0.1'.freeze
28
+ DOCKER_HOST_IP = /172.17.0.\d+/.freeze
29
29
 
30
30
  def initialize(app) #:nodoc:
31
31
  @app = app
@@ -118,11 +118,11 @@ module ActiveElasticJob
118
118
  end
119
119
 
120
120
  def sent_from_docker_host?(request)
121
- app_runs_in_docker_container? && request.remote_ip == DOCKER_HOST_IP
121
+ app_runs_in_docker_container? && request.remote_ip =~ DOCKER_HOST_IP
122
122
  end
123
123
 
124
124
  def app_runs_in_docker_container?
125
- @app_in_docker_container ||= `[ -f /proc/1/cgroup ] && cat /proc/1/cgroup` =~ /docker/
125
+ @app_in_docker_container ||= `[ -f /proc/1/cgroup ] && cat /proc/1/cgroup` =~ /(ecs|docker)/
126
126
  end
127
127
  end
128
128
  end
@@ -1,8 +1,10 @@
1
1
  module ActiveElasticJob
2
2
  class Railtie < Rails::Railtie
3
3
  config.active_elastic_job = ActiveSupport::OrderedOptions.new
4
- config.active_elastic_job.process_jobs = ENV['PROCESS_ACTIVE_ELASTIC_JOBS'] == 'true'
4
+ process_active_elastic_jobs = ENV['PROCESS_ACTIVE_ELASTIC_JOBS']
5
+ config.active_elastic_job.process_jobs = !process_active_elastic_jobs.nil? && process_active_elastic_jobs.downcase == 'true'
5
6
  config.active_elastic_job.aws_credentials = lambda { Aws::InstanceProfileCredentials.new }
7
+ config.active_elastic_job.aws_region = ENV['AWS_REGION']
6
8
  config.active_elastic_job.periodic_tasks_route = '/periodic_tasks'.freeze
7
9
 
8
10
  initializer "active_elastic_job.insert_middleware" do |app|
@@ -11,6 +13,7 @@ module ActiveElasticJob
11
13
  end
12
14
 
13
15
  if app.config.active_elastic_job.process_jobs == true
16
+ app.config.active_elastic_job.aws_credentials ||= lambda { Aws::InstanceProfileCredentials.new }
14
17
  if app.config.force_ssl
15
18
  app.config.middleware.insert_before(ActionDispatch::SSL,ActiveElasticJob::Rack::SqsMessageConsumer)
16
19
  else
@@ -1,9 +1,9 @@
1
1
  module ActiveElasticJob
2
2
  module VERSION
3
- MAJOR = 2
3
+ MAJOR = 3
4
4
  MINOR = 0
5
- TINY = 1
6
- PRE = nil
5
+ TINY = 0
6
+ PRE = 'alpha'
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
9
9
 
@@ -28,7 +28,7 @@ module ActiveJob
28
28
  class SerializedJobTooBig < Error
29
29
  def initialize(serialized_job)
30
30
  super(<<-MSG)
31
- The job contains #{serialized_job.bytesize} bytes in its serialzed form,
31
+ The job contains #{serialized_job.bytesize} bytes in its serialized form,
32
32
  which exceeds the allowed maximum of #{MAX_MESSAGE_SIZE} bytes imposed by Amazon SQS.
33
33
  MSG
34
34
  end
@@ -76,6 +76,18 @@ module ActiveJob
76
76
  end
77
77
  end
78
78
 
79
+ # Raised when the delay is longer than the MAX_DELAY_IN_MINUTES
80
+ class DelayTooLong < RangeError
81
+ def initialize()
82
+ super(<<-MSG)
83
+ Jobs cannot be scheduled more than #{MAX_DELAY_IN_MINUTES} minutes
84
+ into the future.
85
+ See http://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html
86
+ for further details!
87
+ MSG
88
+ end
89
+ end
90
+
79
91
  def enqueue(job) #:nodoc:
80
92
  self.class.enqueue job
81
93
  end
@@ -100,6 +112,7 @@ module ActiveJob
100
112
  message[:message_body],
101
113
  message[:message_attributes])
102
114
  end
115
+ job.provider_job_id = resp.message_id
103
116
  rescue Aws::SQS::Errors::NonExistentQueue => e
104
117
  unless @queue_urls[job.queue_name.to_s].nil?
105
118
  @queue_urls[job.queue_name.to_s] = nil
@@ -113,7 +126,7 @@ module ActiveJob
113
126
  private
114
127
 
115
128
  def aws_client_verifies_md5_digests?
116
- Gem::Version.new(Aws::VERSION) >= Gem::Version.new('2.2.19'.freeze)
129
+ Gem::Version.new(Aws::CORE_GEM_VERSION) >= Gem::Version.new('2.2.19'.freeze)
117
130
  end
118
131
 
119
132
  def build_message(queue_name, serialized_job, timestamp)
@@ -147,12 +160,7 @@ module ActiveJob
147
160
  def calculate_delay(timestamp)
148
161
  delay = (timestamp - Time.current.to_f).to_i + 1
149
162
  if delay > MAX_DELAY_IN_MINUTES.minutes
150
- msg = "Jobs cannot be scheduled more than " <<
151
- "#{MAX_DELAY_IN_MINUTES} minutes into the future. " <<
152
- "See http://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html" <<
153
- " for further details!"
154
-
155
- raise RangeError, msg
163
+ raise DelayTooLong.new
156
164
  end
157
165
  delay = 0 if delay < 0
158
166
  delay
@@ -165,7 +173,13 @@ module ActiveJob
165
173
  end
166
174
 
167
175
  def aws_sqs_client
168
- @aws_sqs_client ||= Aws::SQS::Client.new(credentials: aws_sqs_client_credentials )
176
+ options = {
177
+ credentials: aws_sqs_client_credentials,
178
+ region: aws_region
179
+ }
180
+ endpoint = Rails.application.config.active_elastic_job.endpoint
181
+ options[:endpoint] = endpoint if endpoint.present?
182
+ @aws_sqs_client ||= Aws::SQS::Client.new(options)
169
183
  end
170
184
 
171
185
  def aws_sqs_client_credentials
metadata CHANGED
@@ -1,48 +1,196 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_elastic_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 3.0.0.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tawan Sierek
8
+ - Joey Paris
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2017-02-05 00:00:00.000000000 Z
12
+ date: 2021-01-27 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
- name: aws-sdk
15
+ name: aws-sdk-sqs
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
18
  - - "~>"
18
19
  - !ruby/object:Gem::Version
19
- version: '2'
20
+ version: '1'
20
21
  type: :runtime
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
25
  - - "~>"
25
26
  - !ruby/object:Gem::Version
26
- version: '2'
27
+ version: '1'
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: rails
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
32
  - - ">="
32
33
  - !ruby/object:Gem::Version
33
- version: '4.2'
34
+ version: '5.0'
35
+ - - "<"
36
+ - !ruby/object:Gem::Version
37
+ version: '7'
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
37
41
  requirements:
38
42
  - - ">="
39
43
  - !ruby/object:Gem::Version
40
- version: '4.2'
44
+ version: '5.0'
45
+ - - "<"
46
+ - !ruby/object:Gem::Version
47
+ version: '7'
48
+ - !ruby/object:Gem::Dependency
49
+ name: benchmark-ips
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.8'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.8'
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.2'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.2'
76
+ - !ruby/object:Gem::Dependency
77
+ name: byebug
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '11.1'
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '11.1'
90
+ - !ruby/object:Gem::Dependency
91
+ name: climate_control
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.2'
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.2'
104
+ - !ruby/object:Gem::Dependency
105
+ name: dotenv
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.7'
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.7'
118
+ - !ruby/object:Gem::Dependency
119
+ name: fuubar
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.5'
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.5'
132
+ - !ruby/object:Gem::Dependency
133
+ name: rdoc
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '6.3'
139
+ type: :development
140
+ prerelease: false
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '6.3'
146
+ - !ruby/object:Gem::Dependency
147
+ name: rspec
148
+ requirement: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.4'
153
+ type: :development
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '3.4'
160
+ - !ruby/object:Gem::Dependency
161
+ name: sqlite3
162
+ requirement: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.4'
167
+ type: :development
168
+ prerelease: false
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '1.4'
174
+ - !ruby/object:Gem::Dependency
175
+ name: amazing_print
176
+ requirement: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '1.2'
181
+ type: :development
182
+ prerelease: false
183
+ version_requirements: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '1.2'
41
188
  description: Run background jobs / tasks of Rails applications deployed in Amazon
42
189
  Elastic Beanstalk environments. Active Elastic Job is an Active Job backend which
43
190
  is easy to setup. No need for customised container commands or other workarounds.
44
191
  email:
45
192
  - tawan@sierek.com
193
+ - mail@joeyparis.me
46
194
  executables: []
47
195
  extensions: []
48
196
  extra_rdoc_files: []
@@ -55,7 +203,7 @@ files:
55
203
  - lib/active_elastic_job/railtie.rb
56
204
  - lib/active_elastic_job/version.rb
57
205
  - lib/active_job/queue_adapters/active_elastic_job_adapter.rb
58
- homepage: https://github.com/tawan/active-elastic-job
206
+ homepage: https://github.com/active-elastic-job/active-elastic-job
59
207
  licenses:
60
208
  - MIT
61
209
  metadata: {}
@@ -67,15 +215,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
67
215
  requirements:
68
216
  - - ">="
69
217
  - !ruby/object:Gem::Version
70
- version: 1.9.3
218
+ version: '2.5'
71
219
  required_rubygems_version: !ruby/object:Gem::Requirement
72
220
  requirements:
73
- - - ">="
221
+ - - ">"
74
222
  - !ruby/object:Gem::Version
75
- version: '0'
223
+ version: 1.3.1
76
224
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.4.5.1
225
+ rubygems_version: 3.1.2
79
226
  signing_key:
80
227
  specification_version: 4
81
228
  summary: Active Elastic Job is a simple to use Active Job backend for Rails applications