weel 1.99.98 → 1.99.99
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.
- checksums.yaml +4 -4
- data/lib/weel.rb +93 -90
- data/test/{SimHandlerWrapper.rb → SimConnectionWrapper.rb} +18 -18
- data/test/{TestHandlerWrapper.rb → TestConnectionWrapper.rb} +2 -2
- data/test/TestWorkflow.rb +2 -2
- data/test/basic/tc_handler.rb +4 -4
- data/weel.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b6d41da4a64d101b885ac475da4625fff4bb4098b9430563f3fc950f7804517e
|
|
4
|
+
data.tar.gz: b0714d35fa2e112b63b31e19699814607b66545eb60614d834e852d308d1ce7b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9d79e7d56585b62912f638066fb4fee0e9a71786c10ea638819ff04189df8d335282d140d7b28734abd92e18eb8078c761e9b9e3b16666166afafcfd0c631acc
|
|
7
|
+
data.tar.gz: b3d67a26a4016f7711273025427da307fe989f82319221ee07a1617eefe8f0bd2e04c845acee55d1e3a84619064a31744d53cf2a43344ed09c8568ef57f6a5c3
|
data/lib/weel.rb
CHANGED
|
@@ -20,13 +20,14 @@ require 'securerandom'
|
|
|
20
20
|
class WEEL
|
|
21
21
|
def initialize(*args)# {{{
|
|
22
22
|
@dslr = DSLRealization.new
|
|
23
|
-
@dslr.
|
|
23
|
+
@dslr.__weel_connectionwrapper_args = args
|
|
24
24
|
|
|
25
25
|
initialize_search if methods.include?(:initialize_search)
|
|
26
26
|
initialize_data if methods.include?(:initialize_data)
|
|
27
27
|
initialize_endpoints if methods.include?(:initialize_endpoints)
|
|
28
|
-
|
|
28
|
+
initialize_connectionwrapper if methods.include?(:initialize_connectionwrapper)
|
|
29
29
|
initialize_control if methods.include?(:initialize_control)
|
|
30
|
+
initialize_flow_data if methods.include?(:initialize_flow_data)
|
|
30
31
|
end # }}}
|
|
31
32
|
|
|
32
33
|
module Signal # {{{
|
|
@@ -237,11 +238,11 @@ class WEEL
|
|
|
237
238
|
end
|
|
238
239
|
end # }}}
|
|
239
240
|
|
|
240
|
-
class
|
|
241
|
+
class ConnectionWrapperBase # {{{
|
|
241
242
|
def self::loop_guard(arguments,lid,count); false; end
|
|
242
243
|
def self::inform_state_change(arguments,newstate); end
|
|
243
244
|
def self::inform_syntax_error(arguments,err,code); end
|
|
244
|
-
def self::
|
|
245
|
+
def self::inform_connectionwrapper_error(arguments,err); end
|
|
245
246
|
def self::inform_position_change(arguments,ipc={}); end
|
|
246
247
|
|
|
247
248
|
def initialize(arguments,position=nil,continue=nil); end
|
|
@@ -353,19 +354,21 @@ class WEEL
|
|
|
353
354
|
end
|
|
354
355
|
end
|
|
355
356
|
end # }}}
|
|
356
|
-
def self::
|
|
357
|
-
define_method :
|
|
358
|
-
self.
|
|
359
|
-
self.
|
|
357
|
+
def self::connectionwrapper(aClassname, *args)# {{{
|
|
358
|
+
define_method :initialize_connectionwrapper do
|
|
359
|
+
self.connectionwrapper = aClassname
|
|
360
|
+
self.connectionwrapper_args = args unless args.empty?
|
|
360
361
|
end
|
|
361
362
|
end # }}}
|
|
362
363
|
def self::control(flow, &block)# {{{
|
|
363
|
-
@@__weel_control_block = block
|
|
364
364
|
define_method :initialize_control do
|
|
365
|
-
self.description =
|
|
365
|
+
self.description = block
|
|
366
366
|
end
|
|
367
367
|
end # }}}
|
|
368
|
-
def self::flow # {{{
|
|
368
|
+
def self::flow(flow_data=nil) # {{{
|
|
369
|
+
define_method :initialize_flow_data do
|
|
370
|
+
self.flow_data = flow_data
|
|
371
|
+
end if flow_data
|
|
369
372
|
end #}}}
|
|
370
373
|
|
|
371
374
|
class DSLRealization # {{{
|
|
@@ -375,14 +378,14 @@ class WEEL
|
|
|
375
378
|
@__weel_main = nil
|
|
376
379
|
@__weel_data ||= Hash.new
|
|
377
380
|
@__weel_endpoints ||= Hash.new
|
|
378
|
-
@
|
|
379
|
-
@
|
|
381
|
+
@__weel_connectionwrapper = ConnectionWrapperBase
|
|
382
|
+
@__weel_connectionwrapper_args = []
|
|
380
383
|
@__weel_state = :ready
|
|
381
384
|
@__weel_status = Status.new(0,"undefined")
|
|
382
385
|
@__weel_replay = false
|
|
383
386
|
@__weel_sim = -1
|
|
384
387
|
end #}}}
|
|
385
|
-
attr_accessor :__weel_search_positions, :__weel_positions, :__weel_main, :__weel_data, :__weel_endpoints, :
|
|
388
|
+
attr_accessor :__weel_search_positions, :__weel_positions, :__weel_main, :__weel_data, :__weel_endpoints, :__weel_connectionwrapper, :__weel_connectionwrapper_args, :__weel_replay
|
|
386
389
|
attr_reader :__weel_state, :__weel_status
|
|
387
390
|
|
|
388
391
|
# DSL-Constructs for atomic calls to external services (calls) and pure context manipulations (manipulate).
|
|
@@ -483,15 +486,15 @@ class WEEL
|
|
|
483
486
|
Thread.current[:start_event].wait unless self.__weel_state == :stopping || self.__weel_state == :stopped || self.__weel_state == :finishing
|
|
484
487
|
|
|
485
488
|
if __weel_sim
|
|
486
|
-
|
|
487
|
-
|
|
489
|
+
connectionwrapper = @__weel_connectionwrapper.new @__weel_connectionwrapper_args
|
|
490
|
+
connectionwrapper.simulate(:parallel_branch,:start,Thread.current[:branch_sim_pos],current_branch_sim_pos)
|
|
488
491
|
end
|
|
489
492
|
|
|
490
493
|
unless self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
|
|
491
494
|
__weel_protect_yield(*local, &block)
|
|
492
495
|
end
|
|
493
496
|
|
|
494
|
-
__weel_sim_stop(:parallel_branch,
|
|
497
|
+
__weel_sim_stop(:parallel_branch,connectionwrapper,current_branch_sim_pos) if __weel_sim
|
|
495
498
|
|
|
496
499
|
branch_parent[:mutex].synchronize do
|
|
497
500
|
Thread.current[:branch_status] = true
|
|
@@ -506,7 +509,7 @@ class WEEL
|
|
|
506
509
|
begin
|
|
507
510
|
ipc = {}
|
|
508
511
|
ipc[:unmark] = [Thread.current[:branch_position]]
|
|
509
|
-
@
|
|
512
|
+
@__weel_connectionwrapper::inform_position_change(@__weel_connectionwrapper_args,ipc)
|
|
510
513
|
end rescue nil
|
|
511
514
|
Thread.current[:branch_position] = nil
|
|
512
515
|
end
|
|
@@ -604,13 +607,13 @@ class WEEL
|
|
|
604
607
|
while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
|
|
605
608
|
loop_guard += 1
|
|
606
609
|
__weel_protect_yield(&block)
|
|
607
|
-
sleep 1 if @
|
|
610
|
+
sleep 1 if @__weel_connectionwrapper::loop_guard(@__weel_connectionwrapper_args,loop_id,loop_guard)
|
|
608
611
|
end
|
|
609
612
|
when :post_test
|
|
610
613
|
begin
|
|
611
614
|
loop_guard += 1
|
|
612
615
|
__weel_protect_yield(&block)
|
|
613
|
-
sleep 1 if @
|
|
616
|
+
sleep 1 if @__weel_connectionwrapper::loop_guard(@__weel_connectionwrapper_args,loop_id,loop_guard)
|
|
614
617
|
end while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
|
|
615
618
|
end
|
|
616
619
|
end
|
|
@@ -660,27 +663,27 @@ class WEEL
|
|
|
660
663
|
yield(*local) if block_given?
|
|
661
664
|
rescue NameError => err # don't look into it, or it will explode
|
|
662
665
|
self.__weel_state = :stopping
|
|
663
|
-
@
|
|
666
|
+
@__weel_connectionwrapper::inform_syntax_error(@__weel_connectionwrapper_args,Exception.new("protect_yield: `#{err.name}` is not a thing that can be used. Maybe it is meant to be a string and you forgot quotes?"),nil)
|
|
664
667
|
nil
|
|
665
668
|
rescue => err
|
|
666
669
|
self.__weel_state = :stopping
|
|
667
|
-
@
|
|
670
|
+
@__weel_connectionwrapper::inform_syntax_error(@__weel_connectionwrapper_args,Exception.new(err.message),nil)
|
|
668
671
|
nil
|
|
669
672
|
end
|
|
670
673
|
end #}}}
|
|
671
674
|
|
|
672
675
|
def __weel_eval_condition(condition) #{{{
|
|
673
676
|
begin
|
|
674
|
-
|
|
675
|
-
condition.is_a?(Proc) ? condition.call :
|
|
677
|
+
connectionwrapper = @__weel_connectionwrapper.new @__weel_connectionwrapper_args unless condition.is_a?(Proc)
|
|
678
|
+
condition.is_a?(Proc) ? condition.call : connectionwrapper.test_condition(ReadStructure.new(@__weel_data,@__weel_endpoints,connectionwrapper.additional),condition)
|
|
676
679
|
rescue NameError => err # don't look into it, or it will explode
|
|
677
680
|
# if you access $! here, BOOOM
|
|
678
681
|
self.__weel_state = :stopping
|
|
679
|
-
@
|
|
682
|
+
@__weel_connectionwrapper::inform_syntax_error(@__weel_connectionwrapper_args,Exception.new("eval_condition: `#{err.name}` is not a thing that can be used. Maybe it is meant to be a string and you forgot quotes?"),nil)
|
|
680
683
|
nil
|
|
681
684
|
rescue => err
|
|
682
685
|
self.__weel_state = :stopping
|
|
683
|
-
@
|
|
686
|
+
@__weel_connectionwrapper::inform_syntax_error(@__weel_connectionwrapper_args,Exception.new(err.message),nil)
|
|
684
687
|
nil
|
|
685
688
|
end
|
|
686
689
|
end #}}}
|
|
@@ -718,7 +721,7 @@ class WEEL
|
|
|
718
721
|
@__weel_positions << wp
|
|
719
722
|
Thread.current[:branch_position] = wp
|
|
720
723
|
|
|
721
|
-
@
|
|
724
|
+
@__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, ipc
|
|
722
725
|
wp
|
|
723
726
|
end #}}}
|
|
724
727
|
|
|
@@ -730,10 +733,10 @@ class WEEL
|
|
|
730
733
|
return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
|
|
731
734
|
|
|
732
735
|
Thread.current[:continue] = Continue.new
|
|
733
|
-
|
|
736
|
+
connectionwrapper = @__weel_connectionwrapper.new @__weel_connectionwrapper_args, position, Thread.current[:continue]
|
|
734
737
|
|
|
735
738
|
if __weel_sim
|
|
736
|
-
|
|
739
|
+
connectionwrapper.simulate(:activity,:none,@__weel_sim += 1,Thread.current[:branch_sim_pos],:position => position,:parameters => parameters,:endpoint => endpoint,:type => type,:finalize => finalize.is_a?(String) ? finalize : nil)
|
|
737
740
|
return
|
|
738
741
|
end
|
|
739
742
|
|
|
@@ -744,35 +747,35 @@ class WEEL
|
|
|
744
747
|
|
|
745
748
|
case type
|
|
746
749
|
when :manipulate
|
|
747
|
-
raise Signal::Stop unless
|
|
750
|
+
raise Signal::Stop unless connectionwrapper.vote_sync_before
|
|
748
751
|
raise Signal::Skip if self.__weel_state == :stopping || self.__weel_state == :finishing
|
|
749
752
|
|
|
750
753
|
if finalize.is_a?(Proc) || finalize.is_a?(String)
|
|
751
|
-
|
|
752
|
-
|
|
754
|
+
connectionwrapper.activity_manipulate_handle(parameters)
|
|
755
|
+
connectionwrapper.inform_activity_manipulate
|
|
753
756
|
if finalize.is_a?(Proc)
|
|
754
|
-
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,
|
|
757
|
+
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
|
|
755
758
|
mr.instance_eval(&finalize)
|
|
756
759
|
elsif finalize.is_a?(String)
|
|
757
|
-
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,
|
|
758
|
-
|
|
760
|
+
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
|
|
761
|
+
connectionwrapper.manipulate(mr,finalize)
|
|
759
762
|
end
|
|
760
|
-
|
|
763
|
+
connectionwrapper.inform_manipulate_change(
|
|
761
764
|
((mr && mr.changed_status) ? @__weel_status : nil),
|
|
762
765
|
((mr && mr.changed_data.any?) ? mr.changed_data.uniq : nil),
|
|
763
766
|
((mr && mr.changed_endpoints.any?) ? mr.changed_endpoints.uniq : nil),
|
|
764
767
|
@__weel_data,
|
|
765
768
|
@__weel_endpoints
|
|
766
769
|
)
|
|
767
|
-
|
|
770
|
+
connectionwrapper.inform_activity_done
|
|
768
771
|
wp.detail = :after
|
|
769
|
-
@
|
|
772
|
+
@__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :after => [wp]
|
|
770
773
|
end
|
|
771
774
|
when :call
|
|
772
775
|
begin
|
|
773
776
|
again = catch Signal::Again do
|
|
774
|
-
|
|
775
|
-
rs = ReadStructure.new(@__weel_data,@__weel_endpoints,
|
|
777
|
+
connectionwrapper.mem_guard
|
|
778
|
+
rs = ReadStructure.new(@__weel_data,@__weel_endpoints,connectionwrapper.additional)
|
|
776
779
|
if prepare
|
|
777
780
|
if prepare.is_a?(Proc)
|
|
778
781
|
rs.instance_exec(&prepare)
|
|
@@ -780,14 +783,14 @@ class WEEL
|
|
|
780
783
|
rs.instance_eval prepare
|
|
781
784
|
end
|
|
782
785
|
end
|
|
783
|
-
params =
|
|
784
|
-
raise Signal::Stop unless
|
|
786
|
+
params = connectionwrapper.prepare(rs,endpoint,parameters,@__weel_replay)
|
|
787
|
+
raise Signal::Stop unless connectionwrapper.vote_sync_before(params)
|
|
785
788
|
raise Signal::Skip if self.__weel_state == :stopping || self.__weel_state == :finishing
|
|
786
789
|
|
|
787
|
-
|
|
788
|
-
wp.passthrough =
|
|
790
|
+
connectionwrapper.activity_handle wp.passthrough, params
|
|
791
|
+
wp.passthrough = connectionwrapper.activity_passthrough_value
|
|
789
792
|
unless wp.passthrough.nil?
|
|
790
|
-
@
|
|
793
|
+
@__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :wait => [wp]
|
|
791
794
|
end
|
|
792
795
|
begin
|
|
793
796
|
# with loop if catching Signal::Again
|
|
@@ -797,12 +800,12 @@ class WEEL
|
|
|
797
800
|
raise waitingresult[1] if !waitingresult.nil? && waitingresult.is_a?(Array) && waitingresult.length == 2 && waitingresult[0] == WEEL::Signal::Error
|
|
798
801
|
|
|
799
802
|
if Thread.current[:nolongernecessary]
|
|
800
|
-
|
|
803
|
+
connectionwrapper.activity_no_longer_necessary
|
|
801
804
|
raise Signal::NoLongerNecessary
|
|
802
805
|
end
|
|
803
806
|
if self.__weel_state == :stopping || self.__weel_state == :finishing
|
|
804
|
-
|
|
805
|
-
wp.passthrough =
|
|
807
|
+
connectionwrapper.activity_stop
|
|
808
|
+
wp.passthrough = connectionwrapper.activity_passthrough_value
|
|
806
809
|
raise Signal::Proceed if wp.passthrough # if stop, but no passthrough, let manipulate happen and then stop
|
|
807
810
|
end
|
|
808
811
|
|
|
@@ -814,26 +817,26 @@ class WEEL
|
|
|
814
817
|
finalize
|
|
815
818
|
end
|
|
816
819
|
if code.is_a?(Proc) || code.is_a?(String)
|
|
817
|
-
|
|
820
|
+
connectionwrapper.inform_activity_manipulate
|
|
818
821
|
if code.is_a?(Proc)
|
|
819
|
-
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,
|
|
822
|
+
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
|
|
820
823
|
ma = catch Signal::Again do
|
|
821
824
|
case code.arity
|
|
822
|
-
when 1; mr.instance_exec(
|
|
823
|
-
when 2; mr.instance_exec(
|
|
825
|
+
when 1; mr.instance_exec(connectionwrapper.activity_result_value,&code)
|
|
826
|
+
when 2; mr.instance_exec(connectionwrapper.activity_result_value,&code)
|
|
824
827
|
else
|
|
825
828
|
mr.instance_exec(&code)
|
|
826
829
|
end
|
|
827
830
|
'yes' # ma sadly will have nil when i just throw
|
|
828
831
|
end
|
|
829
832
|
elsif code.is_a?(String)
|
|
830
|
-
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,
|
|
833
|
+
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
|
|
831
834
|
ma = catch Signal::Again do
|
|
832
|
-
|
|
835
|
+
connectionwrapper.manipulate(mr,code,connectionwrapper.activity_result_value,connectionwrapper.activity_result_options)
|
|
833
836
|
'yes' # ma sadly will have nil when i just throw
|
|
834
837
|
end
|
|
835
838
|
end
|
|
836
|
-
|
|
839
|
+
connectionwrapper.inform_manipulate_change(
|
|
837
840
|
(mr.changed_status ? @__weel_status : nil),
|
|
838
841
|
(mr.changed_data.any? ? mr.changed_data.uniq : nil),
|
|
839
842
|
(mr.changed_endpoints.any? ? mr.changed_endpoints.uniq : nil),
|
|
@@ -843,18 +846,18 @@ class WEEL
|
|
|
843
846
|
throw(Signal::Again, Signal::Again) if ma.nil?
|
|
844
847
|
end
|
|
845
848
|
end while waitingresult == Signal::Again
|
|
846
|
-
if
|
|
847
|
-
|
|
849
|
+
if connectionwrapper.activity_passthrough_value.nil?
|
|
850
|
+
connectionwrapper.inform_activity_done
|
|
848
851
|
wp.passthrough = nil
|
|
849
852
|
wp.detail = :after
|
|
850
|
-
@
|
|
853
|
+
@__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :after => [wp]
|
|
851
854
|
end
|
|
852
855
|
end
|
|
853
856
|
end while again == Signal::Again
|
|
854
857
|
end
|
|
855
858
|
raise Signal::Proceed
|
|
856
859
|
rescue Signal::SkipManipulate, Signal::Proceed
|
|
857
|
-
if self.__weel_state != :stopping && self.__weel_state != :finishing && !
|
|
860
|
+
if self.__weel_state != :stopping && self.__weel_state != :finishing && !connectionwrapper.vote_sync_after
|
|
858
861
|
self.__weel_state = :stopping
|
|
859
862
|
wp.detail = :unmark
|
|
860
863
|
end
|
|
@@ -862,19 +865,19 @@ class WEEL
|
|
|
862
865
|
@__weel_positions.delete wp
|
|
863
866
|
Thread.current[:branch_position] = nil
|
|
864
867
|
wp.detail = :unmark
|
|
865
|
-
@
|
|
868
|
+
@__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :unmark => [wp]
|
|
866
869
|
rescue Signal::StopSkipManipulate, Signal::Stop
|
|
867
870
|
self.__weel_state = :stopping
|
|
868
871
|
rescue Signal::Skip
|
|
869
872
|
nil
|
|
870
873
|
rescue SyntaxError => se
|
|
871
|
-
|
|
874
|
+
connectionwrapper.inform_activity_failed se
|
|
872
875
|
self.__weel_state = :stopping
|
|
873
876
|
rescue => err
|
|
874
|
-
@
|
|
877
|
+
@__weel_connectionwrapper::inform_connectionwrapper_error @__weel_connectionwrapper_args, err
|
|
875
878
|
self.__weel_state = :stopping
|
|
876
879
|
ensure
|
|
877
|
-
|
|
880
|
+
connectionwrapper.mem_guard unless connectionwrapper.nil?
|
|
878
881
|
if Thread.current[:branch_parent]
|
|
879
882
|
Thread.current[:branch_parent][:mutex].synchronize do
|
|
880
883
|
if Thread.current[:branch_parent][:branch_wait_count_cancel_condition] == :first
|
|
@@ -938,7 +941,7 @@ class WEEL
|
|
|
938
941
|
position
|
|
939
942
|
else
|
|
940
943
|
self.__weel_state = :stopping
|
|
941
|
-
@
|
|
944
|
+
@__weel_connectionwrapper::inform_syntax_error(@__weel_connectionwrapper_args,Exception.new("position (#{position}) not valid"),nil)
|
|
942
945
|
end
|
|
943
946
|
end # }}}
|
|
944
947
|
|
|
@@ -967,13 +970,13 @@ class WEEL
|
|
|
967
970
|
def __weel_sim_start(what,options={}) #{{{
|
|
968
971
|
current_branch_sim_pos = Thread.current[:branch_sim_pos]
|
|
969
972
|
Thread.current[:branch_sim_pos] = @__weel_sim += 1
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
[
|
|
973
|
+
connectionwrapper = @__weel_connectionwrapper.new @__weel_connectionwrapper_args
|
|
974
|
+
connectionwrapper.simulate(what,:start,Thread.current[:branch_sim_pos],current_branch_sim_pos,options)
|
|
975
|
+
[connectionwrapper, current_branch_sim_pos]
|
|
973
976
|
end #}}}
|
|
974
977
|
|
|
975
|
-
def __weel_sim_stop(what,
|
|
976
|
-
|
|
978
|
+
def __weel_sim_stop(what,connectionwrapper,current_branch_sim_pos,options={}) #{{{
|
|
979
|
+
connectionwrapper.simulate(what,:end,Thread.current[:branch_sim_pos],current_branch_sim_pos,options)
|
|
977
980
|
Thread.current[:branch_sim_pos] = current_branch_sim_pos
|
|
978
981
|
end #}}}
|
|
979
982
|
|
|
@@ -981,7 +984,7 @@ class WEEL
|
|
|
981
984
|
def __weel_finalize #{{{
|
|
982
985
|
__weel_recursive_join(@__weel_main)
|
|
983
986
|
@__weel_state = :stopped
|
|
984
|
-
@
|
|
987
|
+
@__weel_connectionwrapper::inform_state_change @__weel_connectionwrapper_args, @__weel_state
|
|
985
988
|
end #}}}
|
|
986
989
|
|
|
987
990
|
def __weel_state=(newState)# {{{
|
|
@@ -996,7 +999,7 @@ class WEEL
|
|
|
996
999
|
__weel_replay = false
|
|
997
1000
|
end
|
|
998
1001
|
|
|
999
|
-
@
|
|
1002
|
+
@__weel_connectionwrapper::inform_state_change @__weel_connectionwrapper_args, @__weel_state
|
|
1000
1003
|
end # }}}
|
|
1001
1004
|
|
|
1002
1005
|
end # }}}
|
|
@@ -1006,27 +1009,27 @@ public
|
|
|
1006
1009
|
@dslr.__weel_positions
|
|
1007
1010
|
end # }}}
|
|
1008
1011
|
|
|
1009
|
-
# set the
|
|
1010
|
-
def
|
|
1011
|
-
@dslr.
|
|
1012
|
+
# set the connectionwrapper
|
|
1013
|
+
def connectionwrapper # {{{
|
|
1014
|
+
@dslr.__weel_connectionwrapper
|
|
1012
1015
|
end # }}}
|
|
1013
|
-
def
|
|
1014
|
-
superclass =
|
|
1016
|
+
def connectionwrapper=(new_weel_connectionwrapper) # {{{
|
|
1017
|
+
superclass = new_weel_connectionwrapper
|
|
1015
1018
|
while superclass
|
|
1016
|
-
check_ok = true if superclass == WEEL::
|
|
1019
|
+
check_ok = true if superclass == WEEL::ConnectionWrapperBase
|
|
1017
1020
|
superclass = superclass.superclass
|
|
1018
1021
|
end
|
|
1019
|
-
raise "
|
|
1020
|
-
@dslr.
|
|
1022
|
+
raise "ConnectionWrapper is not inherited from ConnectionWrapperBase" unless check_ok
|
|
1023
|
+
@dslr.__weel_connectionwrapper = new_weel_connectionwrapper
|
|
1021
1024
|
end # }}}
|
|
1022
1025
|
|
|
1023
|
-
# Get/Set the
|
|
1024
|
-
def
|
|
1025
|
-
@dslr.
|
|
1026
|
+
# Get/Set the connectionwrapper arguments
|
|
1027
|
+
def connectionwrapper_args # {{{
|
|
1028
|
+
@dslr.__weel_connectionwrapper_args
|
|
1026
1029
|
end # }}}
|
|
1027
|
-
def
|
|
1030
|
+
def connectionwrapper_args=(args) # {{{
|
|
1028
1031
|
if args.class == Array
|
|
1029
|
-
@dslr.
|
|
1032
|
+
@dslr.__weel_connectionwrapper_args = args
|
|
1030
1033
|
end
|
|
1031
1034
|
nil
|
|
1032
1035
|
end # }}}
|
|
@@ -1036,7 +1039,7 @@ public
|
|
|
1036
1039
|
@dslr.__weel_state
|
|
1037
1040
|
end # }}}
|
|
1038
1041
|
def state_signal # {{{
|
|
1039
|
-
|
|
1042
|
+
connectionwrapper::inform_state_change connectionwrapper_args, state
|
|
1040
1043
|
state
|
|
1041
1044
|
end # }}}
|
|
1042
1045
|
def abandon # {{{
|
|
@@ -1100,19 +1103,19 @@ public
|
|
|
1100
1103
|
end
|
|
1101
1104
|
rescue SyntaxError => se
|
|
1102
1105
|
@dslr.__weel_state = :stopping
|
|
1103
|
-
@dslr.
|
|
1106
|
+
@dslr.__weel_connectionwrapper::inform_syntax_error(@dslr.__weel_connectionwrapper_args,Exception.new(se.message),code)
|
|
1104
1107
|
rescue NameError => err # don't look into it, or it will explode
|
|
1105
1108
|
@dslr.__weel_state = :stopping
|
|
1106
|
-
@dslr.
|
|
1109
|
+
@dslr.__weel_connectionwrapper::inform_syntax_error(@dslr.__weel_connectionwrapper_args,Exception.new("main: `#{err.name}` is not a thing that can be used. Maybe it is meant to be a string and you forgot quotes?"),code)
|
|
1107
1110
|
rescue => err
|
|
1108
1111
|
@dslr.__weel_state = :stopping
|
|
1109
|
-
@dslr.
|
|
1112
|
+
@dslr.__weel_connectionwrapper::inform_syntax_error(@dslr.__weel_connectionwrapper_args,Exception.new(err.message),code)
|
|
1110
1113
|
end
|
|
1111
1114
|
if @dslr.__weel_state == :running || @dslr.__weel_state == :finishing
|
|
1112
1115
|
ipc = { :unmark => [] }
|
|
1113
1116
|
@dslr.__weel_positions.each{ |wp| ipc[:unmark] << wp }
|
|
1114
1117
|
@dslr.__weel_positions.clear
|
|
1115
|
-
@dslr.
|
|
1118
|
+
@dslr.__weel_connectionwrapper::inform_position_change(@dslr.__weel_connectionwrapper_args,ipc)
|
|
1116
1119
|
@dslr.__weel_state = :finished
|
|
1117
1120
|
end
|
|
1118
1121
|
if @dslr.__weel_state == :simulating
|
|
@@ -1145,7 +1148,7 @@ public
|
|
|
1145
1148
|
rescue => e
|
|
1146
1149
|
puts e.message
|
|
1147
1150
|
puts e.backtrace
|
|
1148
|
-
|
|
1151
|
+
connectionwrapper::inform_connectionwrapper_error connectionwrapper_args, e
|
|
1149
1152
|
end
|
|
1150
1153
|
end
|
|
1151
1154
|
end # }}}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# Apache License, Version 2.0
|
|
2
|
-
#
|
|
2
|
+
#
|
|
3
3
|
# Copyright (c) 2013 Juergen Mangler
|
|
4
|
-
#
|
|
4
|
+
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
# you may not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
|
-
#
|
|
8
|
+
#
|
|
9
9
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
10
|
+
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing, software
|
|
12
12
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
13
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
@@ -15,18 +15,18 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
|
|
17
17
|
######
|
|
18
|
-
# ADVENTURE Simulation Trace Generator
|
|
18
|
+
# ADVENTURE Simulation Trace Generator Connection Wrapper
|
|
19
19
|
######
|
|
20
20
|
|
|
21
21
|
module TraceBasics #{{{
|
|
22
22
|
def <<(item)
|
|
23
23
|
@elements << item
|
|
24
|
-
item.parent = self
|
|
24
|
+
item.parent = self
|
|
25
25
|
end
|
|
26
26
|
def each
|
|
27
27
|
@elements.each do |ele|
|
|
28
28
|
yield ele
|
|
29
|
-
end
|
|
29
|
+
end
|
|
30
30
|
end
|
|
31
31
|
end #}}}
|
|
32
32
|
|
|
@@ -42,11 +42,11 @@ class Trace #{{{
|
|
|
42
42
|
end
|
|
43
43
|
def recursive_get_container(container,tid)
|
|
44
44
|
return container if container.respond_to?(:tid) and container.tid == tid
|
|
45
|
-
container.each do |ele|
|
|
45
|
+
container.each do |ele|
|
|
46
46
|
if ele.kind_of?(TraceContainer)
|
|
47
|
-
ret = recursive_get_container(ele,tid)
|
|
47
|
+
ret = recursive_get_container(ele,tid)
|
|
48
48
|
return ret unless ret.nil?
|
|
49
|
-
end
|
|
49
|
+
end
|
|
50
50
|
end
|
|
51
51
|
nil
|
|
52
52
|
end
|
|
@@ -79,7 +79,7 @@ class Trace #{{{
|
|
|
79
79
|
tmp = recursive_generate_list(ele,options)
|
|
80
80
|
add_traces(traces,tmp)
|
|
81
81
|
options[:otherwise] = true
|
|
82
|
-
end
|
|
82
|
+
end
|
|
83
83
|
end
|
|
84
84
|
traces
|
|
85
85
|
end
|
|
@@ -137,7 +137,7 @@ class TraceChoose < TraceContainer
|
|
|
137
137
|
def initialize(tid,mode)
|
|
138
138
|
super tid
|
|
139
139
|
@mode = mode
|
|
140
|
-
end
|
|
140
|
+
end
|
|
141
141
|
end
|
|
142
142
|
class TraceAlternative < TraceContainer; end
|
|
143
143
|
class TraceOtherwise < TraceContainer; end
|
|
@@ -145,10 +145,10 @@ class TraceOtherwise < TraceContainer; end
|
|
|
145
145
|
class PlainTrace
|
|
146
146
|
def initialize
|
|
147
147
|
@container
|
|
148
|
-
end
|
|
148
|
+
end
|
|
149
149
|
end
|
|
150
150
|
|
|
151
|
-
class
|
|
151
|
+
class SimConnectionWrapper < WEEL::ConnectionWrapperBase
|
|
152
152
|
def initialize(args,endpoint=nil,position=nil,continue=nil)
|
|
153
153
|
@__myhandler_stopped = false
|
|
154
154
|
@__myhandler_position = position
|
|
@@ -172,19 +172,19 @@ class SimHandlerWrapper < WEEL::HandlerWrapperBase
|
|
|
172
172
|
clast = $trace.get_container(parent)
|
|
173
173
|
until clast.kind_of?(TraceParallel)
|
|
174
174
|
clast = clast.parent
|
|
175
|
-
end
|
|
175
|
+
end
|
|
176
176
|
clast << TraceParallelBranch.new(tid,parent)
|
|
177
177
|
else
|
|
178
178
|
clast = $trace.get_container(tid)
|
|
179
179
|
clast.close! if clast.open?
|
|
180
|
-
end
|
|
180
|
+
end
|
|
181
181
|
when :choose
|
|
182
182
|
simulate_add_to_container($trace,nesting,parent,tid) { TraceChoose.new(tid,parameters[:mode]) }
|
|
183
183
|
when :alternative
|
|
184
184
|
simulate_add_to_container($trace,nesting,parent,tid) { TraceAlternative.new(tid) }
|
|
185
185
|
when :otherwise
|
|
186
186
|
simulate_add_to_container($trace,nesting,parent,tid) { TraceOtherwise.new(tid) }
|
|
187
|
-
end
|
|
187
|
+
end
|
|
188
188
|
end
|
|
189
189
|
|
|
190
190
|
private
|
|
@@ -196,7 +196,7 @@ class SimHandlerWrapper < WEEL::HandlerWrapperBase
|
|
|
196
196
|
else
|
|
197
197
|
clast = trace.get_container(tid)
|
|
198
198
|
clast.close! if clast.open?
|
|
199
|
-
end
|
|
199
|
+
end
|
|
200
200
|
end #}}}
|
|
201
201
|
|
|
202
202
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class TestConnectionWrapper < WEEL::ConnectionWrapperBase
|
|
2
2
|
def self::inform_state_change(arguments,newstate)
|
|
3
3
|
$long_track += "---> STATE #{newstate}\n"
|
|
4
4
|
$short_track << "|#{newstate}|"
|
|
@@ -8,7 +8,7 @@ class TestHandlerWrapper < WEEL::HandlerWrapperBase
|
|
|
8
8
|
$short_track << "E"
|
|
9
9
|
raise(err)
|
|
10
10
|
end
|
|
11
|
-
def self::
|
|
11
|
+
def self::inform_connectionwrapper_error(arguments,err)
|
|
12
12
|
$long_track += "HW ERROR: #{err}\n"
|
|
13
13
|
$short_track << "E"
|
|
14
14
|
end
|
data/test/TestWorkflow.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
require File.expand_path(::File.dirname(__FILE__) + '/../lib/weel')
|
|
2
2
|
require File.expand_path(::File.dirname(__FILE__) + '/TestMixin')
|
|
3
|
-
require File.expand_path(::File.dirname(__FILE__) + '/
|
|
3
|
+
require File.expand_path(::File.dirname(__FILE__) + '/TestConnectionWrapper')
|
|
4
4
|
|
|
5
5
|
class TestWorkflow < WEEL
|
|
6
|
-
|
|
6
|
+
connectionwrapper TestConnectionWrapper
|
|
7
7
|
|
|
8
8
|
endpoint :endpoint1 => 'http://www.heise.de'
|
|
9
9
|
endpoint :stop => 'stop it'
|
data/test/basic/tc_handler.rb
CHANGED
|
@@ -6,14 +6,14 @@ class TestCaseHandler < Test::Unit::TestCase
|
|
|
6
6
|
|
|
7
7
|
def test_handler
|
|
8
8
|
assert_raise RuntimeError do
|
|
9
|
-
@wf.
|
|
9
|
+
@wf.connectionwrapper = String
|
|
10
10
|
end
|
|
11
11
|
assert_nothing_raised do
|
|
12
|
-
@wf.
|
|
12
|
+
@wf.connectionwrapper = TestConnectionWrapper
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
def test_handlerargs
|
|
16
|
-
@wf.
|
|
17
|
-
assert(@wf.
|
|
16
|
+
@wf.connectionwrapper_args = ["1", "2"]
|
|
17
|
+
assert(@wf.connectionwrapper_args.is_a?(Array), "Handler arguments is not an array, it is a #{@wf.connectionwrapper_args.inspect}")
|
|
18
18
|
end
|
|
19
19
|
end
|
data/weel.gemspec
CHANGED
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.
|
|
4
|
+
version: 1.99.99
|
|
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: 2021-05-
|
|
12
|
+
date: 2021-05-19 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: test-unit
|
|
@@ -45,8 +45,8 @@ files:
|
|
|
45
45
|
- lib/weel.rb
|
|
46
46
|
- test/ContinueTest.rb
|
|
47
47
|
- test/README
|
|
48
|
-
- test/
|
|
49
|
-
- test/
|
|
48
|
+
- test/SimConnectionWrapper.rb
|
|
49
|
+
- test/TestConnectionWrapper.rb
|
|
50
50
|
- test/TestMixin.rb
|
|
51
51
|
- test/TestWorkflow.rb
|
|
52
52
|
- test/basic/tc_choose.rb
|
|
@@ -106,12 +106,12 @@ signing_key:
|
|
|
106
106
|
specification_version: 4
|
|
107
107
|
summary: Workflow Execution Engine Library (WEEL)
|
|
108
108
|
test_files:
|
|
109
|
-
- test/TestHandlerWrapper.rb
|
|
110
109
|
- test/test
|
|
111
110
|
- test/ContinueTest.rb
|
|
112
111
|
- test/TestWorkflow.rb
|
|
113
112
|
- test/TestMixin.rb
|
|
114
|
-
- test/
|
|
113
|
+
- test/TestConnectionWrapper.rb
|
|
114
|
+
- test/SimConnectionWrapper.rb
|
|
115
115
|
- test/README
|
|
116
116
|
- test/wfp_iteration/tc_structuredloop.rb
|
|
117
117
|
- test/wfp_adv_branching/tc_structured_partial_join.rb
|