weel 1.99.127 → 1.99.129

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/weel.rb +117 -63
  3. data/weel.gemspec +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f160d41131af38c3087b40f26a0ba6bd05525e1dd4fe7aadb41246bd8b0b3eb9
4
- data.tar.gz: ff7f466bddefecaa975670d6977abacc1fbf2bde393c1a5cfd4f3a4abe38af88
3
+ metadata.gz: 52a9d1b00bfbd9df62e95f290c520c447b8cb2bb4d4add32efa2b7ec2e31fc54
4
+ data.tar.gz: 8d0d3bb0a413fb1ad7a2d81ea63c2eade55e5f0173045daaced8f495fc6f1de0
5
5
  SHA512:
6
- metadata.gz: 96b9d6cdfc740ecea0210a57a72277c75d313c3a8318a4ca69e8a1d1500ce0ab213c276e90b97a696eb365647553b3cd7ca45cd6a45366c52f4f86a62e15b15a
7
- data.tar.gz: 1f430d38d063a362be2f286ccbfe2e3201b08049143c04fabbdc78289c4456b6a6b1d59f5a10ce2796e6531ca82f3ae570aa86163ae1e897361b44d6a73c7488
6
+ metadata.gz: cce8bf3f578fd2700c317a011437fc6f806f5b4b51d335473a041c3e0253fa06e981d9dfd00edebbae8c9cad1b8a1bbfe20e4afab3445b1549eda6cab18b5281
7
+ data.tar.gz: 8497d993333e112bf56c4431040ca454ee8eeeb57f6fd9437abe9c6deac2b6115c0b672aa28e8ce2f47d23dcc5b5f6226315fd6e0d9f01d7507bfe1460c48b86
data/lib/weel.rb CHANGED
@@ -290,6 +290,42 @@ class WEEL
290
290
  end
291
291
  end
292
292
  end # }}}
293
+ class ReadOnlyHash # {{{
294
+ def initialize(values)
295
+ @__weel_values = values.transform_values do |v|
296
+ if Object.const_defined?(:XML) && XML.const_defined?(:Smart) && v.is_a?(XML::Smart::Dom)
297
+ v.root.to_doc
298
+ else
299
+ begin
300
+ Marshal.load(Marshal.dump(v))
301
+ rescue
302
+ v.to_s rescue nil
303
+ end
304
+ end
305
+ end
306
+ end
307
+
308
+ def to_json(*args)
309
+ @__weel_values.to_json(*args)
310
+ end
311
+
312
+ def method_missing(name,*args)
313
+ if args.empty? && @__weel_values.key?(name)
314
+ @__weel_values[name]
315
+ elsif args.empty? && @__weel_values.key?(name.to_s)
316
+ @__weel_values[name.to_s]
317
+ elsif name.to_s[-1..-1] == "=" && args.length == 1
318
+ temp = name.to_s[0..-2]
319
+ @__weel_values[temp.to_sym] = args[0]
320
+ elsif name.to_s == "[]=" && args.length == 2
321
+ @__weel_values[args[0]] = args[1]
322
+ elsif name.to_s == "[]" && args.length == 1
323
+ @__weel_values[args[0]]
324
+ else
325
+ nil
326
+ end
327
+ end
328
+ end # }}}
293
329
 
294
330
  class ProcString #{{{
295
331
  attr_reader :code
@@ -718,6 +754,16 @@ class WEEL
718
754
  self.__weel_state = :stopping
719
755
  end #}}}
720
756
 
757
+ def status # {{{
758
+ @__weel_status
759
+ end # }}}
760
+ def data # {{{
761
+ ReadOnlyHash.new(@__weel_data)
762
+ end # }}}
763
+ def endpoints # {{{
764
+ ReadHash.new(@__weel_endpoints)
765
+ end # }}}
766
+
721
767
  private
722
768
  def __weel_protect_yield(*local) #{{{
723
769
  begin
@@ -829,70 +875,72 @@ class WEEL
829
875
  @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :after => [wp]
830
876
  end
831
877
  when :call
832
- again = catch Signal::Again do # Will be nil if we do not throw (using default connectionwrapper)
833
- connectionwrapper.mem_guard
834
- params = connectionwrapper.prepare(@__weel_lock,@__weel_data,@__weel_endpoints,@__weel_status,Thread.current[:local],connectionwrapper.additional,prepare,endpoint,parameters)
835
-
836
- raise Signal::Stop unless connectionwrapper.vote_sync_before(params)
837
- raise Signal::Skip if self.__weel_state == :stopping || self.__weel_state == :finishing
838
-
839
- connectionwrapper.activity_handle wp.passthrough, params
840
- wp.passthrough = connectionwrapper.activity_passthrough_value
841
- unless wp.passthrough.nil?
842
- @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :wait => [wp]
843
- end
844
- begin
845
- # cleanup after callback updates
878
+ begin
879
+ again = catch Signal::Again do # Will be nil if we do not throw (using default connectionwrapper)
846
880
  connectionwrapper.mem_guard
881
+ params = connectionwrapper.prepare(@__weel_lock,@__weel_data,@__weel_endpoints,@__weel_status,Thread.current[:local],connectionwrapper.additional,prepare,endpoint,parameters)
847
882
 
848
- # with loop if catching Signal::Again
849
- # handshake call and wait until it finished
850
- waitingresult = nil
851
- waitingresult = Thread.current[:continue].wait unless Thread.current[:nolongernecessary] || self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped
883
+ raise Signal::Stop unless connectionwrapper.vote_sync_before(params)
884
+ raise Signal::Skip if self.__weel_state == :stopping || self.__weel_state == :finishing
852
885
 
853
- if Thread.current[:nolongernecessary]
854
- connectionwrapper.activity_no_longer_necessary
855
- raise Signal::NoLongerNecessary
856
- end
857
- if self.__weel_state == :stopping || self.__weel_state == :finishing
858
- connectionwrapper.activity_stop
859
- wp.passthrough = connectionwrapper.activity_passthrough_value
860
- raise Signal::Proceed if wp.passthrough # if stop, but no passthrough, let manipulate happen and then stop
886
+ connectionwrapper.activity_handle wp.passthrough, params
887
+ wp.passthrough = connectionwrapper.activity_passthrough_value
888
+ unless wp.passthrough.nil?
889
+ @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :wait => [wp]
861
890
  end
891
+ begin
892
+ # cleanup after callback updates
893
+ connectionwrapper.mem_guard
894
+
895
+ # with loop if catching Signal::Again
896
+ # handshake call and wait until it finished
897
+ waitingresult = nil
898
+ waitingresult = Thread.current[:continue].wait unless Thread.current[:nolongernecessary] || self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped
899
+
900
+ if Thread.current[:nolongernecessary]
901
+ connectionwrapper.activity_no_longer_necessary
902
+ raise Signal::NoLongerNecessary
903
+ end
904
+ if self.__weel_state == :stopping || self.__weel_state == :finishing
905
+ connectionwrapper.activity_stop
906
+ wp.passthrough = connectionwrapper.activity_passthrough_value
907
+ raise Signal::Proceed if wp.passthrough # if stop, but no passthrough, let manipulate happen and then stop
908
+ end
862
909
 
863
- next if waitingresult == WEEL::Signal::UpdateAgain && connectionwrapper.activity_result_value&.length == 0
910
+ next if waitingresult == WEEL::Signal::UpdateAgain && connectionwrapper.activity_result_value&.length == 0
864
911
 
865
- code, cmess = if waitingresult == WEEL::Signal::UpdateAgain
866
- [update, 'update']
867
- elsif waitingresult == WEEL::Signal::Salvage
868
- [salvage, 'salvage'] || raise('HTTP Error. The service return status was not between 200 and 300.')
869
- else
870
- [finalize, 'finalize']
871
- end
872
- if code.is_a?(String)
873
- connectionwrapper.inform_activity_manipulate
874
- struct = nil
875
-
876
- # when you throw without parameters, ma contains nil, so we return Signal::Proceed to give ma a meaningful value in other cases
877
- ma = catch Signal::Again do
878
- struct = connectionwrapper.manipulate(false,@__weel_lock,@__weel_data,@__weel_endpoints,@__weel_status,Thread.current[:local],connectionwrapper.additional,code,'Activity ' + position.to_s + ' ' + cmess,connectionwrapper.activity_result_value,connectionwrapper.activity_result_options)
879
- Signal::Proceed
912
+ code, cmess = if waitingresult == WEEL::Signal::UpdateAgain
913
+ [update, 'update']
914
+ elsif waitingresult == WEEL::Signal::Salvage
915
+ [salvage, 'salvage'] || raise('HTTP Error. The service return status was not between 200 and 300.')
916
+ else
917
+ [finalize, 'finalize']
880
918
  end
881
- connectionwrapper.inform_manipulate_change(
882
- ((struct && struct.changed_status) ? @__weel_status : nil),
883
- ((struct && struct.changed_data.any?) ? struct.changed_data.uniq : nil),
884
- ((struct && struct.changed_endpoints.any?) ? struct.changed_endpoints.uniq : nil),
885
- @__weel_data,
886
- @__weel_endpoints
887
- )
888
- throw(Signal::Again, Signal::Again) if ma.nil? || ma == Signal::Again # this signal again loops "there is a catch" because rescue signal throw that throughly restarts the task
919
+ if code.is_a?(String)
920
+ connectionwrapper.inform_activity_manipulate
921
+ struct = nil
922
+
923
+ # when you throw without parameters, ma contains nil, so we return Signal::Proceed to give ma a meaningful value in other cases
924
+ ma = catch Signal::Again do
925
+ struct = connectionwrapper.manipulate(false,@__weel_lock,@__weel_data,@__weel_endpoints,@__weel_status,Thread.current[:local],connectionwrapper.additional,code,'Activity ' + position.to_s + ' ' + cmess,connectionwrapper.activity_result_value,connectionwrapper.activity_result_options)
926
+ Signal::Proceed
927
+ end
928
+ connectionwrapper.inform_manipulate_change(
929
+ ((struct && struct.changed_status) ? @__weel_status : nil),
930
+ ((struct && struct.changed_data.any?) ? struct.changed_data.uniq : nil),
931
+ ((struct && struct.changed_endpoints.any?) ? struct.changed_endpoints.uniq : nil),
932
+ @__weel_data,
933
+ @__weel_endpoints
934
+ )
935
+ throw(Signal::Again, Signal::Again) if ma.nil? || ma == Signal::Again # this signal again loops "there is a catch" because rescue signal throw that throughly restarts the task
936
+ end
937
+ end while waitingresult == Signal::UpdateAgain # this signal again loops because async update, proposal: rename to UpdateAgain
938
+ if connectionwrapper.activity_passthrough_value.nil?
939
+ connectionwrapper.inform_activity_done
940
+ wp.passthrough = nil
941
+ wp.detail = :after
942
+ @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :after => [wp]
889
943
  end
890
- end while waitingresult == Signal::UpdateAgain # this signal again loops because async update, proposal: rename to UpdateAgain
891
- if connectionwrapper.activity_passthrough_value.nil?
892
- connectionwrapper.inform_activity_done
893
- wp.passthrough = nil
894
- wp.detail = :after
895
- @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :after => [wp]
896
944
  end
897
945
  end while again == Signal::Again # there is a catch
898
946
  end
@@ -1016,7 +1064,7 @@ class WEEL
1016
1064
  def __weel_state=(newState)# {{{
1017
1065
  return @__weel_state if newState == @__weel_state && @__weel_state != :ready
1018
1066
 
1019
- @__weel_positions = Array.new if newState == :running
1067
+ @__weel_positions = Array.new if newState == :running || @dslr.__weel_state == :simulating
1020
1068
  @__weel_state = newState
1021
1069
 
1022
1070
  if newState == :stopping || newState == :finishing
@@ -1097,7 +1145,7 @@ public
1097
1145
  @dslr.__weel_state = :stopping
1098
1146
  @dslr.__weel_connectionwrapper::inform_syntax_error(@dslr.__weel_connectionwrapper_args,err,code)
1099
1147
  end
1100
- if @dslr.__weel_state == :running || @dslr.__weel_state == :finishing
1148
+ if @dslr.__weel_state == :running || @dslr.__weel_state == :finishing || @dslr.__weel_state == :simulating
1101
1149
  ipc = { :unmark => [] }
1102
1150
  @dslr.__weel_positions.each{ |wp| ipc[:unmark] << wp }
1103
1151
  @dslr.__weel_positions.clear
@@ -1156,7 +1204,7 @@ public
1156
1204
  # Stop the workflow execution
1157
1205
  def stop # {{{
1158
1206
  Thread.new do
1159
- if @dslr.__weel_state == :running
1207
+ if @dslr.__weel_state == :running || @dslr.__weel_state == :simulating
1160
1208
  @dslr.__weel_state = :stopping
1161
1209
  @dslr.__weel_main.join if @dslr.__weel_main
1162
1210
  elsif @dslr.__weel_state == :ready || @dslr.__weel_state == :stopped
@@ -1178,12 +1226,18 @@ public
1178
1226
  end
1179
1227
  end
1180
1228
  end # }}}
1181
-
1229
+ # Sim the workflow execution
1182
1230
  def sim # {{{
1183
- stat = @dslr.__weel_state
1184
- return nil unless stat == :ready || stat == :stopped
1231
+ return nil if @dslr.__weel_state != :ready && @dslr.__weel_state != :stopped
1185
1232
  @dslr.__weel_main = Thread.new do
1186
- __weel_control_flow :simulating, stat
1233
+ Thread.current[:branch_search] = true if @dslr.__weel_search_positions.any?
1234
+ begin
1235
+ __weel_control_flow(:simulating, stat)
1236
+ rescue => e
1237
+ puts e.message
1238
+ puts e.backtrace
1239
+ connectionwrapper::inform_connectionwrapper_error connectionwrapper_args, e
1240
+ end
1187
1241
  end
1188
1242
  end # }}}
1189
1243
 
data/weel.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "weel"
3
- s.version = "1.99.127"
3
+ s.version = "1.99.129"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0-or-later"
6
6
  s.summary = "Workflow Execution Engine Library (WEEL)"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.99.127
4
+ version: 1.99.129
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-09-23 00:00:00.000000000 Z
12
+ date: 2024-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit