/** * Core operations: push, pull, ack, fail */ import type { IFlashQClient, Job, PushOptions, BatchPushResult } from '../types'; import { MAX_BATCH_SIZE, MAX_JOB_DATA_SIZE } from '../connection'; export { MAX_BATCH_SIZE, MAX_JOB_DATA_SIZE }; /** * Push a job to a queue. * * @param client - FlashQ client instance * @param queue - Queue name * @param data - Job data payload * @param options - Push options (priority, delay, ttl, etc.) * @returns Created job * * @example * ```typescript * const job = await client.push('emails', { to: 'user@example.com' }); * ``` */ export declare function push(client: IFlashQClient, queue: string, data: T, options?: PushOptions): Promise; /** * Push multiple jobs to a queue in a single batch. * * @param client - FlashQ client instance * @param queue - Queue name * @param jobs - Array of jobs with data and options * @returns Array of created job IDs * * @example * ```typescript * const ids = await client.pushBatch('emails', [ * { data: { to: 'user1@example.com' } }, * { data: { to: 'user2@example.com' }, priority: 10 }, * ]); * ``` */ export declare function pushBatch(client: IFlashQClient, queue: string, jobs: Array<{ data: T; } & PushOptions>): Promise; /** * Push multiple jobs with partial failure handling. * Unlike pushBatch, this function handles individual job failures gracefully. * * @param client - FlashQ client instance * @param queue - Queue name * @param jobs - Array of jobs with data and options * @returns BatchPushResult with succeeded IDs and failed jobs * * @example * ```typescript * const result = await client.pushBatchSafe('emails', jobs); * console.log(`Created: ${result.ids.length}, Failed: ${result.failed.length}`); * if (!result.allSucceeded) { * for (const f of result.failed) { * console.error(`Job ${f.index} failed: ${f.error}`); * } * } * ``` */ export declare function pushBatchSafe(client: IFlashQClient, queue: string, jobs: Array<{ data: T; } & PushOptions>): Promise; /** * Pull a job from a queue (blocking with server-side timeout). * * @param client - FlashQ client instance * @param queue - Queue name * @param timeout - Server-side timeout in ms (default: 60s) * @returns Job or null if timeout * * @example * ```typescript * const job = await client.pull('emails'); * if (job) { * console.log('Processing:', job.data); * } * ``` */ export declare function pull(client: IFlashQClient, queue: string, timeout?: number): Promise<(Job & { data: T; }) | null>; /** * Pull multiple jobs from a queue. * * @param client - FlashQ client instance * @param queue - Queue name * @param count - Number of jobs to pull * @param timeout - Server-side timeout in ms (default: 60s) * @returns Array of jobs * * @example * ```typescript * const jobs = await client.pullBatch('emails', 10); * for (const job of jobs) { * await processJob(job); * } * ``` */ export declare function pullBatch(client: IFlashQClient, queue: string, count: number, timeout?: number): Promise>; /** * Acknowledge a job as completed. * * @param client - FlashQ client instance * @param jobId - Job ID * @param result - Optional result data * * @example * ```typescript * await client.ack(job.id, { sent: true }); * ``` */ export declare function ack(client: IFlashQClient, jobId: number, result?: unknown): Promise; /** * Acknowledge multiple jobs at once. * * @param client - FlashQ client instance * @param jobIds - Array of job IDs * @returns Number of jobs acknowledged * * @example * ```typescript * await client.ackBatch([1, 2, 3]); * ``` */ export declare function ackBatch(client: IFlashQClient, jobIds: number[]): Promise; /** * Fail a job (will retry or move to DLQ). * * @param client - FlashQ client instance * @param jobId - Job ID * @param error - Optional error message * * @example * ```typescript * await client.fail(job.id, 'Connection timeout'); * ``` */ export declare function fail(client: IFlashQClient, jobId: number, error?: string): Promise; //# sourceMappingURL=core.d.ts.map