@@ -333,17 +333,19 @@ export class Host implements IComponent {
333333 * @param {Instance } instance Instance data.
334334 */
335335 async handleDispatcherEstablishedEvent ( instance : Instance ) {
336- const seq = this . sequenceStore . getById ( instance . sequence . id ) ;
337-
338336 this . logger . info ( "Checking Sequence..." ) ;
339337
338+ const seq = this . sequenceStore . getById ( instance . sequence . id ) ;
339+
340340 if ( ! seq ) {
341341 this . logger . info ( "Sequence not found. Checking Store..." ) ;
342342
343343 try {
344- await this . getExternalSequence ( instance . sequence . id ) ;
344+ const extSeq = await this . getExternalSequence ( instance . sequence . id ) ;
345+
346+ this . logger . info ( "Sequence acquired." , extSeq ) ;
345347 } catch ( e ) {
346- this . logger . warn ( "Sequence not found in store . Instance has no Sequence." ) ;
348+ this . logger . warn ( "Sequence not found in Store . Instance has no Sequence." ) ;
347349 }
348350 }
349351
@@ -594,7 +596,22 @@ export class Host implements IComponent {
594596 connector . init ( ) ;
595597
596598 connector . on ( "connect" , async ( ) => {
597- await connector . sendSequencesInfo ( this . getSequences ( ) ) ;
599+ await defer ( 3000 ) ;
600+ //await connector.sendSequencesInfo(this.getSequences());
601+ await Promise . all (
602+ this . getSequences ( )
603+ . map (
604+ s =>
605+ connector . sendSequenceInfo (
606+ s . id ,
607+ SequenceMessageCode . SEQUENCE_CREATED ,
608+ {
609+ ...s . config ,
610+ location : this . getId ( ) !
611+ } as unknown as STHRestAPI . GetSequenceResponse
612+ )
613+ )
614+ ) ;
598615 await connector . sendInstancesInfo ( this . getInstances ( ) ) ;
599616 await connector . sendTopicsInfo ( this . getTopics ( ) ) ;
600617
@@ -998,6 +1015,8 @@ export class Host implements IComponent {
9981015 }
9991016
10001017 async getExternalSequence ( id : string ) : Promise < SequenceInfo > {
1018+ this . logger . info ( "Requesting Sequence from external source" ) ;
1019+
10011020 let packageStream : IncomingMessage | undefined ;
10021021
10031022 try {
@@ -1021,7 +1040,7 @@ export class Host implements IComponent {
10211040
10221041 return this . sequenceStore . getById ( result . id ) ! ;
10231042 } catch ( e : any ) {
1024- this . logger . error ( "Error requesting sequence ", e . message ) ;
1043+ this . logger . warn ( "Can't aquire Sequence from external source ", e . message ) ;
10251044
10261045 throw new Error ( ReasonPhrases . NOT_FOUND ) ;
10271046 }
0 commit comments