Comparing version 0.0.2 to 0.1.0
import * as bullmq from 'bullmq'; | ||
import { Queue, Worker, ConnectionOptions, Processor, JobsOptions, RepeatOptions, WorkerOptions } from 'bullmq'; | ||
import { Queue, QueueOptions, Worker, ConnectionOptions, Processor, JobsOptions, RepeatOptions, WorkerOptions } from 'bullmq'; | ||
type OptionsData = Omit<WorkerOptions, "connection">; | ||
declare class Job<GlobalInput = never> { | ||
type NoConnection<T> = Omit<T, "connection">; | ||
type OptionsData = NoConnection<WorkerOptions>; | ||
interface DefinedJobsOptions { | ||
queue?: Queue | NoConnection<QueueOptions>; | ||
} | ||
declare class Job<GlobalInput = undefined> { | ||
private connection; | ||
@@ -11,3 +16,3 @@ private name; | ||
private optionsData?; | ||
constructor(connection: ConnectionOptions, jobName: string); | ||
constructor(connection: ConnectionOptions, jobName: string, options?: DefinedJobsOptions); | ||
input<Input>(input?: Input): Job<Input>; | ||
@@ -25,4 +30,4 @@ options(options: OptionsData): this; | ||
declare function initJobify(connection: ConnectionOptions): (name: string) => Job<never>; | ||
declare function initJobify(connection: ConnectionOptions): (jobName: string, options?: DefinedJobsOptions | undefined) => Job<undefined>; | ||
export { initJobify }; |
@@ -10,7 +10,8 @@ import { Queue, Worker } from 'bullmq'; | ||
optionsData; | ||
constructor(connection, jobName) { | ||
constructor(connection, jobName, options) { | ||
this.connection = connection; | ||
this.name = jobName; | ||
this.queue = new Queue(jobName, { | ||
connection | ||
this.queue = options?.queue instanceof Queue ? options.queue : new Queue(jobName, { | ||
connection, | ||
...options?.queue | ||
}); | ||
@@ -48,4 +49,4 @@ } | ||
function initJobify(connection) { | ||
return (name) => { | ||
return new Job(connection, name); | ||
return (...args) => { | ||
return new Job(connection, ...args); | ||
}; | ||
@@ -52,0 +53,0 @@ } |
@@ -15,3 +15,3 @@ { | ||
"keywords": ["jobs", "queue", "bullmq", "bull", "pg-boss"], | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"type": "module", | ||
@@ -18,0 +18,0 @@ "devDependencies": { |
@@ -29,4 +29,11 @@ # jobify | ||
const job1 = defineJob("some") | ||
const job1 = defineJob("some", { | ||
queue: { | ||
defaultJobOptions: { | ||
delay: 100, | ||
}, | ||
}, | ||
}) | ||
.input<{ date: string }>() | ||
// WORKER OPTIONS | ||
.options({ | ||
@@ -33,0 +40,0 @@ limiter: { |
Sorry, the diff of this file is not supported yet
6169
128
84