Prevent request Bus instances from creating new IORedis connections

orm-types
Garrett Mills 2 years ago
parent b42e91533a
commit 351a2e14b8

@ -1,6 +1,6 @@
{
"name": "@extollo/lib",
"version": "0.9.17",
"version": "0.9.18",
"description": "The framework library that lifts up your code.",
"main": "lib/index.js",
"types": "lib/index.d.ts",

@ -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))
}
}
}
}

Loading…
Cancel
Save