@coko/server
Version:
Reusable server for use by Coko's projects
46 lines • 1.75 kB
TypeScript
import { PgBoss } from 'pg-boss';
import { z } from 'zod';
declare const sendOptionsSchema: z.ZodObject<{
startAfter: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>;
type SendOptions = z.infer<typeof sendOptionsSchema>;
type JobManagerOptions = {
exposeBossInstance?: boolean;
};
declare const JobHandlerArgumentsSchema: z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
data: z.ZodAny;
}, z.core.$strict>;
export type JobHandlerArguments = z.infer<typeof JobHandlerArgumentsSchema>;
declare const JobQueueSchema: z.ZodObject<{
name: z.ZodString;
handler: z.ZodFunction<z.core.$ZodTuple<readonly [z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
data: z.ZodAny;
}, z.core.$strict>], z.core.$ZodFunctionOut>, z.core.$ZodFunctionOut>;
batchSize: z.ZodOptional<z.ZodNumber>;
concurrency: z.ZodOptional<z.ZodNumber>;
schedule: z.ZodOptional<z.ZodString>;
scheduleTimezone: z.ZodOptional<z.ZodOptional<z.ZodString>>;
}, z.core.$strict>;
export type JobQueue = z.infer<typeof JobQueueSchema>;
type WaitOptions = {
interval?: number;
timeout?: number;
};
declare class JobManager {
#private;
constructor(options?: JobManagerOptions);
get boss(): PgBoss;
init(passedQueues?: JobQueue[]): Promise<void>;
stop(): Promise<void>;
getQueueSize(queueName: string): Promise<number>;
waitForJobsToFinish(queueName: string, filterData: any, options?: WaitOptions): Promise<void>;
waitForQueueToEmpty(queueName: string, options?: WaitOptions): Promise<void>;
sendToQueue(queueName: string, data: any, options?: SendOptions): Promise<void>;
}
declare const jobManager: JobManager;
export { JobManager, jobManager };
//# sourceMappingURL=JobManager.d.ts.map