sidekiq-grouping 1.0.6 → 1.0.7

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: df70f6272c6c489626dd612e2c736e5d1fbe2cad
4
- data.tar.gz: 5a30ac65ae3e7a0b42d2b9633281990b8be84a86
3
+ metadata.gz: abbfc33064b0d62493579060635fbdd8449ab118
4
+ data.tar.gz: 62f8fb16d37730fb087c78e2ea9ecc9a45d9a42a
5
5
  SHA512:
6
- metadata.gz: a60255525e80b8911bfb72aec1067d67af644449554fdd04e1d448464bdbdb3fc6186b31ea665d4fa17fb8a836b0d3962d45384edf90d7f2c6ca462f6c4fe84a
7
- data.tar.gz: 9ca2e704dcffffcacd45178343e7e824e45073a422f1bdcd70cb2f651d7e3bbb870aa3729cd386bfc6ffb2e31b7f95b6e843831833c7a59eb8468e472a386a48
6
+ metadata.gz: f82b31c45dedc4dd5f9c4b73ff4269c78f1ac7e3c564b4064a09575db15eff8dbf938003061f27836a0528945a62b820b6859f230e4b38882a824f63a005ea39
7
+ data.tar.gz: c30f8345b87e05185f23e26febc766a3b0c857e0a905131dc9586935f8678108ebd3a569e5c5f8168ef225288a2c4834c2d86ca6a21ebd6b387f3eb8ed93ec86
data/README.md CHANGED
@@ -11,6 +11,7 @@ Useful for:
11
11
  * Periodical batch updating of recently changing database counters.
12
12
 
13
13
  *NOTE:* As of 1.0 `batch_size` renamed to `batch_flush_size`.
14
+ *NOTE:* As of 1.0.6 works with Sidekiq 4.
14
15
 
15
16
  ## Usage
16
17
 
@@ -31,7 +31,7 @@ module Sidekiq
31
31
 
32
32
  def pluck_size
33
33
  worker_class_options['batch_flush_size'] ||
34
- Sidekiq::Grouping::Config.max_batch_size
34
+ chunk_size
35
35
  end
36
36
 
37
37
  def pluck
@@ -87,9 +87,7 @@ module Sidekiq
87
87
  private
88
88
 
89
89
  def could_flush_on_overflow?
90
- return true if size >= Sidekiq::Grouping::Config.max_batch_size
91
- worker_class_options['batch_flush_size'] &&
92
- size >= worker_class_options['batch_flush_size']
90
+ size >= pluck_size
93
91
  end
94
92
 
95
93
  def could_flush_on_time?
@@ -125,7 +123,7 @@ module Sidekiq
125
123
 
126
124
  def extract_worker_klass_and_queue(name)
127
125
  klass, queue = name.split(':')
128
- [klass.classify, queue]
126
+ [klass.camelize, queue]
129
127
  end
130
128
  end
131
129
  end
@@ -2,12 +2,13 @@ module Sidekiq
2
2
  module Grouping
3
3
  class Middleware
4
4
  def call(worker_class, msg, queue, redis_pool = nil)
5
- worker_class = worker_class.classify.constantize if worker_class.is_a?(String)
5
+ worker_class = worker_class.camelize.constantize if worker_class.is_a?(String)
6
6
  options = worker_class.get_sidekiq_options
7
7
 
8
8
  batch =
9
- options.keys.include?('batch_flush_size') ||
10
- options.keys.include?('batch_flush_interval')
9
+ options.key?('batch_flush_size') ||
10
+ options.key?('batch_flush_interval') ||
11
+ options.key?('batch_size')
11
12
 
12
13
  passthrough =
13
14
  msg['args'] &&
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Grouping
3
- VERSION = "1.0.6"
3
+ VERSION = "1.0.7"
4
4
  end
5
5
  end
@@ -26,6 +26,7 @@
26
26
  <td><%= batch.next_execution_time || "&ndash;"%></td>
27
27
  <td>
28
28
  <form action="<%= "#{root_path}grouping/#{batch.name}/delete" %>" method="post">
29
+ <%= csrf_tag %>
29
30
  <input class="btn btn-danger btn-xs" type="submit" name="delete" value="Delete" data-confirm="Are you sure you want to delete this batch?" />
30
31
  </form>
31
32
  </td>
@@ -1,6 +1,6 @@
1
1
  require 'sidekiq/web'
2
2
 
3
- module Sidetiq
3
+ module Sidekiq
4
4
  module Grouping
5
5
  module Web
6
6
  VIEWS = File.expand_path('views', File.dirname(__FILE__))
@@ -11,8 +11,8 @@ module Sidetiq
11
11
  erb File.read(File.join(VIEWS, 'index.erb')), locals: {view_path: VIEWS}
12
12
  end
13
13
 
14
- app.post "/grouping/:name/delete" do
15
- worker_class, queue = Sidekiq::Grouping::Batch.extract_worker_klass_and_queue(params['name'])
14
+ app.post "/grouping/*/delete" do |name|
15
+ worker_class, queue = Sidekiq::Grouping::Batch.extract_worker_klass_and_queue(name)
16
16
  batch = Sidekiq::Grouping::Batch.new(worker_class, queue)
17
17
  batch.delete
18
18
  redirect "#{root_path}/grouping"
@@ -23,6 +23,6 @@ module Sidetiq
23
23
  end
24
24
  end
25
25
 
26
- Sidekiq::Web.register(Sidetiq::Grouping::Web)
26
+ Sidekiq::Web.register(Sidekiq::Grouping::Web)
27
27
  Sidekiq::Web.tabs["Grouping"] = "grouping"
28
28
 
@@ -23,9 +23,9 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rspec"
24
24
  spec.add_development_dependency "simplecov"
25
25
  spec.add_development_dependency "rspec-sidekiq"
26
- spec.add_development_dependency "activesupport"
27
26
  spec.add_development_dependency "timecop"
28
27
 
29
- spec.add_dependency "sidekiq"
28
+ spec.add_dependency "activesupport"
29
+ spec.add_dependency "sidekiq", ">= 3.4.2"
30
30
  spec.add_dependency "concurrent-ruby"
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-grouping
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-25 00:00:00.000000000 Z
11
+ date: 2016-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: activesupport
84
+ name: timecop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,13 +95,13 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: timecop
98
+ name: activesupport
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
- type: :development
104
+ type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 3.4.2
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 3.4.2
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: concurrent-ruby
127
127
  requirement: !ruby/object:Gem::Requirement