@hotmeshio/hotmesh
Version:
Serverless Workflow
30 lines (29 loc) • 1.3 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubServiceFactory = void 0;
const utils_1 = require("../../modules/utils");
const redis_1 = require("./providers/redis/redis");
const postgres_1 = require("./providers/postgres/postgres");
const nats_1 = require("./providers/nats/nats");
const ioredis_1 = require("./providers/redis/ioredis");
class SubServiceFactory {
static async init(providerSubClient, providerPubClient, namespace, appId, engineId, logger) {
let service;
const providerType = (0, utils_1.identifyProvider)(providerSubClient);
if (providerType === 'nats') {
service = new nats_1.NatsSubService(providerSubClient, providerPubClient);
}
else if (providerType === 'redis') {
service = new redis_1.RedisSubService(providerSubClient, providerPubClient);
}
else if (providerType === 'postgres') {
service = new postgres_1.PostgresSubService(providerSubClient, providerPubClient);
}
else {
service = new ioredis_1.IORedisSubService(providerSubClient, providerPubClient);
}
await service.init(namespace, appId, engineId, logger);
return service;
}
}
exports.SubServiceFactory = SubServiceFactory;
;