sidekiq-paquet 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/lib/sidekiq/paquet/batch.rb +6 -2
- data/lib/sidekiq/paquet/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a8cb3d7307887cc9c34999050e7460e6515f381
|
4
|
+
data.tar.gz: 6097a9b12ffc1546b784c2b519d5687da3017418
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc9e033a09c25ef09aae43065f9b92329acf33225c640d2737b4ef0dcc112681c5c436938206c0b67c4864d43ad8479a6533b78295ec05b8c1978cf60f216cc9
|
7
|
+
data.tar.gz: c970fde44941632e1d115dd88a5bbdfaf65e44f005ca13bcf356305d042283a705ca9ee1df46a5bd585de6a18b3fef92762a00c1b8ef5ab1b07e03fc0c9920c4
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Sidekiq::Paquet
|
2
2
|
|
3
|
-
Instead of enqueueing and processing jobs one at a time, enqueue them one by one process them in bulk.
|
3
|
+
Instead of enqueueing and processing jobs one at a time, enqueue them one by one and process them in bulk.
|
4
4
|
Useful for grouping background API calls or intensive database inserts coming from multiple sources.
|
5
5
|
|
6
6
|
## Installation
|
@@ -9,7 +9,7 @@ Useful for grouping background API calls or intensive database inserts coming fr
|
|
9
9
|
gem install 'sidekiq-paquet'
|
10
10
|
```
|
11
11
|
|
12
|
-
sidekiq-bulk requires Sidekiq 4+.
|
12
|
+
sidekiq-bulk requires Sidekiq 4+.
|
13
13
|
|
14
14
|
## Usage
|
15
15
|
|
@@ -21,7 +21,7 @@ class ElasticIndexerWorker
|
|
21
21
|
|
22
22
|
sidekiq_options bulk: true, bulk_size: 100
|
23
23
|
|
24
|
-
def perform(values)
|
24
|
+
def perform(*values)
|
25
25
|
# Perform work with the array of values
|
26
26
|
end
|
27
27
|
end
|
@@ -46,6 +46,8 @@ the worker instance will receive these values as a single argument
|
|
46
46
|
]
|
47
47
|
```
|
48
48
|
|
49
|
+
Every time polling happens, `sidekiq-paquet` will try to process all your workers marked for bulk. If you want to limit the time between two polling per worker, you can pass the `bulk_minimum_interval` option to sidekiq options.
|
50
|
+
|
49
51
|
## Configuration
|
50
52
|
|
51
53
|
You can change global configuration by modifying the `Sidekiq::Paquet.options` hash.
|
data/lib/sidekiq/paquet/batch.rb
CHANGED
@@ -8,19 +8,22 @@ module Sidekiq
|
|
8
8
|
|
9
9
|
Sidekiq.redis do |conn|
|
10
10
|
conn.multi do
|
11
|
-
conn.
|
11
|
+
conn.zadd('bulks'.freeze, 0, worker_name, nx: true)
|
12
12
|
conn.rpush("bulk:#{worker_name}", Sidekiq.dump_json(args))
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.enqueue_jobs
|
18
|
+
now = Time.now.to_f
|
18
19
|
Sidekiq.redis do |conn|
|
19
|
-
workers = conn.
|
20
|
+
workers = conn.zrangebyscore('bulks'.freeze, '-inf', now)
|
20
21
|
|
21
22
|
workers.each do |worker|
|
22
23
|
klass = worker.constantize
|
23
24
|
opts = klass.get_sidekiq_options
|
25
|
+
min_interval = opts['bulk_minimum_interval'.freeze]
|
26
|
+
|
24
27
|
items = conn.lrange("bulk:#{worker}", 0, -1)
|
25
28
|
items.map! { |i| Sidekiq.load_json(i) }
|
26
29
|
|
@@ -33,6 +36,7 @@ module Sidekiq
|
|
33
36
|
end
|
34
37
|
|
35
38
|
conn.ltrim("bulk:#{worker}", items.size, -1)
|
39
|
+
conn.zadd('bulks'.freeze, now + min_interval, worker) if min_interval
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-paquet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ccocchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -107,9 +107,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.5.1
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Bulk processing for sidekiq 4+
|
114
114
|
test_files: []
|
115
|
-
has_rdoc:
|