-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow to change job queue or setup options for it
- Loading branch information
1 parent
03a2013
commit d2e0c2b
Showing
7 changed files
with
82 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { type ConnectionOptions, Queue } from "bullmq"; | ||
import type { ConnectionOptions } from "bullmq"; | ||
import { Job } from "define-job"; | ||
import type { Shift } from "./utils"; | ||
|
||
export function initJobify(connection: ConnectionOptions) { | ||
return (name: string) => { | ||
return new Job(connection, name); | ||
return (...args: Shift<ConstructorParameters<typeof Job>>) => { | ||
return new Job(connection, ...args); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export type Shift<T extends any[]> = ((...t: T) => void) extends ( | ||
h: any, | ||
...r: infer R | ||
) => void | ||
? R | ||
: never; | ||
|
||
export type NoConnection<T> = Omit<T, "connection">; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// TODO: | ||
import { describe, expect, it } from "bun:test"; | ||
import { initJobify } from "index"; | ||
import IORedis from "ioredis"; | ||
|
||
const connection = new IORedis({}); | ||
|
||
describe("test", () => { | ||
it("some", () => { | ||
const defineJob = initJobify(connection); | ||
|
||
const job = defineJob("ok", { | ||
queue: { | ||
defaultJobOptions: { | ||
delay: 100, | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
{ | ||
"compilerOptions": { | ||
// Enable latest features | ||
"lib": ["ESNext", "DOM"], | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleDetection": "force", | ||
"jsx": "react-jsx", | ||
"allowJs": true, | ||
"compilerOptions": { | ||
// Enable latest features | ||
"lib": ["ESNext", "DOM"], | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleDetection": "force", | ||
"jsx": "react-jsx", | ||
"allowJs": true, | ||
|
||
// Bundler mode | ||
"moduleResolution": "bundler", | ||
"verbatimModuleSyntax": true, | ||
"declaration": true, | ||
// Bundler mode | ||
"moduleResolution": "Node", | ||
"verbatimModuleSyntax": true, | ||
"declaration": true, | ||
|
||
// Best practices | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"noFallthroughCasesInSwitch": true, | ||
// Best practices | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"noFallthroughCasesInSwitch": true, | ||
|
||
// Some stricter flags (disabled by default) | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false, | ||
"noPropertyAccessFromIndexSignature": false, | ||
"baseUrl": "./src" | ||
} | ||
// Some stricter flags (disabled by default) | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false, | ||
"noPropertyAccessFromIndexSignature": false, | ||
"baseUrl": "./src" | ||
} | ||
} |