RedisClientManager.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* eslint-disable
  2. no-unused-vars,
  3. */
  4. // TODO: This file was created by bulk-decaffeinate.
  5. // Fix any style issues and re-enable lint.
  6. /*
  7. * decaffeinate suggestions:
  8. * DS101: Remove unnecessary use of Array.from
  9. * DS205: Consider reworking code to avoid use of IIFEs
  10. * DS207: Consider shorter variations of null checks
  11. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  12. */
  13. let RedisClientManager
  14. const redis = require('redis-sharelatex')
  15. const logger = require('logger-sharelatex')
  16. module.exports = RedisClientManager = {
  17. createClientList(...configs) {
  18. // create a dynamic list of redis clients, excluding any configurations which are not defined
  19. const clientList = (() => {
  20. const result = []
  21. for (const x of Array.from(configs)) {
  22. if (x != null) {
  23. const redisType =
  24. x.cluster != null
  25. ? 'cluster'
  26. : x.sentinels != null
  27. ? 'sentinel'
  28. : x.host != null
  29. ? 'single'
  30. : 'unknown'
  31. logger.log({ redis: redisType }, 'creating redis client')
  32. result.push(redis.createClient(x))
  33. }
  34. }
  35. return result
  36. })()
  37. return clientList
  38. }
  39. }