Add MariaDB queue table. Fix Bugs
This commit is contained in:
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
import type { BunMariaDBConfig, DBResponseObject } from "../../types";
|
||||
type Params<Table extends string = string> = {
|
||||
table: Table;
|
||||
/** Max jobs to claim. Defaults to 1 */
|
||||
limit?: number;
|
||||
/** How long the claim lasts before another worker may take the job. Defaults to the table's `lease_ms` */
|
||||
lease_ms?: number;
|
||||
/** Jobs whose lease expired after this many attempts are marked `failed`. Defaults to the table's `max_attempts` */
|
||||
max_attempts?: number;
|
||||
config?: BunMariaDBConfig;
|
||||
};
|
||||
/**
|
||||
* Claim the next available jobs, oldest `queue_available_at` first. Each
|
||||
* returned row carries a `queue_lock_token` that must be passed to `ack`,
|
||||
* `fail` or `extend`.
|
||||
*
|
||||
* `FOR UPDATE SKIP LOCKED` lets concurrent workers claim different jobs
|
||||
* without blocking on each other or claiming the same job twice.
|
||||
*/
|
||||
export default function QueueClaim<Schema extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
[k: string]: any;
|
||||
}, Table extends string = string>({ table, limit, lease_ms, max_attempts, config, }: Params<Table>): Promise<DBResponseObject<Schema>>;
|
||||
export {};
|
||||
Reference in New Issue
Block a user