Add debugging option to make bus warnings throw Error; bump version
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
||||
EventHandlerReturn,
|
||||
EventHandlerSubscription,
|
||||
} from './types'
|
||||
import {Awaitable, Collection, Pipeline, uuid4} from '../../util'
|
||||
import {Awaitable, Collection, ifDebugging, Pipeline, uuid4} from '../../util'
|
||||
import {Logging} from '../../service/Logging'
|
||||
import {Unit} from '../../lifecycle/Unit'
|
||||
import {Config} from '../../service/Config'
|
||||
@@ -185,6 +185,9 @@ export class Bus<TEvent extends Event = Event> extends Unit implements EventBus<
|
||||
async up(): Promise<void> {
|
||||
if ( this.isUp ) {
|
||||
this.logging.warn('Attempted to boot more than once. Skipping.')
|
||||
ifDebugging('extollo.bus', () => {
|
||||
throw new Error('Attempted to boot more than once. Skipping.')
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Inject, Injectable, StaticInstantiable} from '../../di'
|
||||
import {BusSubscriber, Event, EventBus, EventHandler, EventHandlerReturn, EventHandlerSubscription} from './types'
|
||||
import {Awaitable, Collection, Pipeline, uuid4} from '../../util'
|
||||
import {Awaitable, Collection, ifDebugging, Pipeline, uuid4} from '../../util'
|
||||
import {Logging} from '../../service/Logging'
|
||||
import {Bus, BusInternalSubscription} from './Bus'
|
||||
import {getEventName} from './getEventName'
|
||||
@@ -109,6 +109,9 @@ export class LocalBus<TEvent extends Event = Event> extends CanonicalItemClass i
|
||||
async up(): Promise<void> {
|
||||
if ( this.isUp ) {
|
||||
this.logging.warn('Attempted to boot more than once. Skipping.')
|
||||
ifDebugging('extollo.bus', () => {
|
||||
throw new Error('Attempted to boot more than once. Skipping.')
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user