sidekiq-bulk 0.0.1 → 0.0.2
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/README.md +12 -3
- data/lib/sidekiq/bulk.rb +1 -3
- data/sidekiq-bulk.gemspec +1 -1
- data/spec/examples.txt +6 -6
- 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: 1ab5533e949a3c0fd54cc150325b0b6fa0c58e18
|
4
|
+
data.tar.gz: 3734f891f92c8e9668779c8e8ecdb29f118e8456
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a84969c10529edd072482cac04682223b0738f3f81a757acf7efa4f42da9b70e814b865de30db8516836891031b739cbb4c3b65abac0c8b1ddb18b2009fe016
|
7
|
+
data.tar.gz: 048773246bf5ef94b82cbdac5e6e69df7596acf3dc00d219407cc199f1a166b527ea0a80aad0ecf9523bb10028aae2f229b825cdcc2aec3afd312cc555e2bcad
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ Augments Sidekiq job classes with a `push_bulk` method for easier bulk pushing.
|
|
8
8
|
|
9
9
|
Sidekiq comes with `Sidekiq::Client.push_bulk` which can be faster than `perform_async` if you have lots and lots of jobs to enqueue.
|
10
10
|
|
11
|
-
This gem provides a wrapper around
|
11
|
+
This gem provides a wrapper around `Sidekiq::Client.push_bulk` so that instead of
|
12
12
|
|
13
13
|
```ruby
|
14
14
|
Sidekiq::Client.push_bulk("class" => FooJob, "args" => [[1], [2], [3])
|
@@ -35,10 +35,19 @@ Either `require "sidekiq-bulk"` or `require "sidekiq/bulk"`.
|
|
35
35
|
|
36
36
|
### To use
|
37
37
|
|
38
|
-
To enqueue
|
38
|
+
To enqueue a job for each element of an array:
|
39
39
|
|
40
40
|
```ruby
|
41
|
-
|
41
|
+
# enqueues 3 jobs for FooJob, each with 1 argument
|
42
|
+
FooJob.push_bulk([1, 2, 3])
|
43
|
+
|
44
|
+
# equivalent to:
|
45
|
+
Sidekiq::Client.push_bulk("class" => FooJob, "args" => [[1], [2], [3]])
|
46
|
+
|
47
|
+
# which is a more efficient version of
|
48
|
+
[1, 2, 3].each do |i|
|
49
|
+
FooJob.perform_async(i)
|
50
|
+
end
|
42
51
|
```
|
43
52
|
|
44
53
|
To enqueue jobs with more than one argument:
|
data/lib/sidekiq/bulk.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
puts Sidekiq::VERSION
|
2
|
-
|
3
1
|
module SidekiqBulk
|
4
2
|
def push_bulk(items, &block)
|
5
3
|
if block
|
@@ -12,4 +10,4 @@ module SidekiqBulk
|
|
12
10
|
end
|
13
11
|
end
|
14
12
|
|
15
|
-
Sidekiq::Worker::ClassMethods.include SidekiqBulk
|
13
|
+
Sidekiq::Worker::ClassMethods.module_eval { include SidekiqBulk }
|
data/sidekiq-bulk.gemspec
CHANGED
data/spec/examples.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
example_id | status | run_time |
|
2
2
|
---------------------------------- | ------ | --------------- |
|
3
|
-
./spec/sidekiq_bulk_spec.rb[1:1] | passed | 0.
|
4
|
-
./spec/sidekiq_bulk_spec.rb[1:2] | passed | 0.
|
5
|
-
./spec/sidekiq_bulk_spec.rb[1:3] | passed | 0.
|
6
|
-
./spec/sidekiq_bulk_spec.rb[1:4] | passed | 0.
|
7
|
-
./spec/sidekiq_bulk_spec.rb[1:5] | passed | 0.
|
8
|
-
./spec/sidekiq_bulk_spec.rb[1:6:1] | passed | 0.
|
3
|
+
./spec/sidekiq_bulk_spec.rb[1:1] | passed | 0.00181 seconds |
|
4
|
+
./spec/sidekiq_bulk_spec.rb[1:2] | passed | 0.00131 seconds |
|
5
|
+
./spec/sidekiq_bulk_spec.rb[1:3] | passed | 0.00118 seconds |
|
6
|
+
./spec/sidekiq_bulk_spec.rb[1:4] | passed | 0.00685 seconds |
|
7
|
+
./spec/sidekiq_bulk_spec.rb[1:5] | passed | 0.00366 seconds |
|
8
|
+
./spec/sidekiq_bulk_spec.rb[1:6:1] | passed | 0.00135 seconds |
|