flor 0.9.4 → 0.9.5

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.
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
  # flor CHANGELOG.md
3
3
 
4
4
 
5
+ ## flor 0.9.5 released 2017-02-10
6
+
7
+ - Don't load exids for which there are "loaded" messages
8
+ - Use Flor.tstamp for flor_messages :mtime
9
+
10
+
5
11
  ## flor 0.9.4 released 2017-02-09
6
12
 
7
13
  - Allow setting of flor_debug in ENV (FLOR_DEBUG) and in conf
data/README.md CHANGED
@@ -6,6 +6,9 @@
6
6
 
7
7
  Flor is a "Ruby workflow engine", if that makes any sense.
8
8
 
9
+ * [![Join the chat at https://gitter.im/floraison/flor](https://badges.gitter.im/floraison/flor.svg)](https://gitter.im/floraison/flor?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
10
+ * [floraison mailing list](https://groups.google.com/forum/#!forum/floraison)
11
+
9
12
  ## Design
10
13
 
11
14
  * Strives to propose a scheming interpreter for long running executions
@@ -20,7 +23,7 @@ Flor is a "Ruby workflow engine", if that makes any sense.
20
23
 
21
24
  ## Documentation
22
25
 
23
- see [doc/](tree/master/doc).
26
+ see [doc/](doc/).
24
27
 
25
28
  ## Running the specs
26
29
 
data/lib/flor.rb CHANGED
@@ -34,7 +34,7 @@ require 'raabro'
34
34
 
35
35
  module Flor
36
36
 
37
- VERSION = '0.9.4'
37
+ VERSION = '0.9.5'
38
38
  end
39
39
 
40
40
  require 'flor/colours'
@@ -360,7 +360,7 @@ module Flor
360
360
  @execution['tasks'][message['nid']] =
361
361
  { 'tasker' => message['tasker'], 'name' => message['taskname'] }
362
362
 
363
- @unit.ganger.task(message)
363
+ @unit.ganger.task(self, message)
364
364
  end
365
365
  alias detask task
366
366
 
@@ -45,7 +45,7 @@ module Flor
45
45
  !! @unit.loader.tasker(domain, name)
46
46
  end
47
47
 
48
- def task(message)
48
+ def task(executor, message)
49
49
 
50
50
  domain = message['exid'].split('-', 2).first
51
51
  tname = message['tasker']
@@ -63,7 +63,7 @@ module Flor
63
63
  message['tconf'] = tconf \
64
64
  unless tconf['on_task']['include_tconf'] == false
65
65
 
66
- message['vars'] = gather_vars(tconf, message)
66
+ message['vars'] = gather_vars(executor, tconf, message)
67
67
 
68
68
  cot = tconf['on_task']
69
69
 
@@ -178,18 +178,25 @@ module Flor
178
178
  }.compact
179
179
  end
180
180
 
181
- def gather_vars(tconf, message)
181
+ def gather_vars(executor, tconf, message)
182
182
 
183
- iv = expand_filter(tconf['on_task']['include_vars'])
184
- ev = expand_filter(tconf['on_task']['exclude_vars'])
183
+ ot = tconf['on_task']
185
184
 
186
- return nil unless iv || ev
185
+ # try to return before calling executor.vars(nid) which my be costly...
187
186
 
188
- vars = @unit.executor(message['exid']).vars(message['nid'])
187
+ return nil if (ot.keys & %w[ include_vars exclude_vars ]).empty?
188
+ # default behaviour, don't pass variables to taskers
189
189
 
190
- return vars if iv == true
190
+ iv = expand_filter(ot['include_vars'])
191
+ return nil if iv == false
192
+
193
+ ev = expand_filter(ot['exclude_vars'])
191
194
  return {} if ev == true
192
195
 
196
+ vars = executor.vars(message['nid'])
197
+
198
+ return vars if iv == true
199
+
193
200
  vars = vars.select { |k, v| var_match(k, iv) } if iv
194
201
  vars = vars.reject { |k, v| var_match(k, ev) } if ev
195
202
 
@@ -121,15 +121,21 @@ module Flor
121
121
 
122
122
  def load_exids
123
123
 
124
- # TODO eventually, exclude exids for which there are "loaded" messages
125
-
126
124
  synchronize do
127
125
 
126
+ # only take messages that are 'created' and for whose exid
127
+ # there are no loaded messages
128
+
129
+ # TODO update status to 'created' for messages that have been
130
+ # 'loaded' for too long
131
+
128
132
  @db[:flor_messages]
129
133
  .select(:exid)
130
- .group(:exid)
131
- .where(status: 'created')
132
- .order { min(:ctime) }
134
+ .where(exid:
135
+ @db[:flor_messages].select(:exid).where(status: 'created'))
136
+ .exclude(exid:
137
+ @db[:flor_messages].select(:exid).where(status: 'loaded'))
138
+ .order(:mtime)
133
139
  .collect { |r| r[:exid] }
134
140
  end
135
141
 
@@ -230,6 +236,8 @@ module Flor
230
236
 
231
237
  transync do
232
238
 
239
+ # TODO weave in [some] optimistic locking here
240
+
233
241
  mids = []
234
242
 
235
243
  ms = @db[:flor_messages]
@@ -243,7 +251,7 @@ module Flor
243
251
 
244
252
  @db[:flor_messages]
245
253
  .where(id: mids)
246
- .update(status: 'loaded', mtime: Time.now)
254
+ .update(status: 'loaded', mtime: Flor.tstamp)
247
255
  #
248
256
  # flag them as "loaded" so that other scheduler don't pick them
249
257
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-02-08 00:00:00.000000000 Z
12
+ date: 2017-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: munemo