Refactor event bus and queue system; detect cycles in DI realization and make
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import {Directive, OptionDefinition} from '../../cli'
|
||||
import {Directive, OptionDefinition, CLIDirective} from '../../cli'
|
||||
import {Container, Inject, Injectable} from '../../di'
|
||||
import {EventBus} from '../../event/EventBus'
|
||||
import {Collection} from '../../util'
|
||||
import {Bus, EventHandlerSubscription} from '../../support/bus'
|
||||
import {Migrations} from '../services/Migrations'
|
||||
import {Migrator} from '../migrations/Migrator'
|
||||
import {ApplyingMigrationEvent} from '../migrations/events/ApplyingMigrationEvent'
|
||||
import {AppliedMigrationEvent} from '../migrations/events/AppliedMigrationEvent'
|
||||
import {EventSubscription} from '../../event/types'
|
||||
import {NothingToMigrateError} from '../migrations/NothingToMigrateError'
|
||||
import {CLIDirective} from '../../cli/decorators'
|
||||
|
||||
/**
|
||||
* CLI directive that applies migrations using the default Migrator.
|
||||
@@ -17,13 +16,13 @@ import {CLIDirective} from '../../cli/decorators'
|
||||
@CLIDirective()
|
||||
export class MigrateDirective extends Directive {
|
||||
@Inject()
|
||||
protected readonly bus!: EventBus
|
||||
protected readonly bus!: Bus
|
||||
|
||||
@Inject('injector')
|
||||
protected readonly injector!: Container
|
||||
|
||||
/** Event bus subscriptions. */
|
||||
protected subscriptions: EventSubscription[] = []
|
||||
protected subscriptions: Collection<EventHandlerSubscription> = new Collection()
|
||||
|
||||
getKeywords(): string | string[] {
|
||||
return ['migrate']
|
||||
@@ -113,7 +112,6 @@ export class MigrateDirective extends Directive {
|
||||
|
||||
/** Remove event bus listeners before finish. */
|
||||
protected async removeListeners(): Promise<void> {
|
||||
await Promise.all(this.subscriptions.map(x => x.unsubscribe()))
|
||||
this.subscriptions = []
|
||||
await this.subscriptions.awaitMapCall('unsubscribe')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import {Directive, OptionDefinition} from '../../cli'
|
||||
import {Directive, OptionDefinition, CLIDirective} from '../../cli'
|
||||
import {Container, Inject, Injectable} from '../../di'
|
||||
import {EventBus} from '../../event/EventBus'
|
||||
import {Collection} from '../../util'
|
||||
import {Bus, EventHandlerSubscription} from '../../support/bus'
|
||||
import {Migrator} from '../migrations/Migrator'
|
||||
import {Migrations} from '../services/Migrations'
|
||||
import {RollingBackMigrationEvent} from '../migrations/events/RollingBackMigrationEvent'
|
||||
import {RolledBackMigrationEvent} from '../migrations/events/RolledBackMigrationEvent'
|
||||
import {EventSubscription} from '../../event/types'
|
||||
import {NothingToMigrateError} from '../migrations/NothingToMigrateError'
|
||||
import {CLIDirective} from '../../cli/decorators'
|
||||
|
||||
/**
|
||||
* CLI directive that undoes applied migrations using the default Migrator.
|
||||
@@ -17,7 +16,7 @@ import {CLIDirective} from '../../cli/decorators'
|
||||
@CLIDirective()
|
||||
export class RollbackDirective extends Directive {
|
||||
@Inject()
|
||||
protected readonly bus!: EventBus
|
||||
protected readonly bus!: Bus
|
||||
|
||||
@Inject('injector')
|
||||
protected readonly injector!: Container
|
||||
@@ -26,7 +25,7 @@ export class RollbackDirective extends Directive {
|
||||
protected readonly migrations!: Migrations
|
||||
|
||||
/** Event bus subscriptions. */
|
||||
protected subscriptions: EventSubscription[] = []
|
||||
protected subscriptions: Collection<EventHandlerSubscription> = new Collection()
|
||||
|
||||
getKeywords(): string | string[] {
|
||||
return ['rollback']
|
||||
@@ -98,7 +97,6 @@ export class RollbackDirective extends Directive {
|
||||
|
||||
/** Remove event bus listeners before finish. */
|
||||
protected async removeListeners(): Promise<void> {
|
||||
await Promise.all(this.subscriptions.map(x => x.unsubscribe()))
|
||||
this.subscriptions = []
|
||||
await this.subscriptions.awaitMapCall('unsubscribe')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user