distributed_job 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +8 -1
- data/lib/distributed_job/version.rb +1 -1
- data/lib/distributed_job.rb +2 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d9474eeee925618320f8a541274a66b68c20648a6ab7e33bd1cc302e97108e9
|
4
|
+
data.tar.gz: d2cf52dc713aca183eda21d4022001533e35d7846fa3fcf76aee9434cbe21089
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a4e788012c9b9c3bf9afe5d20a3ff835c0260aeca0e90bffd9de80441fb342ca1a30550baf974bbb5efcd85707c31e10b187e4281eab65a1f111cfcd4de6817
|
7
|
+
data.tar.gz: ce00582676f135a1a11f92f59e7cf50147b7ac1ddb8427368d1dc0b7095e40d047a6ef662f5ecf5e1c765acf64c8783bcb7a4e1d8b821d7b74b91adbd19b290b
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -38,6 +38,12 @@ To create a distributed job and add parts, i.e. units of work, to it, simply:
|
|
38
38
|
distributed_job.token # can be used to query the status of the distributed job
|
39
39
|
```
|
40
40
|
|
41
|
+
The `part` which is passed to the block is some id for one particular part of
|
42
|
+
the distributed job. It must be used in a respective background job to mark
|
43
|
+
this part finished after it has been successfully processed. Therefore, when
|
44
|
+
all those background jobs have successfully finished, all parts will be marked
|
45
|
+
as finished, such that the distributed job will finally be finished as well.
|
46
|
+
|
41
47
|
The `token` can be used to keep query the status of the distributed job, e.g.
|
42
48
|
on a job summary page or similar. You can show some progress bar in the browser
|
43
49
|
or in the terminal, etc:
|
@@ -48,7 +54,8 @@ distributed_job = Distributed.new(redis: Redis.new, token: params[:token])
|
|
48
54
|
|
49
55
|
distributed_job.total # total number of parts
|
50
56
|
distributed_job.count # number of unfinished parts
|
51
|
-
distributed_job.finished?
|
57
|
+
distributed_job.finished? # whether or not all parts are finished
|
58
|
+
distributed_job.open_parts # returns all not yet finished part id's
|
52
59
|
```
|
53
60
|
|
54
61
|
Within the background job, you use the passed token and part to query and
|
data/lib/distributed_job.rb
CHANGED
@@ -82,8 +82,6 @@ class DistributedJob
|
|
82
82
|
# end
|
83
83
|
|
84
84
|
def push_each(enum)
|
85
|
-
return enum_for(:push_each, enum) unless block_given?
|
86
|
-
|
87
85
|
previous_object = nil
|
88
86
|
previous_index = nil
|
89
87
|
|
@@ -101,11 +99,11 @@ class DistributedJob
|
|
101
99
|
yield(previous_object, previous_index.to_s) if previous_index
|
102
100
|
end
|
103
101
|
|
104
|
-
# Returns all
|
102
|
+
# Returns all parts of the distributed job which are not yet finished.
|
105
103
|
#
|
106
104
|
# @return [Enumerator] The enum which allows to iterate all parts
|
107
105
|
|
108
|
-
def
|
106
|
+
def open_parts
|
109
107
|
redis.sscan_each("#{redis_key}:parts")
|
110
108
|
end
|
111
109
|
|