jongolden / agenda-nest Goto Github PK
View Code? Open in Web Editor NEWA lightweight job scheduler for NestJS
License: MIT License
A lightweight job scheduler for NestJS
License: MIT License
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 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.
Title.
Thanks :)
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?
${name}queue
as name for the collection (no dash).name
and the user can choose to add a suffix if desired as part of the name.@Queue
decorator.@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;
}
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
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.