@nestjs/microservices
Advanced tools
Comparing version 5.3.2 to 5.3.4
@@ -0,1 +1,2 @@ | ||
import { Logger } from '@nestjs/common/services/logger.service'; | ||
import { Observable } from 'rxjs'; | ||
@@ -6,6 +7,6 @@ import { ClientGrpc } from '../interfaces'; | ||
export declare class ClientGrpcProxy extends ClientProxy implements ClientGrpc { | ||
private readonly options; | ||
private readonly logger; | ||
private readonly url; | ||
private grpcClient; | ||
protected readonly options: ClientOptions['options']; | ||
protected readonly logger: Logger; | ||
protected readonly url: string; | ||
protected grpcClient: any; | ||
constructor(options: ClientOptions['options']); | ||
@@ -12,0 +13,0 @@ getService<T extends {}>(name: string): T; |
@@ -0,1 +1,3 @@ | ||
import { Logger } from '@nestjs/common/services/logger.service'; | ||
import { Observable } from 'rxjs'; | ||
import { MqttClient } from '../external/mqtt-client.interface'; | ||
@@ -6,6 +8,7 @@ import { PacketId, ReadPacket, WritePacket } from '../interfaces'; | ||
export declare class ClientMqtt extends ClientProxy { | ||
private readonly options; | ||
private readonly logger; | ||
private readonly url; | ||
private mqttClient; | ||
protected readonly options: ClientOptions['options']; | ||
protected readonly logger: Logger; | ||
protected readonly url: string; | ||
protected mqttClient: MqttClient; | ||
protected connection: Promise<any>; | ||
constructor(options: ClientOptions['options']); | ||
@@ -16,2 +19,3 @@ getAckPatternName(pattern: string): string; | ||
connect(): Promise<any>; | ||
mergeCloseEvent<T = any>(instance: MqttClient, source$: Observable<T>): Observable<T>; | ||
createClient(): MqttClient; | ||
@@ -18,0 +22,0 @@ handleError(client: MqttClient): void; |
@@ -5,2 +5,4 @@ "use strict"; | ||
const load_package_util_1 = require("@nestjs/common/utils/load-package.util"); | ||
const rxjs_1 = require("rxjs"); | ||
const operators_1 = require("rxjs/operators"); | ||
const constants_1 = require("../constants"); | ||
@@ -28,11 +30,22 @@ const client_proxy_1 = require("./client-proxy"); | ||
this.mqttClient = null; | ||
this.connection = null; | ||
} | ||
connect() { | ||
if (this.mqttClient) { | ||
return Promise.resolve(); | ||
return this.connection; | ||
} | ||
this.mqttClient = this.createClient(); | ||
this.handleError(this.mqttClient); | ||
return this.connect$(this.mqttClient).toPromise(); | ||
const connect$ = this.connect$(this.mqttClient); | ||
this.connection = this.mergeCloseEvent(this.mqttClient, connect$) | ||
.pipe(operators_1.share()) | ||
.toPromise(); | ||
return this.connection; | ||
} | ||
mergeCloseEvent(instance, source$) { | ||
const close$ = rxjs_1.fromEvent(instance, constants_1.CLOSE_EVENT).pipe(operators_1.map(err => { | ||
throw err; | ||
})); | ||
return rxjs_1.merge(source$, close$).pipe(operators_1.first()); | ||
} | ||
createClient() { | ||
@@ -39,0 +52,0 @@ return mqttPackage.connect(this.url, this.options); |
@@ -0,1 +1,2 @@ | ||
import { Logger } from '@nestjs/common/services/logger.service'; | ||
import { Client } from '../external/nats-client.interface'; | ||
@@ -6,10 +7,11 @@ import { PacketId, ReadPacket, WritePacket } from '../interfaces'; | ||
export declare class ClientNats extends ClientProxy { | ||
private readonly options; | ||
private readonly logger; | ||
private readonly url; | ||
private natsClient; | ||
protected readonly options: ClientOptions['options']; | ||
protected readonly logger: Logger; | ||
protected readonly url: string; | ||
protected natsClient: Client; | ||
protected connection: Promise<any>; | ||
constructor(options: ClientOptions['options']); | ||
close(): void; | ||
connect(): Promise<any>; | ||
createClient(): Promise<Client>; | ||
createClient(): Client; | ||
handleError(client: Client): void; | ||
@@ -16,0 +18,0 @@ createSubscriptionHandler(packet: ReadPacket & PacketId, callback: (packet: WritePacket) => any): Function; |
@@ -5,2 +5,3 @@ "use strict"; | ||
const load_package_util_1 = require("@nestjs/common/utils/load-package.util"); | ||
const operators_1 = require("rxjs/operators"); | ||
const constants_1 = require("../constants"); | ||
@@ -22,10 +23,14 @@ const client_proxy_1 = require("./client-proxy"); | ||
this.natsClient = null; | ||
this.connection = null; | ||
} | ||
async connect() { | ||
if (this.natsClient) { | ||
return Promise.resolve(); | ||
return this.connection; | ||
} | ||
this.natsClient = await this.createClient(); | ||
this.natsClient = this.createClient(); | ||
this.handleError(this.natsClient); | ||
return this.connect$(this.natsClient).toPromise(); | ||
this.connection = await this.connect$(this.natsClient) | ||
.pipe(operators_1.share()) | ||
.toPromise(); | ||
return this.connection; | ||
} | ||
@@ -32,0 +37,0 @@ createClient() { |
@@ -0,1 +1,2 @@ | ||
import { Logger } from '@nestjs/common/services/logger.service'; | ||
import { Subject } from 'rxjs'; | ||
@@ -7,7 +8,7 @@ import { ClientOpts, RedisClient, RetryStrategyOptions } from '../external/redis.interface'; | ||
export declare class ClientRedis extends ClientProxy { | ||
private readonly options; | ||
private readonly logger; | ||
private readonly url; | ||
private pubClient; | ||
private subClient; | ||
protected readonly options: ClientOptions['options']; | ||
protected readonly logger: Logger; | ||
protected readonly url: string; | ||
protected pubClient: RedisClient; | ||
protected subClient: RedisClient; | ||
private isExplicitlyTerminated; | ||
@@ -14,0 +15,0 @@ constructor(options: ClientOptions['options']); |
{ | ||
"name": "@nestjs/microservices", | ||
"version": "5.3.2", | ||
"version": "5.3.4", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@microservices)", | ||
@@ -5,0 +5,0 @@ "author": "Kamil Mysliwiec", |
138248
3132