"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initDbModel = exports.getDBOperator = void 0;
const config_1 = require("@/config");
const memory_db_1 = require("./memory/memory-db");
const pub_sub_1 = require("./memory/pub-sub");
const redis_db_1 = require("./redis/redis-db");
const pub_sub_2 = require("./redis/pub-sub");
let DB;
let Publisher;
let Subscriber;
/**
 * 获取数据库 db, Publisher, Subscriber
 */
const getDBOperator = () => ({
    DB,
    Publisher,
    Subscriber,
});
exports.getDBOperator = getDBOperator;
/**
 * 初始化数据库环境
 */
const initDbModel = () => {
    if (config_1.config.isRemote) {
        DB = redis_db_1.RedisDB;
        Publisher = pub_sub_2.RedisPublisher;
        Subscriber = pub_sub_2.RedisSubscriber;
    }
    else {
        DB = memory_db_1.MemoryDB;
        Publisher = pub_sub_1.MemoryPubSub;
        Subscriber = pub_sub_1.MemoryPubSub;
    }
};
exports.initDbModel = initDbModel;
