1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.ClientProxyFactory = void 0;
|
4 | const transport_enum_1 = require("../enums/transport.enum");
|
5 | const client_grpc_1 = require("./client-grpc");
|
6 | const client_kafka_1 = require("./client-kafka");
|
7 | const client_mqtt_1 = require("./client-mqtt");
|
8 | const client_nats_1 = require("./client-nats");
|
9 | const client_redis_1 = require("./client-redis");
|
10 | const client_rmq_1 = require("./client-rmq");
|
11 | const client_tcp_1 = require("./client-tcp");
|
12 | class ClientProxyFactory {
|
13 | static create(clientOptions) {
|
14 | if (this.isCustomClientOptions(clientOptions)) {
|
15 | const { customClass, options } = clientOptions;
|
16 | return new customClass(options);
|
17 | }
|
18 | const { transport, options } = clientOptions || {};
|
19 | switch (transport) {
|
20 | case transport_enum_1.Transport.REDIS:
|
21 | return new client_redis_1.ClientRedis(options);
|
22 | case transport_enum_1.Transport.NATS:
|
23 | return new client_nats_1.ClientNats(options);
|
24 | case transport_enum_1.Transport.MQTT:
|
25 | return new client_mqtt_1.ClientMqtt(options);
|
26 | case transport_enum_1.Transport.GRPC:
|
27 | return new client_grpc_1.ClientGrpcProxy(options);
|
28 | case transport_enum_1.Transport.RMQ:
|
29 | return new client_rmq_1.ClientRMQ(options);
|
30 | case transport_enum_1.Transport.KAFKA:
|
31 | return new client_kafka_1.ClientKafka(options);
|
32 | default:
|
33 | return new client_tcp_1.ClientTCP(options);
|
34 | }
|
35 | }
|
36 | static isCustomClientOptions(options) {
|
37 | return !!options.customClass;
|
38 | }
|
39 | }
|
40 | exports.ClientProxyFactory = ClientProxyFactory;
|