feat(queue): define QueueAdapter interface types

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jarvis
2026-04-02 20:20:56 -05:00
parent 73043773d8
commit 05d61e62be
3 changed files with 42 additions and 22 deletions

View File

@@ -6,3 +6,5 @@ export {
type QueueClient,
type TaskPayload,
} from './queue.js';
export { type QueueAdapter, type QueueConfig as QueueAdapterConfig } from './types.js';

View 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 };