active_elastic_job 1.0.0 → 1.1.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9ced62a0162f40de919760ea5563c6bf6e6417e
|
4
|
+
data.tar.gz: 182d2fc41d98ee5fce356190e7ece9aa6d85e449
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f7f9614d11eac062792ff694ca57a2d598f9abd882d42cdfab6fdbd538c171783a14b7f9467de56745c29c6c8688440e08c48b7cd87e19e54ca34c7a8c7b204
|
7
|
+
data.tar.gz: 9871d65f4264d52d4f13d1858093ce2e7de4929f76925f22dfb014be2a5c33370e9c1259486a645ea86bed660f0707ca60b98ac483d9bb820eccc25b943d7ef6
|
@@ -13,13 +13,15 @@ module ActiveElasticJob
|
|
13
13
|
# environment, which verifies the digest, have to use the *same*
|
14
14
|
# +secrets.secret_key_base+ setting.
|
15
15
|
class SqsMessageConsumer
|
16
|
+
USER_AGENT_PREFIX = 'aws-sqsd'
|
17
|
+
|
16
18
|
def initialize(app) #:nodoc:
|
17
19
|
@app = app
|
18
20
|
end
|
19
21
|
|
20
22
|
def call(env) #:nodoc:
|
21
23
|
request = ActionDispatch::Request.new env
|
22
|
-
if request
|
24
|
+
if aws_sqsd?(request)
|
23
25
|
begin
|
24
26
|
verify(request)
|
25
27
|
job = JSON.load(request.body)
|
@@ -38,9 +40,21 @@ module ActiveElasticJob
|
|
38
40
|
|
39
41
|
def verify(request)
|
40
42
|
secret_key_base = Rails.application.secrets[:secret_key_base]
|
41
|
-
verifier
|
43
|
+
@verifier ||= ActiveElasticJob::MessageVerifier.new(secret_key_base)
|
42
44
|
digest = request.headers['HTTP_X_AWS_SQSD_ATTR_MESSAGE_DIGEST']
|
43
|
-
verifier.verify(request.body.string, digest)
|
45
|
+
@verifier.verify(request.body.string, digest)
|
46
|
+
end
|
47
|
+
|
48
|
+
def aws_sqsd?(request)
|
49
|
+
# we do not match against a Regexp
|
50
|
+
# in order to avoid performance penalties.
|
51
|
+
# Instead we make a simple string comparison.
|
52
|
+
# Benchmark runs showed an performance increase of
|
53
|
+
# up to 40%
|
54
|
+
current_user_agent = request.headers['User-Agent']
|
55
|
+
return (current_user_agent.present? &&
|
56
|
+
current_user_agent.size >= USER_AGENT_PREFIX.size &&
|
57
|
+
current_user_agent[0..(USER_AGENT_PREFIX.size - 1)] == USER_AGENT_PREFIX)
|
44
58
|
end
|
45
59
|
end
|
46
60
|
end
|
@@ -29,7 +29,7 @@ module ActiveJob
|
|
29
29
|
See http://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html
|
30
30
|
for further details!
|
31
31
|
MSG
|
32
|
-
raise RangeError,
|
32
|
+
raise RangeError, msg if delay > 15.minutes
|
33
33
|
end
|
34
34
|
|
35
35
|
aws_sqs_client.send_message(
|
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
|
+
version: 1.1.0
|
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-01-
|
11
|
+
date: 2016-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|