conflow 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/conflow/flow.rb +17 -2
- data/lib/conflow/flow/job_handler.rb +2 -0
- data/lib/conflow/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 172b50e6e55599152b9db5caa41bf3c2c12a3ea50211cba7abee58a4087caa78
|
4
|
+
data.tar.gz: 73dbbd9b138d9e5dd97e3827f595f80274b51a62aa1da59b39e443c4b190ad54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67ce640beb104c23a542f3ba8439922a7582c5a4debf7ce444e39137ae6c019b901e529ab1fb8722826a1a554d2d973c791d16aff02883493691d5297cf4b97c
|
7
|
+
data.tar.gz: 991a119e2a9bcc11fafe10ce53b53f121e1b5103773a8471ad9c52cbc734c60dc32cade6473564088fdf87e1ab354bb7bd237c61683855da840cf20186824943
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/conflow/flow.rb
CHANGED
@@ -41,6 +41,7 @@ module Conflow
|
|
41
41
|
has_many :jobs, Conflow::Job
|
42
42
|
field :queued_jobs, :set
|
43
43
|
field :indegree, :sorted_set
|
44
|
+
field :lock, :value
|
44
45
|
|
45
46
|
# Create new flow with given parameters
|
46
47
|
# @param args [Array<Object>] any parameters that will be passed to {#configure} method
|
@@ -56,13 +57,17 @@ module Conflow
|
|
56
57
|
# MyFlow.create(id: 320, strict: false)
|
57
58
|
# MyFlow.create(id: 15, strict: true)
|
58
59
|
def self.create(*args)
|
59
|
-
new.tap
|
60
|
+
new.tap do |flow|
|
61
|
+
flow.with_lock do
|
62
|
+
flow.configure(*args)
|
63
|
+
end
|
64
|
+
end
|
60
65
|
end
|
61
66
|
|
62
67
|
# Returns whether or not the flow is finished (all jobs were processed)
|
63
68
|
# @return [Boolean] true if no pending jobs
|
64
69
|
def finished?
|
65
|
-
queued_jobs.size.zero? && indegree.size.zero?
|
70
|
+
lock.value != 1 && queued_jobs.size.zero? && indegree.size.zero?
|
66
71
|
end
|
67
72
|
|
68
73
|
# @abstract
|
@@ -71,5 +76,15 @@ module Conflow
|
|
71
76
|
# @param args [Array<Object>] any arguments needed to start a flow
|
72
77
|
# @see create
|
73
78
|
def configure(*args); end
|
79
|
+
|
80
|
+
# Lock prevents flow from enqueuing jobs during configuration - it could happen that first job is finished
|
81
|
+
# before second is enqueued, therefore "finishing" the flow.
|
82
|
+
# @api private
|
83
|
+
def with_lock
|
84
|
+
self.lock = 1
|
85
|
+
yield
|
86
|
+
self.lock = 0
|
87
|
+
queue_available_jobs
|
88
|
+
end
|
74
89
|
end
|
75
90
|
end
|
data/lib/conflow/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michał Begejowicz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|