@@ -43,7 +43,6 @@ interface DistributeMainTransactionOptions {
43
43
interface ResolveTransactions {
44
44
incomers : Set < RegisteredIncomer > ;
45
45
backupIncomerTransactions : Transactions < "incomer" > ;
46
- dispatcherTransactions : Transactions < "dispatcher" > ;
47
46
}
48
47
49
48
interface FindISOIncomerOptions {
@@ -151,10 +150,9 @@ export class TransactionHandler<T extends GenericEvent = GenericEvent> {
151
150
this . backupDispatcherTransactionStore . getTransactions ( )
152
151
] ) ;
153
152
154
- let options = {
153
+ let sharedOptions = {
155
154
incomers,
156
- backupIncomerTransactions,
157
- dispatcherTransactions
155
+ backupIncomerTransactions
158
156
} ;
159
157
160
158
const mappedBackupDispatcherTransactions = new Map ( [ ...backupDispatcherTransactions . entries ( ) ]
@@ -167,10 +165,12 @@ export class TransactionHandler<T extends GenericEvent = GenericEvent> {
167
165
return [ id , formatted ] ;
168
166
} ) ) ;
169
167
170
- options = await this . handleBackupIncomerTransactions ( options ) ;
168
+ sharedOptions = await this . handleBackupIncomerTransactions ( sharedOptions ) ;
169
+
170
+ await this . resolvePingTransactions ( dispatcherTransactions ) ;
171
171
172
172
await this . resolveMainTransactions ( {
173
- ...options ,
173
+ ...sharedOptions ,
174
174
dispatcherTransactions : new Map ( [ ...dispatcherTransactions , ...mappedBackupDispatcherTransactions ] )
175
175
} ) ;
176
176
}
@@ -414,7 +414,7 @@ export class TransactionHandler<T extends GenericEvent = GenericEvent> {
414
414
}
415
415
416
416
private async handleBackupIncomerTransactions ( options : ResolveTransactions ) : Promise < ResolveTransactions > {
417
- const { incomers, backupIncomerTransactions, dispatcherTransactions } = options ;
417
+ const { incomers, backupIncomerTransactions } = options ;
418
418
419
419
const toResolve = [ ] ;
420
420
@@ -437,7 +437,7 @@ export class TransactionHandler<T extends GenericEvent = GenericEvent> {
437
437
438
438
await Promise . all ( toResolve ) ;
439
439
440
- return { incomers, backupIncomerTransactions, dispatcherTransactions } ;
440
+ return { incomers, backupIncomerTransactions } ;
441
441
}
442
442
443
443
private findISOIncomer ( options : FindISOIncomerOptions ) : RegisteredIncomer | undefined {
@@ -474,7 +474,22 @@ export class TransactionHandler<T extends GenericEvent = GenericEvent> {
474
474
] ) ;
475
475
}
476
476
477
- private async resolveMainTransactions ( options : ResolveTransactions ) {
477
+ private async resolvePingTransactions ( dispatcherTransactions : Transactions < "dispatcher" > ) {
478
+ for ( const dispatcherTransaction of dispatcherTransactions . values ( ) ) {
479
+ if ( dispatcherTransaction . name === "PING" && dispatcherTransaction . redisMetadata . resolved ) {
480
+ try {
481
+ await this . incomerStore . updateIncomerState ( dispatcherTransaction . redisMetadata . to ) ;
482
+ }
483
+ catch {
484
+ // Do Nothing
485
+ }
486
+
487
+ await this . dispatcherTransactionStore . deleteTransaction ( dispatcherTransaction . redisMetadata . transactionId ) ;
488
+ }
489
+ }
490
+ }
491
+
492
+ private async resolveMainTransactions ( options : ResolveTransactions & { dispatcherTransactions : Transactions < "dispatcher" > } ) {
478
493
const { incomers, backupIncomerTransactions, dispatcherTransactions } = options ;
479
494
480
495
const toResolve = [ ] ;
0 commit comments