sidekiq-dynamic-queues 0.5.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e26d8799284d819ada2b3525662f535823158eda
4
+ data.tar.gz: 4c8675472a38536c7e6c94ef7ed784efe7a9319e
5
+ SHA512:
6
+ metadata.gz: afee84bcaa102dfa32571f8581058e2255cda9567a747fcfb151c82200814039aeab9611440af2ccf64d7c0218a97c4c8f077d6a636acf988b969e01e3f39c1d
7
+ data.tar.gz: c5c9f306121ab9560c64d8e540448efe6fdcfb0bce1a26468169cfd57b07b5261553f6cd54d1e01cd96deae3870aa746c0a892fc676b7de8c9e0bc903c9a194e
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ 0.6.0 (03/04/2014)
2
+ ------------------
3
+
4
+ Merge pull request #3 from adstage-david/master <c1f77c5> [Matt Conway]
5
+ Use Sidekiq::Queue.all instead of deprecated registered_queues. <e01c6b0> [David Haslem]
6
+ updated for latest sidekiq: slim -> erb, fix running of jobs in tests <eb7f982> [Matt Conway]
7
+
1
8
  0.5.6 (06/13/2013)
2
9
  ------------------
3
10
 
@@ -10,12 +10,12 @@ module Sidekiq
10
10
  def json_encode(data)
11
11
  Sidekiq.dump_json(data)
12
12
  end
13
-
13
+
14
14
  def json_decode(data)
15
15
  return nil unless data
16
16
  Sidekiq.load_json(data)
17
17
  end
18
-
18
+
19
19
  def get_dynamic_queue(key, fallback=['*'])
20
20
  data = Sidekiq.redis {|r| r.hget(DYNAMIC_QUEUE_KEY, key) }
21
21
  queue_names = json_decode(data)
@@ -24,7 +24,7 @@ module Sidekiq
24
24
  data = Sidekiq.redis {|r| r.hget(DYNAMIC_QUEUE_KEY, FALLBACK_KEY) }
25
25
  queue_names = json_decode(data)
26
26
  end
27
-
27
+
28
28
  if queue_names.nil? || queue_names.size == 0
29
29
  queue_names = fallback
30
30
  end
@@ -39,7 +39,7 @@ module Sidekiq
39
39
  Sidekiq.redis {|r| r.hset(DYNAMIC_QUEUE_KEY, key, json_encode(values)) }
40
40
  end
41
41
  end
42
-
42
+
43
43
  def set_dynamic_queues(dynamic_queues)
44
44
  Sidekiq.redis do |r|
45
45
  r.multi do
@@ -58,7 +58,7 @@ module Sidekiq
58
58
  result[FALLBACK_KEY] ||= ['*']
59
59
  return result
60
60
  end
61
-
61
+
62
62
  # Returns a list of queues to use when searching for a job.
63
63
  #
64
64
  # A splat ("*") means you want every queue (in alpha order) - this
@@ -76,7 +76,7 @@ module Sidekiq
76
76
  def expand_queues(queues)
77
77
  queue_names = queues.dup
78
78
 
79
- real_queues = Sidekiq::Client.registered_queues
79
+ real_queues = Sidekiq::Queue.all.map(&:name)
80
80
  matched_queues = []
81
81
 
82
82
  while q = queue_names.shift
@@ -113,6 +113,6 @@ module Sidekiq
113
113
  end
114
114
 
115
115
  end
116
-
116
+
117
117
  end
118
118
  end
@@ -44,7 +44,7 @@ module Sidekiq
44
44
  end
45
45
  end
46
46
 
47
- slim :dynamicqueue
47
+ erb :dynamicqueue
48
48
  end
49
49
 
50
50
  app.post "/dynamicqueue" do
@@ -0,0 +1,77 @@
1
+ <div class="row header">
2
+ <div class="col-sm-7">
3
+ <h3>Dynamic Queues</h3>
4
+ </div>
5
+ </div>
6
+
7
+ <p>
8
+ The list below shows the dynamic queues currently defined. When you start
9
+ a worker with a dynamic queue key (@key_name), that key is looked up from
10
+ the list below to determine the actual queues the worker should pull from.
11
+ Wildcards (*) and negation (leading !) can be used to select the queues the
12
+ worker should process. There is always a fallback key - @default, which
13
+ workers will use if the key for that worker is empty. If both the key and
14
+ the fallback are empty, the worker defaults to processing '*'
15
+ </p>
16
+
17
+ <form action="<%= root_path %>dynamicqueue" method="POST">
18
+
19
+ <table class="queues table table-hover table-bordered table-striped table-white">
20
+ <thead>
21
+ <th>Name</th>
22
+ <th>Value</th>
23
+ <th>Expanded</th>
24
+ <th></th>
25
+ </thead>
26
+ <% @queues.each_with_index do |data, i| %>
27
+ <tr class="line">
28
+ <td>
29
+ <input type="text" id="input-<%= i %>-name" name="queues[][name]" value="<%= data['name'] %>" />
30
+ </td>
31
+ <td>
32
+ <input type="text" id="input-<%= i %>-value" name="queues[][value]" value="<%= data['value'] %>" />
33
+ </td>
34
+ <td class="expanded">
35
+ <%= data['expanded'] %>
36
+ </td>
37
+ <td>
38
+ <a href="#remove" class="remove">Remove</a>
39
+ </td>
40
+ </tr>
41
+ <% end %>
42
+ </table>
43
+ <a href="#add" class="add">Add</a>
44
+
45
+ <input type="submit" value="Save" />
46
+ </form>
47
+
48
+ <script type="text/javascript">
49
+ function markDirty()
50
+ {
51
+ $("input[type=submit]").css({border:"3px orange solid"});
52
+ }
53
+
54
+ jQuery(function($) {
55
+
56
+ $("input").live("keypress", markDirty);
57
+
58
+ $("a.add").live("click", function(e) {
59
+ e.preventDefault();
60
+ var $table = $("table.queues");
61
+ var $newRow = $table.find("tr.line:first").clone();
62
+ $newRow.find("input[type=text]").attr("value", "");
63
+ $newRow.find("td.expanded").html("")
64
+ $newRow.appendTo($table);
65
+ markDirty();
66
+ });
67
+
68
+ $("a.remove").live("click", function(e) {
69
+ e.preventDefault();
70
+ var $link = $(this);
71
+ $link.parents("tr").remove();
72
+ markDirty();
73
+ });
74
+
75
+
76
+ });
77
+ </script>
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module DynamicQueues
3
- VERSION = "0.5.6"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.add_development_dependency('sinatra')
27
27
  s.add_development_dependency('slim')
28
28
  s.add_development_dependency('rack-test', '~> 0.5.4')
29
+ s.add_development_dependency('tilt', '~> 1.4')
29
30
 
30
31
  end
31
32
 
@@ -242,7 +242,7 @@ describe "Dynamic Queues" do
242
242
 
243
243
  it "finds work on dynamic queue that doesn't exist till after sidekiq is waiting for jobs" do
244
244
  watch_queues(*%w[default])
245
- manager = run_queues("*", :async => true)
245
+ launcher = run_queues("*", :async => true)
246
246
  # give run_queues a chance to block on only the default queue given above
247
247
  sleep 0.1
248
248
 
@@ -252,8 +252,7 @@ describe "Dynamic Queues" do
252
252
  # that for it to re-evaluate the dynamic queues
253
253
  sleep 2
254
254
  timeout(5) do
255
- manager.async.stop(:shutdown => true, :timeout => 1)
256
- manager.wait(:shutdown)
255
+ launcher.stop
257
256
  end
258
257
  SomeJob.result.should eq [1]
259
258
  end
@@ -94,10 +94,10 @@ describe "Dynamic Queues pages" do
94
94
  set_dynamic_queue("key_two", ["bar", "baz"])
95
95
  get "/dynamicqueue"
96
96
 
97
- last_response.body.should match /<input id="input-0-name" name="queues\[\]\[name\]" type="text" value="key_one"/
98
- last_response.body.should match /<input id="input-0-value" name="queues\[\]\[value\]" type="text" value="foo"/
99
- last_response.body.should match /<input id="input-1-name" name="queues\[\]\[name\]" type="text" value="key_two"/
100
- last_response.body.should match /<input id="input-1-value" name="queues\[\]\[value\]" type="text" value="bar, baz"/
97
+ last_response.body.should include '<input type="text" id="input-0-name" name="queues[][name]" value="key_one" />'
98
+ last_response.body.should include '<input type="text" id="input-0-value" name="queues[][value]" value="foo" />'
99
+ last_response.body.should include '<input type="text" id="input-1-name" name="queues[][name]" value="key_two" />'
100
+ last_response.body.should include '<input type="text" id="input-1-value" name="queues[][value]" value="bar, baz" />'
101
101
  end
102
102
 
103
103
  it "should delete queues on empty queue submit" do
@@ -2,9 +2,7 @@ require 'rspec'
2
2
  require 'sidekiq-dynamic-queues'
3
3
  require 'celluloid'
4
4
  require 'sidekiq'
5
- require 'sidekiq/fetch'
6
- require 'sidekiq/cli'
7
- require 'sidekiq/manager'
5
+ require 'sidekiq/launcher'
8
6
 
9
7
  Sidekiq.logger.level = Logger::DEBUG
10
8
  Celluloid.logger = Sidekiq.logger = nil
@@ -73,23 +71,20 @@ end
73
71
  def run_queues(*queues)
74
72
  options = queues.last.is_a?(Hash) ? queues.pop : {}
75
73
  options = {:async => false, :timeout => 5}.merge(options)
76
- Sidekiq::Fetcher.instance_eval { @done = false }
77
- manager = Sidekiq::Manager.new({:queues=>queues, :concurrency=>1, :timeout=>1})
78
74
 
79
- manager.start
80
-
75
+ sidekiq_opts = {:queues=>queues, :concurrency=>1, :timeout=>1}
76
+ Sidekiq::Fetcher.reset
77
+ launcher = Sidekiq::Launcher.new(sidekiq_opts)
78
+ launcher.run
79
+
81
80
  unless options[:async]
82
81
  # give up control so jobs can start running before we call stop
83
82
  # Manager.when_done only gets called for jobs that succeed, not jobs that raise
84
83
  sleep 0.1
85
- manager.async.stop(:shutdown => true, :timeout => 1)
86
-
87
- timeout(options[:timeout]) do
88
- manager.wait(:shutdown)
89
- end
84
+ launcher.stop
90
85
  end
91
86
 
92
- manager
87
+ launcher
93
88
  end
94
89
 
95
90
  class SomeJob
metadata CHANGED
@@ -1,119 +1,115 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-dynamic-queues
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.5.6
4
+ version: 0.6.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Matt Conway
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-13 00:00:00.000000000 Z
11
+ date: 2014-03-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: sidekiq
16
- version_requirements: !ruby/object:Gem::Requirement
15
+ requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
17
  - - "~>"
19
18
  - !ruby/object:Gem::Version
20
19
  version: '2.9'
21
- none: false
22
- requirement: !ruby/object:Gem::Requirement
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.9'
27
- none: false
28
- prerelease: false
29
- type: :runtime
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
- version_requirements: !ruby/object:Gem::Requirement
29
+ requirement: !ruby/object:Gem::Requirement
33
30
  requirements:
34
31
  - - ">="
35
32
  - !ruby/object:Gem::Version
36
- version: !binary |-
37
- MA==
38
- none: false
39
- requirement: !ruby/object:Gem::Requirement
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - ">="
42
39
  - !ruby/object:Gem::Version
43
- version: !binary |-
44
- MA==
45
- none: false
46
- prerelease: false
47
- type: :development
40
+ version: '0'
48
41
  - !ruby/object:Gem::Dependency
49
42
  name: rspec
50
- version_requirements: !ruby/object:Gem::Requirement
43
+ requirement: !ruby/object:Gem::Requirement
51
44
  requirements:
52
45
  - - "~>"
53
46
  - !ruby/object:Gem::Version
54
47
  version: '2.5'
55
- none: false
56
- requirement: !ruby/object:Gem::Requirement
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
52
  - - "~>"
59
53
  - !ruby/object:Gem::Version
60
54
  version: '2.5'
61
- none: false
62
- prerelease: false
63
- type: :development
64
55
  - !ruby/object:Gem::Dependency
65
56
  name: sinatra
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
66
64
  version_requirements: !ruby/object:Gem::Requirement
67
65
  requirements:
68
66
  - - ">="
69
67
  - !ruby/object:Gem::Version
70
- version: !binary |-
71
- MA==
72
- none: false
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: slim
73
71
  requirement: !ruby/object:Gem::Requirement
74
72
  requirements:
75
73
  - - ">="
76
74
  - !ruby/object:Gem::Version
77
- version: !binary |-
78
- MA==
79
- none: false
80
- prerelease: false
75
+ version: '0'
81
76
  type: :development
82
- - !ruby/object:Gem::Dependency
83
- name: slim
77
+ prerelease: false
84
78
  version_requirements: !ruby/object:Gem::Requirement
85
79
  requirements:
86
80
  - - ">="
87
81
  - !ruby/object:Gem::Version
88
- version: !binary |-
89
- MA==
90
- none: false
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
93
- - - ">="
87
+ - - "~>"
94
88
  - !ruby/object:Gem::Version
95
- version: !binary |-
96
- MA==
97
- none: false
98
- prerelease: false
89
+ version: 0.5.4
99
90
  type: :development
100
- - !ruby/object:Gem::Dependency
101
- name: rack-test
91
+ prerelease: false
102
92
  version_requirements: !ruby/object:Gem::Requirement
103
93
  requirements:
104
94
  - - "~>"
105
95
  - !ruby/object:Gem::Version
106
96
  version: 0.5.4
107
- none: false
97
+ - !ruby/object:Gem::Dependency
98
+ name: tilt
108
99
  requirement: !ruby/object:Gem::Requirement
109
100
  requirements:
110
101
  - - "~>"
111
102
  - !ruby/object:Gem::Version
112
- version: 0.5.4
113
- none: false
114
- prerelease: false
103
+ version: '1.4'
115
104
  type: :development
116
- description: A sidekiq plugin for specifying the queues a worker pulls from with wildcards, negations, or dynamic look up from redis
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.4'
111
+ description: A sidekiq plugin for specifying the queues a worker pulls from with wildcards,
112
+ negations, or dynamic look up from redis
117
113
  email:
118
114
  - matt@conwaysplace.com
119
115
  executables: []
@@ -135,7 +131,7 @@ files:
135
131
  - lib/sidekiq/dynamic_queues/attributes.rb
136
132
  - lib/sidekiq/dynamic_queues/fetch.rb
137
133
  - lib/sidekiq/dynamic_queues/server.rb
138
- - lib/sidekiq/dynamic_queues/server/views/dynamicqueue.slim
134
+ - lib/sidekiq/dynamic_queues/server/views/dynamicqueue.erb
139
135
  - lib/sidekiq/dynamic_queues/version.rb
140
136
  - sidekiq-dynamic-queues.gemspec
141
137
  - spec/queues_spec.rb
@@ -144,7 +140,8 @@ files:
144
140
  - spec/spec_helper.rb
145
141
  homepage: ''
146
142
  licenses: []
147
- post_install_message:
143
+ metadata: {}
144
+ post_install_message:
148
145
  rdoc_options: []
149
146
  require_paths:
150
147
  - lib
@@ -152,25 +149,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
149
  requirements:
153
150
  - - ">="
154
151
  - !ruby/object:Gem::Version
155
- version: !binary |-
156
- MA==
157
- none: false
152
+ version: '0'
158
153
  required_rubygems_version: !ruby/object:Gem::Requirement
159
154
  requirements:
160
155
  - - ">="
161
156
  - !ruby/object:Gem::Version
162
- version: !binary |-
163
- MA==
164
- none: false
157
+ version: '0'
165
158
  requirements: []
166
159
  rubyforge_project: sidekiq-dynamic-queues
167
- rubygems_version: 1.8.24
168
- signing_key:
169
- specification_version: 3
170
- summary: A sidekiq plugin for specifying the queues a worker pulls from with wildcards, negations, or dynamic look up from redis
160
+ rubygems_version: 2.2.2
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: A sidekiq plugin for specifying the queues a worker pulls from with wildcards,
164
+ negations, or dynamic look up from redis
171
165
  test_files:
172
166
  - spec/queues_spec.rb
173
167
  - spec/redis-test.conf
174
168
  - spec/server_spec.rb
175
169
  - spec/spec_helper.rb
176
- has_rdoc:
@@ -1,63 +0,0 @@
1
- h3 Dynamic Queues
2
-
3
- p class="intro"
4
- | The list below shows the dynamic queues currently defined. When you start
5
- a worker with a dynamic queue key (@key_name), that key is looked up from
6
- the list below to determine the actual queues the worker should pull from.
7
- Wildcards (*) and negation (leading !) can be used to select the queues the
8
- worker should process. There is always a fallback key - @default, which
9
- workers will use if the key for that worker is empty. If both the key and
10
- the fallback are empty, the worker defaults to processing '*'
11
-
12
- form action="#{root_path}dynamicqueue" method="POST"
13
-
14
- table class="queues table table-hover table-bordered table-striped table-white"
15
- thead
16
- th Name
17
- th Value
18
- th Expanded
19
- th
20
- - @queues.each_with_index do |data, i|
21
- tr class="line"
22
- td
23
- input type="text" id="input-#{{i}}-name" name="queues[][name]" value="#{{data['name']}}"
24
- td
25
- input type="text" id="input-#{{i}}-value" name="queues[][value]" value="#{{data['value']}}"
26
- td class="expanded"
27
- = data['expanded']
28
- td
29
- a href="#remove" class="remove" Remove
30
-
31
- a href="#add" class="add" Add
32
-
33
- input type="submit" value="Save"
34
-
35
- javascript:
36
- function markDirty()
37
- {
38
- $("input[type=submit]").css({border:"3px orange solid"});
39
- }
40
-
41
- jQuery(function($) {
42
-
43
- $("input").live("keypress", markDirty);
44
-
45
- $("a.add").live("click", function(e) {
46
- e.preventDefault();
47
- var $table = $("table.queues");
48
- var $newRow = $table.find("tr.line:first").clone();
49
- $newRow.find("input[type=text]").attr("value", "");
50
- $newRow.find("td.expanded").html("")
51
- $newRow.appendTo($table);
52
- markDirty();
53
- });
54
-
55
- $("a.remove").live("click", function(e) {
56
- e.preventDefault();
57
- var $link = $(this);
58
- $link.parents("tr").remove();
59
- markDirty();
60
- });
61
-
62
-
63
- });