GithubHelp home page GithubHelp logo

jongolden / agenda-nest Goto Github PK

View Code? Open in Web Editor NEW
17.0 1.0 4.0 5.67 MB

A lightweight job scheduler for NestJS

License: MIT License

JavaScript 2.83% Shell 0.21% TypeScript 96.97%
agendajs nestjs queue schedule

agenda-nest's People

Contributors

dependabot[bot] avatar jongolden avatar mirandabrawnersavannah avatar tomups avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

agenda-nest's Issues

Unable to use @InjectQueue in other modules

Nest can't resolve dependencies of the MiscSerice (CATEGORY_MODEL, ?). Please make sure that the argument wallets-queue at index [1] is available in the MiscModule context.

I get the error above when I tried to use @InjectQueue in my other modules. I have imported the JobModule in the Module but it still gives me the error

Potential solutions:
- If wallets-queue is a provider, is it part of the current MiscModule?
- If wallets-queue is exported from a separate @Module, is that module imported within MiscModule?
  @Module({
    imports: [ /* the Module containing wallets-queue */ ]
  })

I have tried the possible solutions above too

Enable processing multiple queues

Enable defining and processing multiple queues without needing to import multiple instances of AgendaModule.

We should be able to achieve this by introducing a @Queue decorator. This decorator should take the queue name and optional AgendaConfig. The queue name will be mapped to the mongodb collection.

Doing this may necessitate requiring the decorator on any processor class as this feature will require changing the way we lookup job processors in the explorer. Specifically, we will need to first find all instances of @Queue, creating an Agenda instance for each, and then iterating over the prototypes of each to find the corresponding job processors and event listeners.

Don't force a dash in queue collection name

Right now the collection name for a queue is hardcoded to be ${name}-queue, but using dashes / hyphens in mongdb collections can be problematic (in our case, it's giving us problems with a custom import / export job)

https://devops.datenkollektiv.de/why-you-shouldnt-use-a-dash-in-a-mongodb-collection-name.html
https://coderwall.com/p/lhxbtq/do-not-use-hyphens-in-mongodb-collection-names

Would it be possible to have one of these options?

  • Have ${name}queue as name for the collection (no dash).
  • Not add anything, just name the collection name and the user can choose to add a suffix if desired as part of the name.
  • Allow to define a custom suffix in the @Queue decorator.
  • Allow to define a full collection name without suffix in the @Queue decorator.

I was checking the parameters for @Queue and I see that it might be possible to change the collection name by passing an AgendaConfig object to the @Queue decorator, in the db.collection property, but unfortunately that also requires to define db.address which is the mongodb connection string and I don't want to do that, I want it to use the already configured mongo connection just like when you only provide a queue name.

export interface AgendaConfig {
  name?: string;
  processEvery?: string;
  maxConcurrency?: number;
  defaultConcurrency?: number;
  lockLimit?: number;
  defaultLockLimit?: number;
  defaultLockLifetime?: number;
  sort?: any;
  mongo?: MongoDb;
  db?: {
    address: string; // I don't want to have to provide the mongodb connection string just for this, but it's not optional
    collection?: string; // I suppose with this I can set my own collection name, without -queue
    options?: MongoClientOptions;
  };
  disableAutoIndex?: boolean;
}

`done` argument is not passed to job functions when using @Define

According to the agenda documentation, done is passed as the second argument to the method.
Currently it is not being passed.

See below for an example:

import { IngestionService } from './ingestion.service';
import { Queue, Define, InjectQueue } from 'agenda-nest';
import { Agenda } from 'agenda';

@Queue('ingestions')
export default class IngestionQueue {
  constructor(
    @InjectQueue('ingestions') private readonly ingestionQueue: Agenda,
  ) {}

  @Define()
  async ingestBatch(job, done) {
    console.log({job, done}): // done is undefined
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.