How to use the ioredis.SentinelConnector function in ioredis

To help you get started, we’ve selected a few ioredis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github luin / ioredis / examples / custom_connector.js View on Github external
"use strict";

const Redis = require("ioredis");
const MyService = require("path/to/my/service");

// Create a custom connector that fetches sentinels from an external call
class AsyncSentinelConnector extends Redis.SentinelConnector {
  constructor(options = {}) {
    // Placeholder
    options.sentinels = options.sentinels || [
      { host: "localhost", port: 6379 }
    ];

    // SentinelConnector saves options as its property
    super(options);
  }

  connect(eventEmitter) {
    return MyService.getSentinels().then(sentinels => {
      this.options.sentinels = sentinels;
      this.sentinelIterator = new Redis.SentinelIterator(sentinels);
      return Redis.SentinelConnector.prototype.connect.call(this, eventEmitter);
    });
github luin / ioredis / examples / custom_connector.js View on Github external
return MyService.getSentinels().then(sentinels => {
      this.options.sentinels = sentinels;
      this.sentinelIterator = new Redis.SentinelIterator(sentinels);
      return Redis.SentinelConnector.prototype.connect.call(this, eventEmitter);
    });
  }

ioredis

A robust, performance-focused and full-featured Redis client for Node.js.

MIT
Latest version published 6 days ago

Package Health Score

98 / 100
Full package analysis