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KAAK,KAAO,WAAW,EAAQ,MAAO,EAAQ,KAAM,KACtD,CAIA,aAAA,CAAc,GACZ,OAAO,KAAK,KAAK,QAAQ,EAC3B,CAIA,OAAA,CAAQ,GACN,OAAO,KAAK,KAAK,QAAQ,EAC3B,CAIA,UAAA,CAAW,GACT,OAAO,KAAK,KAAK,QAAQ,EAC3B,CAIA,GAAA,GACE,OAAO,KAAK,KAAK,QAAQ,MAAK,IAAM,KAAK,KAAK,UAAS,MAAK,KAC1D,KAAK,OAAO,KAAK,sCAAsC,GAE3D,EAEF,UAAU,SAAW,CACnB,KAAM,CACJ,IAAK,EACL,IAAK,IAEP,aAAc,QAEhB,QAAQ,MAAQ,MAChB,QAAQ,UAAY","file":"/npm/ioredis-conn-pool@2.0.1/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/ioredis-conn-pool@2.0.1/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nObject.defineProperty(exports, Symbol.toStringTag, { value: \"Module\" });\nconst genericPool = require(\"generic-pool\");\nconst Redis = require(\"ioredis\");\nconst node_util = require(\"node:util\");\nconst baseLogFactory = require(\"base-log-factory\");\nconst blfDebugAppender = require(\"blf-debug-appender\");\nconst name = \"ioredis-conn-pool\";\nfunction createConverter(specifier) {\n  if (specifier === \"m\") {\n    return (event) => {\n      return event.message.map((msg) => {\n        switch (typeof msg) {\n          case \"object\":\n            return node_util.inspect(msg);\n          case \"symbol\":\n            return msg.toString();\n          default:\n            return msg;\n        }\n      }).join(\" \");\n    };\n  }\n}\nconst logger = new baseLogFactory.Logger(name, {\n  level: baseLogFactory.Level.INFO,\n  appenders: [\n    new blfDebugAppender.DebugAppender({\n      layout: new baseLogFactory.PatternLayout(\"%d{HH:mm:ss} [%p] - %m\", createConverter)\n    })\n  ]\n});\nfunction createPool(redisOptions, poolOptions, context) {\n  return genericPool.createPool({\n    create() {\n      return new Promise((resolve, reject) => {\n        const ioredis = new Redis(redisOptions);\n        const onError = (e) => {\n          context.logger.error(\"Create redis connection error.\", e);\n          ioredis.disconnect();\n          reject(e);\n        };\n        ioredis.once(\"error\", onError).once(\"ready\", () => {\n          ioredis.off(\"error\", onError);\n          if (ioredis.options.enableReadyCheck) {\n            context.logger.info(\"Redis Server is ready.\");\n          } else {\n            context.logger.info(\"The connection is established to the Redis server.\");\n          }\n          resolve(ioredis);\n        });\n      });\n    },\n    destroy(ioredis) {\n      return new Promise((resolve) => {\n        ioredis.once(\"end\", () => {\n          context.logger.info(\"No more reconnections will be made.\");\n          resolve();\n        }).disconnect();\n      });\n    }\n  }, poolOptions);\n}\nclass RedisPool {\n  constructor(opts) {\n    const options = Object.assign({}, RedisPool.defaults, opts);\n    this.logger = options.customLogger;\n    this.pool = createPool(options.redis, options.pool, this);\n  }\n  /**\n   * Get a connection from the pool\n   */\n  getConnection(priority) {\n    return this.pool.acquire(priority);\n  }\n  /**\n   * Release a redis connection\n   */\n  release(client) {\n    return this.pool.release(client);\n  }\n  /**\n   * Close a redis connection\n   */\n  disconnect(client) {\n    return this.pool.destroy(client);\n  }\n  /**\n   * Close all connections\n   */\n  end() {\n    return this.pool.drain().then(() => this.pool.clear()).then(() => {\n      this.logger.info(\"Disconnected all Redis connections.\");\n    });\n  }\n}\nRedisPool.defaults = {\n  pool: {\n    min: 2,\n    max: 10\n  },\n  customLogger: logger\n};\nexports.Redis = Redis;\nexports.RedisPool = RedisPool;\n"]}