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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useClass ignores top-level name property #285

Closed
solshark opened this issue Feb 24, 2020 · 2 comments
Closed

useClass ignores top-level name property #285

solshark opened this issue Feb 24, 2020 · 2 comments

Comments

@solshark
Copy link

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Expected behavior

If registerQueueAsync used with useClass in this way:

    BullModule.registerQueueAsync({
      name: LINK_GAMES_QUEUE,
      useClass: QueueConfigService,
    }),

where QueueConfigService looks like

import { BullModuleOptions, BullOptionsFactory } from '@nestjs/bull';
import { ConfigService } from '@nestjs/config';
import { Injectable } from '@nestjs/common';
import { LINK_GAMES_QUEUE, QUEUE_REDIS_DB } from '@app/constants';

@Injectable()
export class QueueConfigService implements BullOptionsFactory {
  constructor(private configService: ConfigService) {}

  createBullOptions(): BullModuleOptions {
    return {
      redis: {
        host: this.configService.get('REDIS_CACHE_HOST'),
        port: this.configService.get('REDIS_CACHE_PORT'),
        db: QUEUE_REDIS_DB,
      },
    };
  }
}

queue created as default.

@frankhock
Copy link

frankhock commented Mar 1, 2020

@solshark I ran into the same issue but using useFactory, you have to pass the name prop as part of the return object from your createBullOptions method

UPDATED:

import { BullModuleOptions, BullOptionsFactory } from '@nestjs/bull';
import { ConfigService } from '@nestjs/config';
import { Injectable } from '@nestjs/common';
import { LINK_GAMES_QUEUE, QUEUE_REDIS_DB } from '@app/constants';

@Injectable()
export class QueueConfigService implements BullOptionsFactory {
  constructor(private configService: ConfigService) {}

  createBullOptions(): BullModuleOptions {
    return {
      name: YOUR_QUEUE_NAME,
      redis: {
        host: this.configService.get('REDIS_CACHE_HOST'),
        port: this.configService.get('REDIS_CACHE_PORT'),
        db: QUEUE_REDIS_DB,
      },
    };
  }
}

kamilmysliwiec added a commit that referenced this issue Apr 14, 2020
…operty

fix(core): use root name prop as queue name when creating providers #285
@kamilmysliwiec
Copy link
Member

Fixed in 0.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants