tantot 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tantot/config.rb +2 -1
- data/lib/tantot/performer/sidekiq.rb +4 -2
- data/lib/tantot/version.rb +1 -1
- data/spec/extensions/chewy_spec.rb +0 -14
- data/spec/sidekiq_spec.rb +52 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8034dc47aeea3eeca0970dae7bec53a8e99de285
|
4
|
+
data.tar.gz: 26a50c7cd327edfdebc0706edf1cb6a861b76411
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d439b688a52f03174b5f18020e226522518069da36e9b96b41953aec8266f8f81c533ae6299f5b4c496ffc9830512c7c62bb86b26075fe110627b135bfcd7119
|
7
|
+
data.tar.gz: a1a4189f19fdc39e248c40e3b4d60dc734dd4340082caeeb72289281df287aca115e84460714fce002ce49dea3195ff7c312caa5439693e5efb2663614a74bda
|
data/lib/tantot/config.rb
CHANGED
@@ -2,13 +2,14 @@ module Tantot
|
|
2
2
|
class Config
|
3
3
|
include Singleton
|
4
4
|
|
5
|
-
attr_accessor :performer, :format, :use_after_commit_callbacks, :sweep_on_push
|
5
|
+
attr_accessor :performer, :format, :use_after_commit_callbacks, :sweep_on_push, :sidekiq_queue
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
@performer = :inline
|
9
9
|
@format = :compact
|
10
10
|
@use_after_commit_callbacks = true
|
11
11
|
@sweep_on_push = false
|
12
|
+
@sidekiq_queue = :default
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -11,8 +11,10 @@ module Tantot
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def run(context, changes)
|
14
|
-
context
|
15
|
-
Tantot::Performer::Sidekiq::Worker
|
14
|
+
queue = context[:options][:queue] || Tantot.config.sidekiq_queue
|
15
|
+
::Sidekiq::Client.push('class' => Tantot::Performer::Sidekiq::Worker,
|
16
|
+
'args' => Tantot.collector.marshal(context, changes),
|
17
|
+
'queue' => queue)
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
data/lib/tantot/version.rb
CHANGED
@@ -135,20 +135,6 @@ if defined?(::Chewy)
|
|
135
135
|
City.create!
|
136
136
|
end
|
137
137
|
end
|
138
|
-
|
139
|
-
if defined?(::Sidekiq)
|
140
|
-
context "using Sidekiq" do
|
141
|
-
require 'sidekiq/testing'
|
142
|
-
|
143
|
-
around do |example|
|
144
|
-
Sidekiq::Worker.clear_all
|
145
|
-
Tantot.config.performer = :sidekiq
|
146
|
-
example.run
|
147
|
-
Tantot.config.performer = :inline
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
138
|
end
|
153
139
|
|
154
140
|
end
|
data/spec/sidekiq_spec.rb
CHANGED
@@ -31,6 +31,7 @@ if defined?(::Sidekiq)
|
|
31
31
|
City.create name: 'foo'
|
32
32
|
end
|
33
33
|
expect(Tantot::Performer::Sidekiq::Worker.jobs.size).to eq(1)
|
34
|
+
expect(Tantot::Performer::Sidekiq::Worker.jobs.first["queue"]).to eq('default')
|
34
35
|
expect(Tantot::Performer::Sidekiq::Worker.jobs.first["args"]).to eq([{
|
35
36
|
"model" => "City",
|
36
37
|
"attributes" => ["name"],
|
@@ -63,6 +64,7 @@ if defined?(::Sidekiq)
|
|
63
64
|
city.save
|
64
65
|
end
|
65
66
|
expect(Tantot::Performer::Sidekiq::Worker.jobs.size).to eq(1)
|
67
|
+
expect(Tantot::Performer::Sidekiq::Worker.jobs.first["queue"]).to eq('default')
|
66
68
|
expect(Tantot::Performer::Sidekiq::Worker.jobs.first["args"]).to eq([{
|
67
69
|
"model" => "City",
|
68
70
|
"attributes" => ["name"],
|
@@ -74,6 +76,55 @@ if defined?(::Sidekiq)
|
|
74
76
|
end
|
75
77
|
end
|
76
78
|
|
79
|
+
describe Tantot::Performer::Sidekiq do
|
80
|
+
context "with a specific queue on a watcher" do
|
81
|
+
before do
|
82
|
+
class SidekiqWatcher
|
83
|
+
include Tantot::Watcher
|
84
|
+
|
85
|
+
watcher_options queue: :foo
|
86
|
+
|
87
|
+
def perform(changes)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
Sidekiq::Worker.clear_all
|
92
|
+
stub_model(:city) do
|
93
|
+
watch SidekiqWatcher, :name
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should set the sidekiq queue accordingly" do
|
98
|
+
Tantot.collector.run do
|
99
|
+
City.create name: 'foo'
|
100
|
+
end
|
101
|
+
expect(Tantot::Performer::Sidekiq::Worker.jobs.size).to eq(1)
|
102
|
+
expect(Tantot::Performer::Sidekiq::Worker.jobs.first["queue"]).to eq('foo')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "with a specific queue on a block" do
|
107
|
+
before do
|
108
|
+
Sidekiq::Worker.clear_all
|
109
|
+
stub_model(:city) do
|
110
|
+
watch(:name, queue: :foo) {|changes| }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should set the sidekiq queue accordingly" do
|
115
|
+
class SidekiqWatcher
|
116
|
+
watcher_options queue: :foo
|
117
|
+
end
|
118
|
+
|
119
|
+
Tantot.collector.run do
|
120
|
+
City.create name: 'foo'
|
121
|
+
end
|
122
|
+
expect(Tantot::Performer::Sidekiq::Worker.jobs.size).to eq(1)
|
123
|
+
expect(Tantot::Performer::Sidekiq::Worker.jobs.first["queue"]).to eq('foo')
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
77
128
|
describe Tantot::Collector::Block do
|
78
129
|
let(:value) { {changed: false} }
|
79
130
|
let(:changes) { {obj: nil} }
|
@@ -93,6 +144,7 @@ if defined?(::Sidekiq)
|
|
93
144
|
end
|
94
145
|
expect(Tantot::Performer::Sidekiq::Worker.jobs.size).to eq(1)
|
95
146
|
block_id = Tantot.registry.watch_config.keys.last
|
147
|
+
expect(Tantot::Performer::Sidekiq::Worker.jobs.first["queue"]).to eq('default')
|
96
148
|
expect(Tantot::Performer::Sidekiq::Worker.jobs.first["args"]).to eq([{
|
97
149
|
"model" => "City",
|
98
150
|
"attributes" => ["name"],
|