Prevent request Bus instances from creating new IORedis connections
This commit is contained in:
parent
b42e91533a
commit
351a2e14b8
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@extollo/lib",
|
"name": "@extollo/lib",
|
||||||
"version": "0.9.17",
|
"version": "0.9.18",
|
||||||
"description": "The framework library that lifts up your code.",
|
"description": "The framework library that lifts up your code.",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
@ -19,7 +19,7 @@ export class InjectRequestEventBusHTTPModule extends HTTPKernelModule {
|
|||||||
|
|
||||||
public async apply(request: Request): Promise<Request> {
|
public async apply(request: Request): Promise<Request> {
|
||||||
const requestBus = this.container().makeNew<Bus>(Bus)
|
const requestBus = this.container().makeNew<Bus>(Bus)
|
||||||
await requestBus.up()
|
await requestBus.up(false)
|
||||||
await requestBus.connect(this.bus)
|
await requestBus.connect(this.bus)
|
||||||
|
|
||||||
request.purge(Bus).registerProducer(Bus, () => requestBus)
|
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. */
|
/** Initialize this event bus. */
|
||||||
async up(): Promise<void> {
|
async up(createUpstreamFromConfig = true): Promise<void> {
|
||||||
if ( this.isUp ) {
|
if ( this.isUp ) {
|
||||||
this.logging.warn('Attempted to boot more than once. Skipping.')
|
this.logging.warn('Attempted to boot more than once. Skipping.')
|
||||||
ifDebugging('extollo.bus', () => {
|
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
|
// Read the connectors from the server.bus config and set them up
|
||||||
const config = this.config.get('server.bus', {})
|
if ( createUpstreamFromConfig ) {
|
||||||
if ( Array.isArray(config.connectors) ) {
|
const config = this.config.get('server.bus', {})
|
||||||
for ( const connector of (config.connectors as BusConnectorConfig[]) ) {
|
if ( Array.isArray(config.connectors) ) {
|
||||||
this.logging.verbose(`Creating bus connection of type: ${connector.type}`)
|
for ( const connector of (config.connectors as BusConnectorConfig[]) ) {
|
||||||
if ( connector.type === 'redis' ) {
|
this.logging.verbose(`Creating bus connection of type: ${connector.type}`)
|
||||||
await this.connect(this.make(RedisBus))
|
if ( connector.type === 'redis' ) {
|
||||||
|
await this.connect(this.make(RedisBus))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user