@@ -360,6 +360,7 @@ export class Host implements IComponent {
360
360
await this . startCSIController ( sequence , {
361
361
appConfig : seqenceConfig . appConfig || { } ,
362
362
args : seqenceConfig . args ,
363
+ instanceId : seqenceConfig . instanceId
363
364
} ) ;
364
365
this . logger . debug ( "Starting sequence based on config" , seqenceConfig ) ;
365
366
} )
@@ -488,9 +489,6 @@ export class Host implements IComponent {
488
489
}
489
490
490
491
topicsMiddleware ( req : ParsedMessage , res : ServerResponse , next : NextCallback ) {
491
- req . socket ?. setTimeout ( 0 ) ;
492
- req . socket ?. setNoDelay ( true ) ;
493
-
494
492
req . url = req . url ?. substring ( this . topicsBase . length ) ;
495
493
496
494
return this . serviceDiscovery . router . lookup ( req , res , next ) ;
@@ -861,7 +859,7 @@ export class Host implements IComponent {
861
859
*/
862
860
async startCSIController ( sequence : SequenceInfo , payload : STHRestAPI . StartSequencePayload ) : Promise < CSIController > {
863
861
const communicationHandler = new CommunicationHandler ( ) ;
864
- const id = IDProvider . generate ( ) ;
862
+ const id = payload . instanceId || IDProvider . generate ( ) ;
865
863
866
864
this . logger . debug ( "CSIC start payload" , payload ) ;
867
865
@@ -880,64 +878,33 @@ export class Host implements IComponent {
880
878
} ) ;
881
879
882
880
csic . on ( "pang" , async ( data ) => {
883
- // @TODO REFACTOR possibly send only one PANG in Runner and throw on more pangs
884
881
this . logger . trace ( "PANG received" , data ) ;
885
882
886
- // On First empty PANG
887
- if ( ! data . requires && ! data . provides ) {
888
- if ( csic . inputTopic ) {
889
- this . logger . trace ( "Routing topic to Sequence input, name from API:" , csic . inputTopic ) ;
890
-
891
- csic . requires = csic . inputTopic ;
892
-
893
- await this . serviceDiscovery . routeTopicToStream (
894
- { topic : csic . inputTopic , contentType : "" } ,
895
- csic . getInputStream ( )
896
- ) ;
897
- }
898
-
899
- if ( csic . outputTopic ) {
900
- this . logger . trace ( "Routing Sequence output to topic, name from API" , csic . outputTopic ) ;
901
-
902
- csic . provides = csic . outputTopic ;
903
-
904
- // @TODO use pang data for contentType, right now it's a bit tricky bc there are multiple pangs
905
- await this . serviceDiscovery . routeStreamToTopic (
906
- csic . getOutputStream ( ) ,
907
- { topic : csic . outputTopic , contentType : "" } ,
908
- csic . id
909
- ) ;
910
- }
911
- }
912
-
913
- // Do not route original topic to input stream, if --input-topic is specified
914
- if ( ! csic . inputTopic && data . requires ) {
915
- this . logger . trace ( "Routing topic to sequence input, name from Sequence:" , data . requires ) ;
916
-
917
- csic . requires = data . requires ;
883
+ if ( data . requires && ! csic . inputRouted ) {
884
+ this . logger . trace ( "Routing Sequence input to topic" , data . requires ) ;
918
885
919
886
await this . serviceDiscovery . routeTopicToStream (
920
887
{ topic : data . requires , contentType : data . contentType ! } ,
921
888
csic . getInputStream ( )
922
889
) ;
923
890
891
+ csic . inputRouted = true ;
892
+
924
893
await this . serviceDiscovery . update ( {
925
894
requires : data . requires , contentType : data . contentType ! , topicName : data . requires
926
895
} ) ;
927
896
}
928
897
929
- // Do not route output stream to original topic if --output-topic is specified
930
- if ( ! csic . outputTopic && data . provides ) {
931
- this . logger . trace ( "Routing sequence output to topic, name from Sequence" , data . provides ) ;
932
-
933
- csic . provides = data . provides ;
934
-
898
+ if ( data . provides && ! csic . outputRouted ) {
899
+ this . logger . trace ( "Routing Sequence output to topic" , data . requires ) ;
935
900
await this . serviceDiscovery . routeStreamToTopic (
936
901
csic . getOutputStream ( ) ,
937
- { topic : data . provides , contentType : "" } ,
902
+ { topic : data . provides , contentType : data . contentType ! } ,
938
903
csic . id
939
904
) ;
940
905
906
+ csic . outputRouted = true ;
907
+
941
908
await this . serviceDiscovery . update ( {
942
909
provides : data . provides , contentType : data . contentType ! , topicName : data . provides
943
910
} ) ;
@@ -1039,6 +1006,8 @@ export class Host implements IComponent {
1039
1006
* @returns {STHRestAPI.GetSequencesResponse } List of Sequences.
1040
1007
*/
1041
1008
getSequences ( ) : STHRestAPI . GetSequencesResponse {
1009
+ this . logger . info ( "List Sequences" ) ;
1010
+
1042
1011
return Array . from ( this . sequencesStore . values ( ) ) . map ( ( sequence ) => ( {
1043
1012
id : sequence . id ,
1044
1013
name : sequence . name ,
@@ -1067,10 +1036,9 @@ export class Host implements IComponent {
1067
1036
}
1068
1037
1069
1038
getTopics ( ) {
1070
- return this . serviceDiscovery . getTopics ( ) . map ( ( topic ) => ( {
1071
- name : topic . topic ,
1072
- contentType : topic . contentType ,
1073
- } ) ) ;
1039
+ this . logger . info ( "List topics" ) ;
1040
+
1041
+ return this . serviceDiscovery . getTopics ( ) ;
1074
1042
}
1075
1043
1076
1044
getStatus ( ) : STHRestAPI . GetStatusResponse {
0 commit comments