Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: allow connection url #246

Open
iwpnd opened this issue May 8, 2023 · 5 comments
Open

feature request: allow connection url #246

iwpnd opened this issue May 8, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@iwpnd
Copy link

iwpnd commented May 8, 2023

Hey @ejhayes 馃憢

any chance you could offer the option to pass a redis url instead of the host/port? that would allow to connect optionally via tls using rediss:// or redis://.

Looks like @nestjs/redis is supporting it here. As for implementation one could prioritise an env such as REDIS_URL over REDIS_HOST/REDIS_PORT/REDIS_PASSWORD if set.

wdyt?

@iwpnd
Copy link
Author

iwpnd commented May 8, 2023

optionally i believe adding tls: true would also work.

@ejhayes
Copy link
Owner

ejhayes commented May 8, 2023

Good idea @iwpnd. I can definitely add this in.

@ejhayes ejhayes added the enhancement New feature or request label May 8, 2023
@iwpnd
Copy link
Author

iwpnd commented May 9, 2023

i have a working first draft, where whenever a REDIS_URL is present in the configService I change connection parameters.

  private getConnection() {
    const hasUrl = this.configService.config.REDIS_URL !== '';

    return !hasUrl
      ? {
          connection: {
            host: this.configService.config.REDIS_HOST,
            port: this.configService.config.REDIS_PORT,
            password: this.configService.config.REDIS_PASSWORD,
          },
        }
      : {
          connection: new Redis(this.configService.config.REDIS_URL, {
            maxRetriesPerRequest: null,
          }),
        };
  }

// used like

  create(queuePrefix: string, queueName: string, queue: Queue) {
    const labels = {
      [LABEL_NAMES.QUEUE_PREFIX]: queuePrefix,
      [LABEL_NAMES.QUEUE_NAME]: queueName,
    };
    const queueEvents = new QueueEvents(queueName, {
      prefix: queuePrefix,
      ...this.getConnection(),
    });
    [...]

I understand that everybody has their way of working, so I understand that this is not the desired way to do it - yet, with some guidance I can draft a PR and complete this myself if you'd allow me to.

wdyt @ejhayes ?

@cahlan
Copy link

cahlan commented Sep 13, 2023

adding my vote for this as well. as I understand it, this package won't work with redis instances that are configured to use TLS?

@iwpnd
Copy link
Author

iwpnd commented Dec 22, 2023

This is correct @cahlan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

3 participants