Prevent request Bus instances from creating new IORedis connections
This commit is contained in:
@@ -19,7 +19,7 @@ export class InjectRequestEventBusHTTPModule extends HTTPKernelModule {
|
||||
|
||||
public async apply(request: Request): Promise<Request> {
|
||||
const requestBus = this.container().makeNew<Bus>(Bus)
|
||||
await requestBus.up()
|
||||
await requestBus.up(false)
|
||||
await requestBus.connect(this.bus)
|
||||
|
||||
request.purge(Bus).registerProducer(Bus, () => requestBus)
|
||||
|
||||
@@ -188,7 +188,7 @@ export class Bus<TEvent extends Event = Event> extends Unit implements EventBus<
|
||||
}
|
||||
|
||||
/** Initialize this event bus. */
|
||||
async up(): Promise<void> {
|
||||
async up(createUpstreamFromConfig = true): Promise<void> {
|
||||
if ( this.isUp ) {
|
||||
this.logging.warn('Attempted to boot more than once. Skipping.')
|
||||
ifDebugging('extollo.bus', () => {
|
||||
@@ -198,12 +198,14 @@ export class Bus<TEvent extends Event = Event> extends Unit implements EventBus<
|
||||
}
|
||||
|
||||
// Read the connectors from the server.bus config and set them up
|
||||
const config = this.config.get('server.bus', {})
|
||||
if ( Array.isArray(config.connectors) ) {
|
||||
for ( const connector of (config.connectors as BusConnectorConfig[]) ) {
|
||||
this.logging.verbose(`Creating bus connection of type: ${connector.type}`)
|
||||
if ( connector.type === 'redis' ) {
|
||||
await this.connect(this.make(RedisBus))
|
||||
if ( createUpstreamFromConfig ) {
|
||||
const config = this.config.get('server.bus', {})
|
||||
if ( Array.isArray(config.connectors) ) {
|
||||
for ( const connector of (config.connectors as BusConnectorConfig[]) ) {
|
||||
this.logging.verbose(`Creating bus connection of type: ${connector.type}`)
|
||||
if ( connector.type === 'redis' ) {
|
||||
await this.connect(this.make(RedisBus))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user