active_elastic_job 1.4.2 → 1.4.3

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
  SHA1:
3
- metadata.gz: 23ebae0278f2915ef56c50b3387a2d862c697a0a
4
- data.tar.gz: 60f652aab799782e51bfe1eaae1fcc7c12abb234
3
+ metadata.gz: e235c668ed6b4cc4d6b462061c0e63d8786f4a90
4
+ data.tar.gz: a54b85273c167cb0abeed10739fe82533a7251ef
5
5
  SHA512:
6
- metadata.gz: 6177ea2b5c0b2eaf15787a3421bb08696862a4b70e03f61702a1ddc0d3df059e1d89440b4cc70cfcb5c9b7d15304c68cbda832c386777710ca91a4aa7117fb5c
7
- data.tar.gz: 630e3c61425608800d84e402a2de004ef65ec8424ce19df24be19c942eac75425a1389ac5502110af9042b3c541c2c5ae516516018e18c592c58e586df480543
6
+ metadata.gz: ad76b1050b01e79f40116296cbc9f146a7d354551b61b1aa8b953546f45f733c9d349ed0ea0d4589e2abc327cb005356fbb9000ca2c822d361fb7dcc04fbd099
7
+ data.tar.gz: 59ffc700b728075af2e670cae7a07acf2dee007d43e4283dbfcd895ab6277874d7ea55a09dbf2182302141d75b8ec896e53c18b084e9e8b989e0b0e84291ac34
@@ -1,7 +1,10 @@
1
1
  module ActiveElasticJob
2
2
  class Railtie < Rails::Railtie
3
3
  initializer "active_elastic_job.insert_middleware" do |app|
4
- app.config.middleware.use "ActiveElasticJob::Rack::SqsMessageConsumer"
4
+ disabled = ENV['DISABLE_SQS_CONSUMER']
5
+ if disabled == 'false' || disabled.nil?
6
+ app.config.middleware.use "ActiveElasticJob::Rack::SqsMessageConsumer"
7
+ end
5
8
  end
6
9
  end
7
10
  end
@@ -2,7 +2,7 @@ module ActiveElasticJob
2
2
  module VERSION
3
3
  MAJOR = 1
4
4
  MINOR = 4
5
- TINY = 2
5
+ TINY = 3
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -19,6 +19,12 @@ module ActiveJob
19
19
  MAX_MESSAGE_SIZE = (256 * 1024)
20
20
  MAX_DELAY_IN_MINUTES = 15
21
21
 
22
+ if Gem::Version.new(Aws::VERSION) >= Gem::Version.new('2.2.19')
23
+ AWS_CLIENT_VERIFIES_MD5_DIGESTS = true
24
+ else
25
+ AWS_CLIENT_VERIFIES_MD5_DIGESTS = false
26
+ end
27
+
22
28
  extend ActiveElasticJob::MD5MessageDigestCalculation
23
29
 
24
30
  class Error < RuntimeError; end;
@@ -28,10 +34,10 @@ module ActiveJob
28
34
  class SerializedJobTooBig < Error
29
35
  def initialize(serialized_job)
30
36
  msg = <<-MSG
31
- The job contains #{serialized_job.bytesize} bytes in its serialzed form,
32
- which exceeds the allowed maximum of #{MAX_MESSAGE_SIZE} bytes imposed by Amazon SQS.
37
+ super(<<-MSG)
38
+ The job contains #{serialized_job.bytesize} bytes in its serialzed form,
39
+ which exceeds the allowed maximum of #{MAX_MESSAGE_SIZE} bytes imposed by Amazon SQS.
33
40
  MSG
34
- super msg
35
41
  end
36
42
  end
37
43
 
@@ -51,13 +57,14 @@ which exceeds the allowed maximum of #{MAX_MESSAGE_SIZE} bytes imposed by Amazon
51
57
  # end
52
58
  class NonExistentQueue < Error
53
59
  def initialize(queue_name)
54
- msg = "The job is bound to queue at #{queue_name}. " <<
55
- "Unfortunately a queue with this name does not exist in this " <<
56
- "region. Either create an Amazon SQS queue named #{queue_name} - " <<
57
- "you can do this in AWS console, make sure to select region " <<
58
- "'#{ENV['AWS_REGION']}' - or you select another queue for your jobs."
59
60
 
60
- super msg
61
+ super(<<-MSG)
62
+ The job is bound to queue at #{queue_name}.
63
+ Unfortunately a queue with this name does not exist in this
64
+ region. Either create an Amazon SQS queue named #{queue_name} -
65
+ you can do this in AWS console, make sure to select region
66
+ '#{ENV['AWS_REGION']}' - or you select another queue for your jobs.
67
+ MSG
61
68
  end
62
69
  end
63
70
 
@@ -65,12 +72,13 @@ which exceeds the allowed maximum of #{MAX_MESSAGE_SIZE} bytes imposed by Amazon
65
72
  # of the response from Amazon SQS.
66
73
  class MD5MismatchError < Error
67
74
  def initialize(message_id, calculated, returned)
68
- msg = "MD5 '#{returned}' returned by Amazon SQS does not match the" <<
69
- " calculation on the original request which was '#{calculated}'. " <<
70
- "The message with Message ID #{message_id} sent to SQS might be " <<
71
- "corrupted."
72
75
 
73
- super msg
76
+ super(<<-MSG)
77
+ MD5 '#{returned}' returned by Amazon SQS does not match the
78
+ calculation on the original request which was '#{calculated}'.
79
+ The message with Message ID #{message_id} sent to SQS might be
80
+ corrupted.
81
+ MSG
74
82
  end
75
83
  end
76
84
 
@@ -84,11 +92,12 @@ which exceeds the allowed maximum of #{MAX_MESSAGE_SIZE} bytes imposed by Amazon
84
92
  check_job_size!(serialized_job)
85
93
  message = build_message(job.queue_name, serialized_job, timestamp)
86
94
  resp = aws_sqs_client.send_message(message)
87
- verify_md5_digests!(
88
- resp,
89
- message[:message_body],
90
- message[:message_attributes]
91
- )
95
+ unless aws_client_verifies_md5_digests?
96
+ verify_md5_digests!(
97
+ resp,
98
+ message[:message_body],
99
+ message[:message_attributes])
100
+ end
92
101
  rescue Aws::SQS::Errors::NonExistentQueue => e
93
102
  unless @queue_urls[job.queue_name.to_s].nil?
94
103
  @queue_urls[job.queue_name.to_s] = nil
@@ -101,6 +110,10 @@ which exceeds the allowed maximum of #{MAX_MESSAGE_SIZE} bytes imposed by Amazon
101
110
 
102
111
  private
103
112
 
113
+ def aws_client_verifies_md5_digests?
114
+ return AWS_CLIENT_VERIFIES_MD5_DIGESTS
115
+ end
116
+
104
117
  def build_message(queue_name, serialized_job, timestamp)
105
118
  {
106
119
  queue_url: queue_url(queue_name),
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_elastic_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tawan Sierek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-18 00:00:00.000000000 Z
11
+ date: 2016-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk