sidekiq-sqs 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Guardfile +1 -1
- data/lib/sidekiq-sqs/fetcher.rb +1 -13
- data/lib/sidekiq-sqs/version.rb +1 -1
- data/sidekiq-sqs.gemspec +2 -0
- data/spec/sidekiq-sqs/client_spec.rb +45 -0
- data/spec/sidekiq-sqs/processor_spec.rb +25 -0
- data/spec/sidekiq-sqs/worker_spec.rb +25 -0
- data/spec/spec_helper.rb +4 -0
- metadata +40 -4
- data/spec/sidekiq-sqs/middleware/compression_spec.rb +0 -26
data/Guardfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# A sample Guardfile
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
|
4
|
-
guard 'rspec', :version => 2 do
|
4
|
+
guard 'rspec', :version => 2, :cli => "--format nested" do
|
5
5
|
watch(%r{^spec/.+_spec\.rb$})
|
6
6
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
7
|
watch('spec/spec_helper.rb') { "spec" }
|
data/lib/sidekiq-sqs/fetcher.rb
CHANGED
@@ -16,16 +16,6 @@ module Sidekiq
|
|
16
16
|
@unique_queues = @queues.uniq
|
17
17
|
end
|
18
18
|
|
19
|
-
# TODO Since there's only one fetcher per manager, we run into the issue
|
20
|
-
# where it takes longer to fetch a single job that it does to process,
|
21
|
-
# on average, so that we have waiting workers even if we have jobs in the
|
22
|
-
# queue because, with the HTTP round trip, fetching single messages is too
|
23
|
-
# slow.
|
24
|
-
#
|
25
|
-
# We could fetch 10 at a time, but then we have to worry about stuffing them
|
26
|
-
# into a "cache", and pushing them back into SQS if we die or exit. We could,
|
27
|
-
# I guess, just let the "hold" on them expire, and then they would be picked
|
28
|
-
# up again. I wonder if that would be 'good enough'
|
29
19
|
def fetch
|
30
20
|
watchdog('Fetcher#fetch died') do
|
31
21
|
return if Sidekiq::Fetcher.done?
|
@@ -39,9 +29,7 @@ module Sidekiq
|
|
39
29
|
queues.pop # Last entry is TIMEOUT
|
40
30
|
|
41
31
|
msg = queues.inject(nil) do |message, queue|
|
42
|
-
|
43
|
-
|
44
|
-
Sidekiq.sqs.queues.named(queue).receive_message
|
32
|
+
message || Sidekiq.sqs.queues.named(queue).receive_message
|
45
33
|
end
|
46
34
|
|
47
35
|
if msg
|
data/lib/sidekiq-sqs/version.rb
CHANGED
data/sidekiq-sqs.gemspec
CHANGED
@@ -22,6 +22,8 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.add_dependency 'aws-sdk', '~> 1.6.6'
|
23
23
|
|
24
24
|
gem.add_development_dependency 'rspec'
|
25
|
+
gem.add_development_dependency 'rb-fsevent', '~> 0.9.1'
|
25
26
|
gem.add_development_dependency 'guard'
|
26
27
|
gem.add_development_dependency 'guard-rspec'
|
28
|
+
gem.add_development_dependency 'mocha', '~> 0.12.3'
|
27
29
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class StubClient
|
4
|
+
def self.push(*args)
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.push_bulk(*args)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.process_single(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
include Sidekiq::Sqs::Client
|
14
|
+
end
|
15
|
+
|
16
|
+
describe Sidekiq::Sqs::Client do
|
17
|
+
subject { StubClient }
|
18
|
+
|
19
|
+
describe ".process_single_with_sqs" do
|
20
|
+
it "base64 encodes and compresses the payload" do
|
21
|
+
subject.expects(:process_single_without_sqs).with(:worker_class, :item).returns([:item, "payload"])
|
22
|
+
|
23
|
+
subject.process_single_with_sqs(:worker_class, :item).should eq([:item, "eJwrSKzMyU9MAQAL3QLr\n"])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe ".queue_or_create" do
|
28
|
+
let(:queue) { 'queue' }
|
29
|
+
let(:queues) { stub }
|
30
|
+
before { Sidekiq.stubs(sqs: stub(queues: queues)) }
|
31
|
+
|
32
|
+
it "returns the queue if it exists" do
|
33
|
+
queues.expects(:named).with(queue).returns(:queue)
|
34
|
+
|
35
|
+
subject.queue_or_create(queue).should eq(:queue)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "creates the queue if it doesn't exists" do
|
39
|
+
queues.expects(:named).with(queue).raises(AWS::SQS::Errors::NonExistentQueue.new)
|
40
|
+
queues.expects(:create).with(queue).returns(:queue)
|
41
|
+
|
42
|
+
subject.queue_or_create(queue).should eq(:queue)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class StubProcessor
|
4
|
+
def process(msg, queue)
|
5
|
+
end
|
6
|
+
|
7
|
+
include Sidekiq::Sqs::Processor
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Sidekiq::Sqs::Processor do
|
11
|
+
subject { StubProcessor.new }
|
12
|
+
|
13
|
+
describe "#process_with_sqs" do
|
14
|
+
let(:body) { "eJxLTEo2NDIGAAbsAb0=\n" }
|
15
|
+
let(:message) { stub(body: body) }
|
16
|
+
let(:queue) { stub }
|
17
|
+
|
18
|
+
it "expands the message, delegates to the base class and deletes the message" do
|
19
|
+
subject.expects(:process_without_sqs).with('abc123', queue).returns(:processed)
|
20
|
+
message.expects(:delete)
|
21
|
+
|
22
|
+
subject.process(message, queue).should eq(:processed)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class StubWorker
|
4
|
+
include Sidekiq::Sqs::Worker
|
5
|
+
end
|
6
|
+
|
7
|
+
describe Sidekiq::Sqs::Worker do
|
8
|
+
subject { StubWorker.new }
|
9
|
+
|
10
|
+
describe "#perform_async_bulk" do
|
11
|
+
it "formats the arguments" do
|
12
|
+
subject.expects(:client_push_bulk).with('class' => subject, 'args' => :args)
|
13
|
+
|
14
|
+
subject.perform_async_bulk(:args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#client_push_bulk" do
|
19
|
+
it "delegates to Client" do
|
20
|
+
Sidekiq::Client.expects(:push_bulk).with(:args)
|
21
|
+
|
22
|
+
subject.client_push_bulk(:args)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-sqs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rb-fsevent
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.9.1
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.9.1
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
name: guard
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,6 +123,22 @@ dependencies:
|
|
107
123
|
- - ! '>='
|
108
124
|
- !ruby/object:Gem::Version
|
109
125
|
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: mocha
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 0.12.3
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 0.12.3
|
110
142
|
description: SQS backed job store for Sidekiq. Redis is still used for stats/job worker
|
111
143
|
tracking
|
112
144
|
email:
|
@@ -130,7 +162,9 @@ files:
|
|
130
162
|
- lib/sidekiq-sqs/worker.rb
|
131
163
|
- lib/top_level.rb
|
132
164
|
- sidekiq-sqs.gemspec
|
133
|
-
- spec/sidekiq-sqs/
|
165
|
+
- spec/sidekiq-sqs/client_spec.rb
|
166
|
+
- spec/sidekiq-sqs/processor_spec.rb
|
167
|
+
- spec/sidekiq-sqs/worker_spec.rb
|
134
168
|
- spec/spec_helper.rb
|
135
169
|
homepage: http://github.com/jmoses/sidekiq-sqs
|
136
170
|
licenses: []
|
@@ -157,5 +191,7 @@ signing_key:
|
|
157
191
|
specification_version: 3
|
158
192
|
summary: SQS backed job store for Sidekiq
|
159
193
|
test_files:
|
160
|
-
- spec/sidekiq-sqs/
|
194
|
+
- spec/sidekiq-sqs/client_spec.rb
|
195
|
+
- spec/sidekiq-sqs/processor_spec.rb
|
196
|
+
- spec/sidekiq-sqs/worker_spec.rb
|
161
197
|
- spec/spec_helper.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Sidekiq::Sqs::Middleware::Compression do
|
4
|
-
context "Server" do
|
5
|
-
subject { Sidekiq::Sqs::Middleware::Compression::Server.new }
|
6
|
-
let(:message) { stub(body: "eJzLTS0uTkxPBQALwQLm\n") }
|
7
|
-
|
8
|
-
it "decompresses the message" do
|
9
|
-
subject.call(nil, message, nil)
|
10
|
-
|
11
|
-
message.body.should eq('message')
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# context "Client" do
|
16
|
-
# subject { Sidekiq::Sqs::Middleware::Compression::Client.new }
|
17
|
-
# let(:message) { 'message' }
|
18
|
-
#
|
19
|
-
# it "compresses the message and yields" do
|
20
|
-
# expect {|b| subject.call(nil, message, :queue, &b) }.to yield_control
|
21
|
-
#
|
22
|
-
# message.should eq(Base64.encode64(Zlib::Deflate.deflate('message')))
|
23
|
-
# end
|
24
|
-
# end
|
25
|
-
end
|
26
|
-
|