feat(queue): define QueueAdapter interface types
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,3 +6,5 @@ export {
|
||||
type QueueClient,
|
||||
type TaskPayload,
|
||||
} from './queue.js';
|
||||
|
||||
export { type QueueAdapter, type QueueConfig as QueueAdapterConfig } from './types.js';
|
||||
|
||||
18
packages/queue/src/types.ts
Normal file
18
packages/queue/src/types.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export interface TaskPayload {
|
||||
id: string;
|
||||
type: string;
|
||||
data: Record<string, unknown>;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface QueueAdapter {
|
||||
readonly name: string;
|
||||
enqueue(queueName: string, payload: TaskPayload): Promise<void>;
|
||||
dequeue(queueName: string): Promise<TaskPayload | null>;
|
||||
length(queueName: string): Promise<number>;
|
||||
publish(channel: string, message: string): Promise<void>;
|
||||
subscribe(channel: string, handler: (message: string) => void): () => void;
|
||||
close(): Promise<void>;
|
||||
}
|
||||
|
||||
export type QueueConfig = { type: 'bullmq'; url?: string } | { type: 'local'; dataDir?: string };
|
||||
Reference in New Issue
Block a user