Add MariaDB queue table. Fix Bugs

This commit is contained in:
2026-10-18 15:58:02 +01:00
parent d872c3661a
commit f9ba5f8657
28 changed files with 785 additions and 49 deletions
+34
View File
@@ -0,0 +1,34 @@
import { type BUN_MARIADB_QueueTableOptions } from "../../types";
/**
* Current time in ms from the database clock. Leases are set and checked
* with this so workers on hosts with drifting clocks agree on expiry.
*/
export declare const QUEUE_NOW_SQL = "CAST(UNIX_TIMESTAMP(NOW(3)) * 1000 AS SIGNED)";
/**
* Extra WHERE condition for generic update/delete on queue tables: rows a
* worker has claimed are only changed through the queue API.
*/
export declare const QUEUE_NOT_CLAIMED_SQL = "`queue_status` <> 'processing'";
export type ResolvedQueueTableOptions = Required<BUN_MARIADB_QueueTableOptions>;
/**
* A table's `queue_table` options with defaults filled in (looked up
* directly or through its parent table), or `undefined` if it is not a
* queue table.
*/
export declare function grabQueueTableOptions(tableName: string): ResolvedQueueTableOptions | undefined;
/**
* Whether a table is declared with `queue_table` (directly or through its
* parent table).
*/
export declare function isQueueTable(tableName: string): boolean;
/**
* Queue options for a table the queue API was called on. Throws if the table
* is not a queue table.
*/
export declare function requireQueueTable(tableName: string): ResolvedQueueTableOptions;
/**
* Throw if `data` sets queue state the queue API owns.
*/
export declare function assertNoProtectedQueueFields(table: string, data: {
[k: string]: any;
}[]): void;