gush 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +7 -6
- data/gush.gemspec +1 -1
- data/lib/gush/cli.rb +1 -1
- data/lib/gush/cli/overview.rb +1 -1
- data/lib/gush/job.rb +8 -4
- data/lib/gush/workflow.rb +7 -3
- data/spec/features/integration_spec.rb +14 -5
- data/spec/lib/gush/workflow_spec.rb +1 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 684995dea63d846e4b58504b9d1fdf3b386ca2af
|
4
|
+
data.tar.gz: b52e1adc2ebb098de804028dc0d7d70ee38e548e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ad6ed4b35110be871cdbb82d5e6058a2debdf416866d02fd4d93ecd3e7c782c5e5ad9c93823341aa0f1a68ade9b3af8cb6d9bf39c20f7211e8b75ebb1ae8c97
|
7
|
+
data.tar.gz: 8bd0060a367a3e4b27787add32210ac27fe75fe982f958043d053f2bde5dcc190a276fecc1d8f26cbe11cfa5a412112bbbd539cf662fb92a30eb9c2ce51a5e14
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -63,7 +63,7 @@ For the Workflow above, the graph will look like this:
|
|
63
63
|
You can pass any primitive arguments into jobs while defining your workflow:
|
64
64
|
|
65
65
|
```ruby
|
66
|
-
# workflows/sample_workflow.rb
|
66
|
+
# app/workflows/sample_workflow.rb
|
67
67
|
class SampleWorkflow < Gush::Workflow
|
68
68
|
def configure
|
69
69
|
run FetchJob1, params: { url: "http://some.com/url" }
|
@@ -78,7 +78,8 @@ See below to learn how to access those params inside your job.
|
|
78
78
|
Jobs are classes inheriting from `Gush::Job`:
|
79
79
|
|
80
80
|
```ruby
|
81
|
-
|
81
|
+
# app/jobs/fetch_job.rb
|
82
|
+
class FetchJob < Gush::Job
|
82
83
|
def work
|
83
84
|
# do some fetching from remote APIs
|
84
85
|
|
@@ -97,7 +98,7 @@ Workflows can accept any primitive arguments in their constructor, which then wi
|
|
97
98
|
Here's an example of a workflow responsible for publishing a book:
|
98
99
|
|
99
100
|
```ruby
|
100
|
-
# workflows/sample_workflow.rb
|
101
|
+
# app/workflows/sample_workflow.rb
|
101
102
|
class PublishBookWorkflow < Gush::Workflow
|
102
103
|
def configure(url, isbn)
|
103
104
|
run FetchBook, params: { url: url }
|
@@ -182,7 +183,7 @@ end
|
|
182
183
|
`payloads` is a hash containing outputs from all parent jobs, where job class names are the keys.
|
183
184
|
|
184
185
|
**Note:** `payloads` will only contain outputs of the job's ancestors. So if job `A` depends on `B` and `C`,
|
185
|
-
the `
|
186
|
+
the `payloads` hash will look like this:
|
186
187
|
|
187
188
|
```ruby
|
188
189
|
{
|
@@ -199,7 +200,7 @@ the `paylods` hash will look like this:
|
|
199
200
|
```ruby
|
200
201
|
flow.reload
|
201
202
|
flow.status
|
202
|
-
#=> :running|:
|
203
|
+
#=> :running|:finished|:failed
|
203
204
|
```
|
204
205
|
|
205
206
|
`reload` is needed to see the latest status, since workflows are updated asynchronously.
|
@@ -239,7 +240,7 @@ end
|
|
239
240
|
|
240
241
|
## Contributing
|
241
242
|
|
242
|
-
1. Fork it ( http://github.com/
|
243
|
+
1. Fork it ( http://github.com/chaps-io/gush/fork )
|
243
244
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
244
245
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
245
246
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/gush.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "gush"
|
7
|
-
spec.version = "0.
|
7
|
+
spec.version = "0.2.0"
|
8
8
|
spec.authors = ["Piotrek Okoński"]
|
9
9
|
spec.email = ["piotrek@okonski.org"]
|
10
10
|
spec.summary = "Fast and distributed workflow runner using only Sidekiq and Redis"
|
data/lib/gush/cli.rb
CHANGED
data/lib/gush/cli/overview.rb
CHANGED
data/lib/gush/job.rb
CHANGED
@@ -60,23 +60,27 @@ module Gush
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def enqueued?
|
63
|
-
|
63
|
+
!enqueued_at.nil?
|
64
64
|
end
|
65
65
|
|
66
66
|
def finished?
|
67
|
-
|
67
|
+
!finished_at.nil?
|
68
68
|
end
|
69
69
|
|
70
70
|
def failed?
|
71
|
-
|
71
|
+
!failed_at.nil?
|
72
72
|
end
|
73
73
|
|
74
74
|
def succeeded?
|
75
75
|
finished? && !failed?
|
76
76
|
end
|
77
77
|
|
78
|
+
def started?
|
79
|
+
!started_at.nil?
|
80
|
+
end
|
81
|
+
|
78
82
|
def running?
|
79
|
-
|
83
|
+
started? && !finished?
|
80
84
|
end
|
81
85
|
|
82
86
|
def ready_to_start?
|
data/lib/gush/workflow.rb
CHANGED
@@ -70,8 +70,12 @@ module Gush
|
|
70
70
|
jobs.all?(&:finished?)
|
71
71
|
end
|
72
72
|
|
73
|
+
def started?
|
74
|
+
@stopped == false
|
75
|
+
end
|
76
|
+
|
73
77
|
def running?
|
74
|
-
!
|
78
|
+
!finished?
|
75
79
|
end
|
76
80
|
|
77
81
|
def failed?
|
@@ -122,7 +126,7 @@ module Gush
|
|
122
126
|
when stopped?
|
123
127
|
:stopped
|
124
128
|
else
|
125
|
-
:
|
129
|
+
:running
|
126
130
|
end
|
127
131
|
end
|
128
132
|
|
@@ -174,7 +178,7 @@ module Gush
|
|
174
178
|
end
|
175
179
|
|
176
180
|
def last_job
|
177
|
-
jobs.max_by{ |n| n.finished_at || 0 } if
|
181
|
+
jobs.max_by{ |n| n.finished_at || 0 } if finished?
|
178
182
|
end
|
179
183
|
end
|
180
184
|
end
|
@@ -1,7 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
3
|
describe "Workflows" do
|
4
|
+
context "when all jobs finish successfuly" do
|
5
|
+
it "marks workflow as completed" do
|
6
|
+
flow = TestWorkflow.create
|
7
|
+
flow.start!
|
8
|
+
expect(flow.reload).to be_running
|
9
|
+
|
10
|
+
Gush::Worker.drain
|
11
|
+
|
12
|
+
flow = flow.reload
|
13
|
+
expect(flow).to be_finished
|
14
|
+
expect(flow).to_not be_failed
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
5
18
|
it "runs the whole workflow in proper order" do
|
6
19
|
flow = TestWorkflow.create
|
7
20
|
flow.start!
|
@@ -23,10 +36,6 @@ describe "Workflows" do
|
|
23
36
|
Gush::Worker.perform_one
|
24
37
|
|
25
38
|
expect(Gush::Worker.jobs).to be_empty
|
26
|
-
|
27
|
-
flow = flow.reload
|
28
|
-
expect(flow).to be_finished
|
29
|
-
expect(flow).to_not be_failed
|
30
39
|
end
|
31
40
|
|
32
41
|
it "passes payloads down the workflow" do
|
@@ -73,7 +73,7 @@ describe Gush::Workflow do
|
|
73
73
|
"id" => an_instance_of(String),
|
74
74
|
"name" => klass.to_s,
|
75
75
|
"klass" => klass.to_s,
|
76
|
-
"status" => "
|
76
|
+
"status" => "running",
|
77
77
|
"total" => 2,
|
78
78
|
"finished" => 0,
|
79
79
|
"started_at" => nil,
|
@@ -203,13 +203,6 @@ describe Gush::Workflow do
|
|
203
203
|
describe "#running?" do
|
204
204
|
context "when no enqueued or running jobs" do
|
205
205
|
it "returns false" do
|
206
|
-
expect(subject.running?).to be_falsy
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
context "when some jobs are enqueued" do
|
211
|
-
it "returns true" do
|
212
|
-
subject.find_job('Prepare').enqueue!
|
213
206
|
expect(subject.running?).to be_truthy
|
214
207
|
end
|
215
208
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotrek Okoński
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|