refactor(core): Make PruningService.init and WaitTracker.init consistent (no-changelog) (#9761)

This commit is contained in:
Iván Ovejero
2024-06-17 12:49:40 +02:00
committed by GitHub
parent 7c70b782a1
commit f7352b6a8f
5 changed files with 43 additions and 30 deletions

View File

@@ -30,19 +30,19 @@ export class WaitTracker {
private readonly orchestrationService: OrchestrationService,
) {}
/**
* @important Requires `OrchestrationService` to be initialized.
*/
init() {
const { isSingleMainSetup, isLeader, multiMainSetup } = this.orchestrationService;
if (isSingleMainSetup) {
this.startTracking();
return;
}
const { isLeader, isMultiMainSetupEnabled } = this.orchestrationService;
if (isLeader) this.startTracking();
multiMainSetup
.on('leader-takeover', () => this.startTracking())
.on('leader-stepdown', () => this.stopTracking());
if (isMultiMainSetupEnabled) {
this.orchestrationService.multiMainSetup
.on('leader-takeover', () => this.startTracking())
.on('leader-stepdown', () => this.stopTracking());
}
}
private startTracking() {