@workglow/storage 0.2.26 → 0.2.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts +0 -10
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +407 -4002
- package/dist/browser.js.map +8 -24
- package/dist/bun.js +496 -6711
- package/dist/bun.js.map +8 -34
- package/dist/common-server.d.ts +1 -21
- package/dist/common-server.d.ts.map +1 -1
- package/dist/common.d.ts +1 -6
- package/dist/common.d.ts.map +1 -1
- package/dist/node.js +496 -6712
- package/dist/node.js.map +8 -34
- package/dist/tabular/SharedInMemoryTabularStorage.d.ts +2 -1
- package/dist/tabular/SharedInMemoryTabularStorage.d.ts.map +1 -1
- package/package.json +5 -71
- package/dist/kv/IndexedDbKvStorage.d.ts +0 -27
- package/dist/kv/IndexedDbKvStorage.d.ts.map +0 -1
- package/dist/kv/PostgresKvStorage.d.ts +0 -28
- package/dist/kv/PostgresKvStorage.d.ts.map +0 -1
- package/dist/kv/SqliteKvStorage.d.ts +0 -28
- package/dist/kv/SqliteKvStorage.d.ts.map +0 -1
- package/dist/kv/SupabaseKvStorage.d.ts +0 -33
- package/dist/kv/SupabaseKvStorage.d.ts.map +0 -1
- package/dist/postgres/browser.d.ts +0 -32
- package/dist/postgres/browser.d.ts.map +0 -1
- package/dist/postgres/browser.js +0 -150
- package/dist/postgres/browser.js.map +0 -11
- package/dist/postgres/node-bun.d.ts +0 -26
- package/dist/postgres/node-bun.d.ts.map +0 -1
- package/dist/postgres/node-bun.js +0 -41
- package/dist/postgres/node-bun.js.map +0 -10
- package/dist/postgres/pglite-pool.d.ts +0 -21
- package/dist/postgres/pglite-pool.d.ts.map +0 -1
- package/dist/queue/IQueueStorage.d.ts +0 -206
- package/dist/queue/IQueueStorage.d.ts.map +0 -1
- package/dist/queue/InMemoryQueueStorage.d.ts +0 -148
- package/dist/queue/InMemoryQueueStorage.d.ts.map +0 -1
- package/dist/queue/IndexedDbQueueStorage.d.ts +0 -165
- package/dist/queue/IndexedDbQueueStorage.d.ts.map +0 -1
- package/dist/queue/PostgresQueueStorage.d.ts +0 -133
- package/dist/queue/PostgresQueueStorage.d.ts.map +0 -1
- package/dist/queue/SqliteQueueStorage.d.ts +0 -141
- package/dist/queue/SqliteQueueStorage.d.ts.map +0 -1
- package/dist/queue/SupabaseQueueStorage.d.ts +0 -194
- package/dist/queue/SupabaseQueueStorage.d.ts.map +0 -1
- package/dist/queue/TelemetryQueueStorage.d.ts +0 -32
- package/dist/queue/TelemetryQueueStorage.d.ts.map +0 -1
- package/dist/queue-limiter/IRateLimiterStorage.d.ts +0 -81
- package/dist/queue-limiter/IRateLimiterStorage.d.ts.map +0 -1
- package/dist/queue-limiter/InMemoryRateLimiterStorage.d.ts +0 -32
- package/dist/queue-limiter/InMemoryRateLimiterStorage.d.ts.map +0 -1
- package/dist/queue-limiter/IndexedDbRateLimiterStorage.d.ts +0 -52
- package/dist/queue-limiter/IndexedDbRateLimiterStorage.d.ts.map +0 -1
- package/dist/queue-limiter/PostgresRateLimiterStorage.d.ts +0 -54
- package/dist/queue-limiter/PostgresRateLimiterStorage.d.ts.map +0 -1
- package/dist/queue-limiter/SqliteRateLimiterStorage.d.ts +0 -53
- package/dist/queue-limiter/SqliteRateLimiterStorage.d.ts.map +0 -1
- package/dist/queue-limiter/SupabaseRateLimiterStorage.d.ts +0 -49
- package/dist/queue-limiter/SupabaseRateLimiterStorage.d.ts.map +0 -1
- package/dist/sqlite/browser.d.ts +0 -37
- package/dist/sqlite/browser.d.ts.map +0 -1
- package/dist/sqlite/browser.js +0 -125
- package/dist/sqlite/browser.js.map +0 -10
- package/dist/sqlite/bun.d.ts +0 -32
- package/dist/sqlite/bun.d.ts.map +0 -1
- package/dist/sqlite/bun.js +0 -84
- package/dist/sqlite/bun.js.map +0 -10
- package/dist/sqlite/canonical-api.d.ts +0 -34
- package/dist/sqlite/canonical-api.d.ts.map +0 -1
- package/dist/sqlite/node.d.ts +0 -34
- package/dist/sqlite/node.d.ts.map +0 -1
- package/dist/sqlite/node.js +0 -65
- package/dist/sqlite/node.js.map +0 -10
- package/dist/tabular/IndexedDbTabularStorage.d.ts +0 -199
- package/dist/tabular/IndexedDbTabularStorage.d.ts.map +0 -1
- package/dist/tabular/PostgresTabularStorage.d.ts +0 -196
- package/dist/tabular/PostgresTabularStorage.d.ts.map +0 -1
- package/dist/tabular/SqliteTabularStorage.d.ts +0 -167
- package/dist/tabular/SqliteTabularStorage.d.ts.map +0 -1
- package/dist/tabular/SupabaseTabularStorage.d.ts +0 -174
- package/dist/tabular/SupabaseTabularStorage.d.ts.map +0 -1
- package/dist/util/IndexedDbTable.d.ts +0 -40
- package/dist/util/IndexedDbTable.d.ts.map +0 -1
- package/dist/util/traced.d.ts +0 -10
- package/dist/util/traced.d.ts.map +0 -1
- package/dist/vector/IndexedDbVectorStorage.d.ts +0 -53
- package/dist/vector/IndexedDbVectorStorage.d.ts.map +0 -1
- package/dist/vector/PostgresVectorStorage.d.ts +0 -39
- package/dist/vector/PostgresVectorStorage.d.ts.map +0 -1
- package/dist/vector/SqliteAiVectorStorage.d.ts +0 -100
- package/dist/vector/SqliteAiVectorStorage.d.ts.map +0 -1
- package/dist/vector/SqliteVectorStorage.d.ts +0 -49
- package/dist/vector/SqliteVectorStorage.d.ts.map +0 -1
- package/src/queue/README.md +0 -41
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresQueueStorage.d.ts","sourceRoot":"","sources":["../../src/queue/PostgresQueueStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EACL,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,sBAAsB,gEAElC,CAAC;AAKF;;;GAGG;AACH,q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CAAC,MAAM,EAAE,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAC7D,OAAO,CAAC,EAAE,qBAAqB,GAC9B,MAAM,IAAI,CAEZ;CACF"}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import type { Sqlite } from "@workglow/storage/sqlite";
|
|
7
|
-
import { IQueueStorage, JobStatus, JobStorageFormat, PrefixColumn, QueueChangePayload, QueueStorageOptions, QueueSubscribeOptions } from "./IQueueStorage";
|
|
8
|
-
export declare const SQLITE_QUEUE_STORAGE: import("@workglow/util").ServiceToken<IQueueStorage<any, any>>;
|
|
9
|
-
/**
|
|
10
|
-
* Extended options for SQLite queue storage including prefix support
|
|
11
|
-
*/
|
|
12
|
-
export interface SqliteQueueStorageOptions extends QueueStorageOptions {
|
|
13
|
-
readonly deleteAfterCompletionMs?: number;
|
|
14
|
-
readonly deleteAfterFailureMs?: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* SQLite implementation of a job queue.
|
|
18
|
-
* Provides storage and retrieval for job execution states using SQLite.
|
|
19
|
-
*/
|
|
20
|
-
export declare class SqliteQueueStorage<Input, Output> implements IQueueStorage<Input, Output> {
|
|
21
|
-
protected db: Sqlite.Database;
|
|
22
|
-
protected queueName: string;
|
|
23
|
-
protected options?: SqliteQueueStorageOptions | undefined;
|
|
24
|
-
/** The prefix column definitions */
|
|
25
|
-
protected readonly prefixes: readonly PrefixColumn[];
|
|
26
|
-
/** The prefix values for filtering */
|
|
27
|
-
protected readonly prefixValues: Readonly<Record<string, string | number>>;
|
|
28
|
-
/** The table name for the job queue */
|
|
29
|
-
protected readonly tableName: string;
|
|
30
|
-
constructor(db: Sqlite.Database, queueName: string, options?: SqliteQueueStorageOptions | undefined);
|
|
31
|
-
/**
|
|
32
|
-
* Gets the SQL column type for a prefix column (SQLite uses TEXT for uuid)
|
|
33
|
-
*/
|
|
34
|
-
private getPrefixColumnType;
|
|
35
|
-
/**
|
|
36
|
-
* Builds the prefix columns SQL for CREATE TABLE
|
|
37
|
-
*/
|
|
38
|
-
private buildPrefixColumnsSql;
|
|
39
|
-
/**
|
|
40
|
-
* Builds prefix column names for use in queries
|
|
41
|
-
*/
|
|
42
|
-
private getPrefixColumnNames;
|
|
43
|
-
/**
|
|
44
|
-
* Builds WHERE clause conditions for prefix filtering
|
|
45
|
-
* @returns The conditions string with placeholders
|
|
46
|
-
*/
|
|
47
|
-
private buildPrefixWhereClause;
|
|
48
|
-
/**
|
|
49
|
-
* Gets prefix values as an array in column order
|
|
50
|
-
*/
|
|
51
|
-
private getPrefixParamValues;
|
|
52
|
-
setupDatabase(): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Adds a new job to the queue.
|
|
55
|
-
* @param job - The job to add
|
|
56
|
-
* @returns The ID of the added job
|
|
57
|
-
*/
|
|
58
|
-
add(job: JobStorageFormat<Input, Output>): Promise<unknown>;
|
|
59
|
-
/**
|
|
60
|
-
* Retrieves a job by its ID.
|
|
61
|
-
* @param id - The ID of the job to retrieve
|
|
62
|
-
* @returns The job if found, undefined otherwise
|
|
63
|
-
*/
|
|
64
|
-
get(id: unknown): Promise<JobStorageFormat<Input, Output> | undefined>;
|
|
65
|
-
/**
|
|
66
|
-
* Retrieves a slice of jobs from the queue.
|
|
67
|
-
* @param num - Maximum number of jobs to return
|
|
68
|
-
* @returns An array of jobs
|
|
69
|
-
*/
|
|
70
|
-
peek(status?: JobStatus, num?: number): Promise<Array<JobStorageFormat<Input, Output>>>;
|
|
71
|
-
/**
|
|
72
|
-
* Aborts a job by setting its status to "ABORTING".
|
|
73
|
-
* This method will signal the corresponding AbortController so that
|
|
74
|
-
* the job's execute() method (if it supports an AbortSignal parameter)
|
|
75
|
-
* can clean up and exit.
|
|
76
|
-
*/
|
|
77
|
-
abort(jobId: unknown): Promise<void>;
|
|
78
|
-
/**
|
|
79
|
-
* Releases a claimed job back to PENDING without incrementing run_attempts.
|
|
80
|
-
* @param jobId - The id of the claimed job to release.
|
|
81
|
-
*/
|
|
82
|
-
release(jobId: unknown): Promise<void>;
|
|
83
|
-
/**
|
|
84
|
-
* Retrieves all jobs for a given job run ID.
|
|
85
|
-
* @param job_run_id - The ID of the job run to retrieve
|
|
86
|
-
* @returns An array of jobs
|
|
87
|
-
*/
|
|
88
|
-
getByRunId(job_run_id: string): Promise<Array<JobStorageFormat<Input, Output>>>;
|
|
89
|
-
/**
|
|
90
|
-
* Retrieves the next available job that is ready to be processed,
|
|
91
|
-
* and updates its status to PROCESSING.
|
|
92
|
-
*
|
|
93
|
-
* @param workerId - Worker ID to associate with the job
|
|
94
|
-
* @returns The next job or undefined if no job is available
|
|
95
|
-
*/
|
|
96
|
-
next(workerId: string): Promise<JobStorageFormat<Input, Output> | undefined>;
|
|
97
|
-
/**
|
|
98
|
-
* Retrieves the number of jobs in the queue with a specific status.
|
|
99
|
-
* @param status - The status of the jobs to count
|
|
100
|
-
* @returns The count of jobs with the specified status
|
|
101
|
-
*/
|
|
102
|
-
size(status?: "PENDING"): Promise<number>;
|
|
103
|
-
/**
|
|
104
|
-
* Marks a job as complete with its output or error.
|
|
105
|
-
* Enhanced error handling:
|
|
106
|
-
* - Increments the retry count.
|
|
107
|
-
* - For a retryable error, updates run_after with the retry date.
|
|
108
|
-
* - Marks the job as FAILED for permanent or generic errors.
|
|
109
|
-
* - Marks the job as DISABLED for disabled jobs.
|
|
110
|
-
*/
|
|
111
|
-
complete(job: JobStorageFormat<Input, Output>): Promise<void>;
|
|
112
|
-
deleteAll(): Promise<void>;
|
|
113
|
-
/**
|
|
114
|
-
* Looks up cached output for a given input
|
|
115
|
-
* Uses input fingerprinting for efficient matching
|
|
116
|
-
* @returns The cached output or null if not found
|
|
117
|
-
*/
|
|
118
|
-
outputForInput(input: Input): Promise<Output | null>;
|
|
119
|
-
/**
|
|
120
|
-
* Implements the abstract saveProgress method from JobQueue
|
|
121
|
-
*/
|
|
122
|
-
saveProgress(jobId: unknown, progress: number, message: string, details: Record<string, any>): Promise<void>;
|
|
123
|
-
/**
|
|
124
|
-
* Deletes a job by its ID
|
|
125
|
-
*/
|
|
126
|
-
delete(jobId: unknown): Promise<void>;
|
|
127
|
-
/**
|
|
128
|
-
* Delete jobs with a specific status older than a cutoff date
|
|
129
|
-
* @param status - Status of jobs to delete
|
|
130
|
-
* @param olderThanMs - Delete jobs completed more than this many milliseconds ago
|
|
131
|
-
*/
|
|
132
|
-
deleteJobsByStatusAndAge(status: JobStatus, olderThanMs: number): Promise<void>;
|
|
133
|
-
/**
|
|
134
|
-
* Subscribes to changes in the queue.
|
|
135
|
-
* NOT IMPLEMENTED for SQLite storage.
|
|
136
|
-
*
|
|
137
|
-
* @throws Error always - subscribeToChanges is not supported for SQLite storage
|
|
138
|
-
*/
|
|
139
|
-
subscribeToChanges(callback: (change: QueueChangePayload<Input, Output>) => void, options?: QueueSubscribeOptions): () => void;
|
|
140
|
-
}
|
|
141
|
-
//# sourceMappingURL=SqliteQueueStorage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteQueueStorage.d.ts","sourceRoot":"","sources":["../../src/queue/SqliteQueueStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EACL,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,oBAAoB,gEACuC,CAAC;AAQzE;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACpE,QAAQ,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAC1C,QAAQ,CAAC,oBAAoB,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EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAa3F;IAED;;;;;OAKG;IACI,kBAAkB,CACvB,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAC7D,OAAO,CAAC,EAAE,qBAAqB,GAC9B,MAAM,IAAI,CAEZ;CACF"}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
7
|
-
import { IQueueStorage, JobStatus, JobStorageFormat, PrefixColumn, QueueChangePayload, QueueStorageOptions, QueueSubscribeOptions } from "./IQueueStorage";
|
|
8
|
-
export declare const SUPABASE_QUEUE_STORAGE: import("@workglow/util").ServiceToken<IQueueStorage<any, any>>;
|
|
9
|
-
/**
|
|
10
|
-
* Supabase implementation of a job queue.
|
|
11
|
-
* Provides storage and retrieval for job execution states using Supabase.
|
|
12
|
-
*/
|
|
13
|
-
export declare class SupabaseQueueStorage<Input, Output> implements IQueueStorage<Input, Output> {
|
|
14
|
-
protected readonly queueName: string;
|
|
15
|
-
protected readonly client: SupabaseClient;
|
|
16
|
-
protected readonly prefixes: readonly PrefixColumn[];
|
|
17
|
-
protected readonly prefixValues: Readonly<Record<string, string | number>>;
|
|
18
|
-
protected readonly tableName: string;
|
|
19
|
-
private realtimeChannel;
|
|
20
|
-
private pollingManager;
|
|
21
|
-
constructor(client: SupabaseClient, queueName: string, options?: QueueStorageOptions);
|
|
22
|
-
/**
|
|
23
|
-
* Gets the SQL column type for a prefix column (Supabase supports UUID natively)
|
|
24
|
-
*/
|
|
25
|
-
private getPrefixColumnType;
|
|
26
|
-
/**
|
|
27
|
-
* Builds the prefix columns SQL for CREATE TABLE
|
|
28
|
-
*/
|
|
29
|
-
private buildPrefixColumnsSql;
|
|
30
|
-
/**
|
|
31
|
-
* Builds prefix column names for use in queries
|
|
32
|
-
*/
|
|
33
|
-
private getPrefixColumnNames;
|
|
34
|
-
/**
|
|
35
|
-
* Applies prefix filters to a Supabase query builder
|
|
36
|
-
*/
|
|
37
|
-
private applyPrefixFilters;
|
|
38
|
-
/**
|
|
39
|
-
* Gets prefix values as an object for inserts
|
|
40
|
-
*/
|
|
41
|
-
private getPrefixInsertValues;
|
|
42
|
-
/**
|
|
43
|
-
* Builds WHERE clause conditions for prefix filtering with inline values (for raw SQL)
|
|
44
|
-
* @returns SQL conditions string with values inlined
|
|
45
|
-
*/
|
|
46
|
-
private buildPrefixWhereSql;
|
|
47
|
-
/**
|
|
48
|
-
* Regex for validating SQL literal-safe strings.
|
|
49
|
-
* Used for quoted values (e.g. queue names/IDs) and only allows alphanumeric
|
|
50
|
-
* characters, underscores, hyphens, colons, and periods.
|
|
51
|
-
*/
|
|
52
|
-
private static readonly SAFE_SQL_VALUE_RE;
|
|
53
|
-
/**
|
|
54
|
-
* Validates that a string value is safe for use as a quoted SQL literal.
|
|
55
|
-
* Throws an error if the value contains characters outside SAFE_SQL_VALUE_RE.
|
|
56
|
-
*/
|
|
57
|
-
private validateSqlValue;
|
|
58
|
-
/**
|
|
59
|
-
* Escapes a string value for use in SQL
|
|
60
|
-
*/
|
|
61
|
-
private escapeSqlString;
|
|
62
|
-
setupDatabase(): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Adds a new job to the queue.
|
|
65
|
-
* @param job - The job to add
|
|
66
|
-
* @returns The ID of the added job
|
|
67
|
-
*/
|
|
68
|
-
add(job: JobStorageFormat<Input, Output>): Promise<unknown>;
|
|
69
|
-
/**
|
|
70
|
-
* Retrieves a job by its ID.
|
|
71
|
-
* @param id - The ID of the job to retrieve
|
|
72
|
-
* @returns The job if found, undefined otherwise
|
|
73
|
-
*/
|
|
74
|
-
get(id: unknown): Promise<JobStorageFormat<Input, Output> | undefined>;
|
|
75
|
-
/**
|
|
76
|
-
* Retrieves a slice of jobs from the queue.
|
|
77
|
-
* @param status - The status to filter by
|
|
78
|
-
* @param num - Maximum number of jobs to return
|
|
79
|
-
* @returns An array of jobs
|
|
80
|
-
*/
|
|
81
|
-
peek(status?: JobStatus, num?: number): Promise<JobStorageFormat<Input, Output>[]>;
|
|
82
|
-
/**
|
|
83
|
-
* Retrieves the next available job that is ready to be processed.
|
|
84
|
-
* Uses atomic UPDATE with subquery SELECT FOR UPDATE SKIP LOCKED to prevent race conditions.
|
|
85
|
-
* @param workerId - Worker ID to associate with the job (required)
|
|
86
|
-
* @returns The next job or undefined if no job is available
|
|
87
|
-
*/
|
|
88
|
-
next(workerId: string): Promise<JobStorageFormat<Input, Output> | undefined>;
|
|
89
|
-
/**
|
|
90
|
-
* Retrieves the number of jobs in the queue with a specific status.
|
|
91
|
-
* @param status - The status of the jobs to count
|
|
92
|
-
* @returns The count of jobs with the specified status
|
|
93
|
-
*/
|
|
94
|
-
size(status?: "PENDING"): Promise<number>;
|
|
95
|
-
private getAllJobs;
|
|
96
|
-
/**
|
|
97
|
-
* Marks a job as complete with its output or error.
|
|
98
|
-
* Enhanced error handling:
|
|
99
|
-
* - For a retryable error, increments run_attempts and updates run_after.
|
|
100
|
-
* - Marks a job as FAILED immediately for permanent or generic errors.
|
|
101
|
-
*/
|
|
102
|
-
complete(jobDetails: JobStorageFormat<Input, Output>): Promise<void>;
|
|
103
|
-
/**
|
|
104
|
-
* Releases a claimed job without consuming a retry attempt.
|
|
105
|
-
*/
|
|
106
|
-
release(jobId: unknown): Promise<void>;
|
|
107
|
-
/**
|
|
108
|
-
* Clears all jobs from the queue.
|
|
109
|
-
*/
|
|
110
|
-
deleteAll(): Promise<void>;
|
|
111
|
-
/**
|
|
112
|
-
* Looks up cached output for a given input
|
|
113
|
-
* Uses input fingerprinting for efficient matching
|
|
114
|
-
* @returns The cached output or null if not found
|
|
115
|
-
*/
|
|
116
|
-
outputForInput(input: Input): Promise<Output | null>;
|
|
117
|
-
/**
|
|
118
|
-
* Aborts a job by setting its status to "ABORTING".
|
|
119
|
-
* This method will signal the corresponding AbortController so that
|
|
120
|
-
* the job's execute() method (if it supports an AbortSignal parameter)
|
|
121
|
-
* can clean up and exit.
|
|
122
|
-
*/
|
|
123
|
-
abort(jobId: unknown): Promise<void>;
|
|
124
|
-
/**
|
|
125
|
-
* Retrieves all jobs for a given job run ID.
|
|
126
|
-
* @param job_run_id - The ID of the job run to retrieve
|
|
127
|
-
* @returns An array of jobs
|
|
128
|
-
*/
|
|
129
|
-
getByRunId(job_run_id: string): Promise<Array<JobStorageFormat<Input, Output>>>;
|
|
130
|
-
/**
|
|
131
|
-
* Implements the saveProgress method
|
|
132
|
-
*/
|
|
133
|
-
saveProgress(jobId: unknown, progress: number, message: string, details: Record<string, any>): Promise<void>;
|
|
134
|
-
/**
|
|
135
|
-
* Deletes a job by its ID
|
|
136
|
-
*/
|
|
137
|
-
delete(jobId: unknown): Promise<void>;
|
|
138
|
-
/**
|
|
139
|
-
* Delete jobs with a specific status older than a cutoff date
|
|
140
|
-
* @param status - Status of jobs to delete
|
|
141
|
-
* @param olderThanMs - Delete jobs completed more than this many milliseconds ago
|
|
142
|
-
*/
|
|
143
|
-
deleteJobsByStatusAndAge(status: JobStatus, olderThanMs: number): Promise<void>;
|
|
144
|
-
/**
|
|
145
|
-
* Checks if a job from a realtime payload matches the specified prefix filter
|
|
146
|
-
* @param job - The job record from the realtime payload
|
|
147
|
-
* @param prefixFilter - The prefix filter to match against (undefined = use instance prefixes, {} = no filter)
|
|
148
|
-
*/
|
|
149
|
-
private matchesPrefixFilter;
|
|
150
|
-
/**
|
|
151
|
-
* Checks if a prefix filter is custom (different from instance's prefixes).
|
|
152
|
-
*/
|
|
153
|
-
private isCustomPrefixFilter;
|
|
154
|
-
private getAllJobsWithFilter;
|
|
155
|
-
/**
|
|
156
|
-
* Subscribes to changes in the queue.
|
|
157
|
-
* Uses Supabase realtime by default.
|
|
158
|
-
*
|
|
159
|
-
* @param callback - Function called when a change occurs
|
|
160
|
-
* @param options - Subscription options including prefix filter
|
|
161
|
-
* @returns Unsubscribe function
|
|
162
|
-
*/
|
|
163
|
-
subscribeToChanges(callback: (change: QueueChangePayload<Input, Output>) => void, options?: QueueSubscribeOptions): () => void;
|
|
164
|
-
/**
|
|
165
|
-
* Subscribe using Supabase realtime (protected).
|
|
166
|
-
*
|
|
167
|
-
* @param callback - Function called when a change occurs
|
|
168
|
-
* @param prefixFilter - Optional prefix filter (undefined = use instance prefixes, {} = no filter)
|
|
169
|
-
* @returns Unsubscribe function
|
|
170
|
-
*/
|
|
171
|
-
protected subscribeToChangesWithRealtime(callback: (change: QueueChangePayload<Input, Output>) => void, prefixFilter?: Readonly<Record<string, string | number>>): () => void;
|
|
172
|
-
/**
|
|
173
|
-
* Gets or creates the shared polling subscription manager for normal subscriptions (fallback).
|
|
174
|
-
* This ensures all normal subscriptions share a single polling loop per interval.
|
|
175
|
-
*/
|
|
176
|
-
private getPollingManager;
|
|
177
|
-
/**
|
|
178
|
-
* Creates a dedicated polling subscription for custom prefix filters (fallback).
|
|
179
|
-
* This runs separately from the normal polling manager with DB-level filtering.
|
|
180
|
-
*/
|
|
181
|
-
private subscribeWithCustomPrefixFilterPolling;
|
|
182
|
-
/**
|
|
183
|
-
* Subscribe using polling (protected, available as fallback).
|
|
184
|
-
*
|
|
185
|
-
* Normal subscriptions (no custom prefix filter) share a single polling loop for efficiency.
|
|
186
|
-
* Custom prefix filter subscriptions get their own dedicated polling loop with DB-level filtering.
|
|
187
|
-
*
|
|
188
|
-
* @param callback - Function called when a change occurs
|
|
189
|
-
* @param options - Subscription options including interval and prefix filter
|
|
190
|
-
* @returns Unsubscribe function
|
|
191
|
-
*/
|
|
192
|
-
protected subscribeToChangesWithPolling(callback: (change: QueueChangePayload<Input, Output>) => void, options?: QueueSubscribeOptions): () => void;
|
|
193
|
-
}
|
|
194
|
-
//# sourceMappingURL=SupabaseQueueStorage.d.ts.map
|
|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,EAAE,CAAC,MAAM,EAAE,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAC7D,OAAO,CAAC,EAAE,qBAAqB,GAC9B,MAAM,IAAI,CAgBZ;CACF"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import type { IQueueStorage, JobStatus, JobStorageFormat, QueueChangePayload, QueueSubscribeOptions } from "./IQueueStorage";
|
|
7
|
-
/**
|
|
8
|
-
* Telemetry wrapper for any IQueueStorage implementation.
|
|
9
|
-
* Creates spans for all queue storage operations.
|
|
10
|
-
*/
|
|
11
|
-
export declare class TelemetryQueueStorage<Input, Output> implements IQueueStorage<Input, Output> {
|
|
12
|
-
private readonly storageName;
|
|
13
|
-
private readonly inner;
|
|
14
|
-
constructor(storageName: string, inner: IQueueStorage<Input, Output>);
|
|
15
|
-
add(job: JobStorageFormat<Input, Output>): Promise<unknown>;
|
|
16
|
-
get(id: unknown): Promise<JobStorageFormat<Input, Output> | undefined>;
|
|
17
|
-
next(workerId: string): Promise<JobStorageFormat<Input, Output> | undefined>;
|
|
18
|
-
peek(status?: JobStatus, num?: number): Promise<Array<JobStorageFormat<Input, Output>>>;
|
|
19
|
-
size(status?: JobStatus): Promise<number>;
|
|
20
|
-
complete(job: JobStorageFormat<Input, Output>): Promise<void>;
|
|
21
|
-
release(id: unknown): Promise<void>;
|
|
22
|
-
deleteAll(): Promise<void>;
|
|
23
|
-
outputForInput(input: Input): Promise<Output | null>;
|
|
24
|
-
abort(id: unknown): Promise<void>;
|
|
25
|
-
getByRunId(runId: string): Promise<Array<JobStorageFormat<Input, Output>>>;
|
|
26
|
-
saveProgress(id: unknown, progress: number, message: string, details: Record<string, any> | null): Promise<void>;
|
|
27
|
-
delete(id: unknown): Promise<void>;
|
|
28
|
-
deleteJobsByStatusAndAge(status: JobStatus, olderThanMs: number): Promise<void>;
|
|
29
|
-
setupDatabase(): Promise<void>;
|
|
30
|
-
subscribeToChanges(callback: (change: QueueChangePayload<Input, Output>) => void, options?: QueueSubscribeOptions): () => void;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=TelemetryQueueStorage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TelemetryQueueStorage.d.ts","sourceRoot":"","sources":["../../src/queue/TelemetryQueueStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB;;;GAGG;AACH,qBAAa,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAE,YAAW,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC;IAErF,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFxB,YACmB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,EAClD;IAEJ,GAAG,CAAC,GAAG,EAAE,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAE1D;IACD,GAAG,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,CAErE;IACD,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,CAE3E;IACD,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAA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
-
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import type { PrefixColumn } from "../queue/IQueueStorage";
|
|
7
|
-
export declare const RATE_LIMITER_STORAGE: import("@workglow/util").ServiceToken<IRateLimiterStorage>;
|
|
8
|
-
/**
|
|
9
|
-
* Options for configuring rate limiter storage with prefix filters.
|
|
10
|
-
*/
|
|
11
|
-
export interface RateLimiterStorageOptions {
|
|
12
|
-
/** The prefix column definitions for this storage */
|
|
13
|
-
readonly prefixes?: readonly PrefixColumn[];
|
|
14
|
-
/** The values for each prefix column */
|
|
15
|
-
readonly prefixValues?: Readonly<Record<string, string | number>>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Record of a job execution for rate limiting tracking.
|
|
19
|
-
*/
|
|
20
|
-
export interface ExecutionRecord {
|
|
21
|
-
readonly id?: unknown;
|
|
22
|
-
readonly queue_name: string;
|
|
23
|
-
readonly executed_at: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Record of the next available time for a queue.
|
|
27
|
-
*/
|
|
28
|
-
export interface NextAvailableRecord {
|
|
29
|
-
readonly queue_name: string;
|
|
30
|
-
readonly next_available_at: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Interface defining the storage operations for a rate limiter.
|
|
34
|
-
* This separates the storage concerns from the rate limiting logic.
|
|
35
|
-
*/
|
|
36
|
-
export interface IRateLimiterStorage {
|
|
37
|
-
/**
|
|
38
|
-
* Sets up the database schema and tables.
|
|
39
|
-
* This method should be called before using the storage.
|
|
40
|
-
* For production use, database setup should be done via migrations.
|
|
41
|
-
*/
|
|
42
|
-
setupDatabase(): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Records a job execution for rate limiting tracking.
|
|
45
|
-
* @param queueName - The name of the queue
|
|
46
|
-
*/
|
|
47
|
-
recordExecution(queueName: string): Promise<void>;
|
|
48
|
-
/**
|
|
49
|
-
* Gets the count of executions within a time window.
|
|
50
|
-
* @param queueName - The name of the queue
|
|
51
|
-
* @param windowStartTime - The start of the time window (ISO string)
|
|
52
|
-
* @returns The count of executions within the window
|
|
53
|
-
*/
|
|
54
|
-
getExecutionCount(queueName: string, windowStartTime: string): Promise<number>;
|
|
55
|
-
/**
|
|
56
|
-
* Gets the oldest execution time within the window, offset by a count.
|
|
57
|
-
* Used to calculate when the rate limit will allow the next execution.
|
|
58
|
-
* @param queueName - The name of the queue
|
|
59
|
-
* @param offset - The offset (typically maxExecutions - 1)
|
|
60
|
-
* @returns The execution time or undefined if not enough executions
|
|
61
|
-
*/
|
|
62
|
-
getOldestExecutionAtOffset(queueName: string, offset: number): Promise<string | undefined>;
|
|
63
|
-
/**
|
|
64
|
-
* Gets the next available time for a queue.
|
|
65
|
-
* @param queueName - The name of the queue
|
|
66
|
-
* @returns The next available time or undefined if not set
|
|
67
|
-
*/
|
|
68
|
-
getNextAvailableTime(queueName: string): Promise<string | undefined>;
|
|
69
|
-
/**
|
|
70
|
-
* Sets the next available time for a queue.
|
|
71
|
-
* @param queueName - The name of the queue
|
|
72
|
-
* @param nextAvailableAt - The next available time (ISO string)
|
|
73
|
-
*/
|
|
74
|
-
setNextAvailableTime(queueName: string, nextAvailableAt: string): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* Clears all rate limit entries for a queue.
|
|
77
|
-
* @param queueName - The name of the queue
|
|
78
|
-
*/
|
|
79
|
-
clear(queueName: string): Promise<void>;
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=IRateLimiterStorage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IRateLimiterStorage.d.ts","sourceRoot":"","sources":["../../src/queue-limiter/IRateLimiterStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,eAAO,MAAM,oBAAoB,4DAAiE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IACH,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { IRateLimiterStorage, RateLimiterStorageOptions } from "./IRateLimiterStorage";
|
|
7
|
-
export declare const IN_MEMORY_RATE_LIMITER_STORAGE: import("@workglow/util").ServiceToken<IRateLimiterStorage>;
|
|
8
|
-
/**
|
|
9
|
-
* In-memory implementation of rate limiter storage.
|
|
10
|
-
* Manages execution records and next available times for rate limiting.
|
|
11
|
-
*/
|
|
12
|
-
export declare class InMemoryRateLimiterStorage implements IRateLimiterStorage {
|
|
13
|
-
/** The prefix values for filtering */
|
|
14
|
-
protected readonly prefixValues: Readonly<Record<string, string | number>>;
|
|
15
|
-
/** Execution records keyed by a composite of prefix values and queue name */
|
|
16
|
-
private readonly executions;
|
|
17
|
-
/** Next available times keyed by a composite of prefix values and queue name */
|
|
18
|
-
private readonly nextAvailableTimes;
|
|
19
|
-
constructor(options?: RateLimiterStorageOptions);
|
|
20
|
-
/**
|
|
21
|
-
* Creates a storage key from the queue name and prefix values.
|
|
22
|
-
*/
|
|
23
|
-
private makeKey;
|
|
24
|
-
setupDatabase(): Promise<void>;
|
|
25
|
-
recordExecution(queueName: string): Promise<void>;
|
|
26
|
-
getExecutionCount(queueName: string, windowStartTime: string): Promise<number>;
|
|
27
|
-
getOldestExecutionAtOffset(queueName: string, offset: number): Promise<string | undefined>;
|
|
28
|
-
getNextAvailableTime(queueName: string): Promise<string | undefined>;
|
|
29
|
-
setNextAvailableTime(queueName: string, nextAvailableAt: string): Promise<void>;
|
|
30
|
-
clear(queueName: string): Promise<void>;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=InMemoryRateLimiterStorage.d.ts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,CAAC,CAKnD;CACF"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { MigrationOptions } from "../util/IndexedDbTable";
|
|
7
|
-
import type { PrefixColumn } from "../queue/IQueueStorage";
|
|
8
|
-
import { IRateLimiterStorage, RateLimiterStorageOptions } from "./IRateLimiterStorage";
|
|
9
|
-
export declare const INDEXED_DB_RATE_LIMITER_STORAGE: import("@workglow/util").ServiceToken<IRateLimiterStorage>;
|
|
10
|
-
/**
|
|
11
|
-
* Extended options for IndexedDB rate limiter storage including prefix support.
|
|
12
|
-
*/
|
|
13
|
-
export interface IndexedDbRateLimiterStorageOptions extends RateLimiterStorageOptions, MigrationOptions {
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* IndexedDB implementation of rate limiter storage.
|
|
17
|
-
* Manages execution records and next available times for rate limiting.
|
|
18
|
-
*/
|
|
19
|
-
export declare class IndexedDbRateLimiterStorage implements IRateLimiterStorage {
|
|
20
|
-
private executionDb;
|
|
21
|
-
private nextAvailableDb;
|
|
22
|
-
private readonly executionTableName;
|
|
23
|
-
private readonly nextAvailableTableName;
|
|
24
|
-
private readonly migrationOptions;
|
|
25
|
-
/** The prefix column definitions */
|
|
26
|
-
protected readonly prefixes: readonly PrefixColumn[];
|
|
27
|
-
/** The prefix values for filtering */
|
|
28
|
-
protected readonly prefixValues: Readonly<Record<string, string | number>>;
|
|
29
|
-
constructor(options?: IndexedDbRateLimiterStorageOptions);
|
|
30
|
-
/**
|
|
31
|
-
* Gets prefix column names for use in indexes.
|
|
32
|
-
*/
|
|
33
|
-
private getPrefixColumnNames;
|
|
34
|
-
/**
|
|
35
|
-
* Checks if a record matches the current prefix values.
|
|
36
|
-
*/
|
|
37
|
-
private matchesPrefixes;
|
|
38
|
-
/**
|
|
39
|
-
* Gets prefix values as an array in column order for index key construction.
|
|
40
|
-
*/
|
|
41
|
-
private getPrefixKeyValues;
|
|
42
|
-
private getExecutionDb;
|
|
43
|
-
private getNextAvailableDb;
|
|
44
|
-
setupDatabase(): Promise<void>;
|
|
45
|
-
recordExecution(queueName: string): Promise<void>;
|
|
46
|
-
getExecutionCount(queueName: string, windowStartTime: string): Promise<number>;
|
|
47
|
-
getOldestExecutionAtOffset(queueName: string, offset: number): Promise<string | undefined>;
|
|
48
|
-
getNextAvailableTime(queueName: string): Promise<string | undefined>;
|
|
49
|
-
setNextAvailableTime(queueName: string, nextAvailableAt: string): Promise<void>;
|
|
50
|
-
clear(queueName: string): Promise<void>;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=IndexedDbRateLimiterStorage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedDbRateLimiterStorage.d.ts","sourceRoot":"","sources":["../../src/queue-limiter/IndexedDbRateLimiterStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAGL,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAEvF,eAAO,MAAM,+BAA+B,4DAE3C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,kCACf,SAAQ,yBAAyB,EAAE,gBAAgB;CAAG;AAqBxD;;;GAGG;AACH,qBAAa,2BAA4B,YAAW,mBAAmB;IACrE,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,eAAe,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAS;IAC5C,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAS;IAChD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IACpD,oCAAoC;IACpC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;IACrD,sCAAsC;IACtC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;IAE3E,YAAY,OAAO,GAAE,kCAAuC,EAc3D;IAED;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAI5B;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;OAEG;IACH,OAAO,CAAC,kBAAkB;YAIZ,cAAc;YAMd,kBAAkB;IAMnB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAqC1C;IAEY,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB7D;IAEY,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAgC1F;IAEY,0BAA0B,CACrC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAkC7B;IAEY,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAoBhF;IAEY,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4B3F;IAEY,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2CnD;CACF"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import type { Pool } from "@workglow/storage/postgres";
|
|
7
|
-
import type { PrefixColumn } from "../queue/IQueueStorage";
|
|
8
|
-
import { IRateLimiterStorage, RateLimiterStorageOptions } from "./IRateLimiterStorage";
|
|
9
|
-
export declare const POSTGRES_RATE_LIMITER_STORAGE: import("@workglow/util").ServiceToken<IRateLimiterStorage>;
|
|
10
|
-
/**
|
|
11
|
-
* PostgreSQL implementation of rate limiter storage.
|
|
12
|
-
* Manages execution records and next available times for rate limiting.
|
|
13
|
-
*/
|
|
14
|
-
export declare class PostgresRateLimiterStorage implements IRateLimiterStorage {
|
|
15
|
-
protected readonly db: Pool;
|
|
16
|
-
/** The prefix column definitions */
|
|
17
|
-
protected readonly prefixes: readonly PrefixColumn[];
|
|
18
|
-
/** The prefix values for filtering */
|
|
19
|
-
protected readonly prefixValues: Readonly<Record<string, string | number>>;
|
|
20
|
-
/** The table name for execution tracking */
|
|
21
|
-
protected readonly executionTableName: string;
|
|
22
|
-
/** The table name for next available times */
|
|
23
|
-
protected readonly nextAvailableTableName: string;
|
|
24
|
-
constructor(db: Pool, options?: RateLimiterStorageOptions);
|
|
25
|
-
/**
|
|
26
|
-
* Gets the SQL column type for a prefix column.
|
|
27
|
-
*/
|
|
28
|
-
private getPrefixColumnType;
|
|
29
|
-
/**
|
|
30
|
-
* Builds the prefix columns SQL for CREATE TABLE.
|
|
31
|
-
*/
|
|
32
|
-
private buildPrefixColumnsSql;
|
|
33
|
-
/**
|
|
34
|
-
* Builds prefix column names for use in queries.
|
|
35
|
-
*/
|
|
36
|
-
private getPrefixColumnNames;
|
|
37
|
-
/**
|
|
38
|
-
* Builds WHERE clause conditions for prefix filtering.
|
|
39
|
-
* @param startParam - The starting parameter number for parameterized queries
|
|
40
|
-
*/
|
|
41
|
-
private buildPrefixWhereClause;
|
|
42
|
-
/**
|
|
43
|
-
* Gets prefix values as an array in column order.
|
|
44
|
-
*/
|
|
45
|
-
private getPrefixParamValues;
|
|
46
|
-
setupDatabase(): Promise<void>;
|
|
47
|
-
recordExecution(queueName: string): Promise<void>;
|
|
48
|
-
getExecutionCount(queueName: string, windowStartTime: string): Promise<number>;
|
|
49
|
-
getOldestExecutionAtOffset(queueName: string, offset: number): Promise<string | undefined>;
|
|
50
|
-
getNextAvailableTime(queueName: string): Promise<string | undefined>;
|
|
51
|
-
setNextAvailableTime(queueName: string, nextAvailableAt: string): Promise<void>;
|
|
52
|
-
clear(queueName: string): Promise<void>;
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=PostgresRateLimiterStorage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresRateLimiterStorage.d.ts","sourceRoot":"","sources":["../../src/queue-limiter/PostgresRateLimiterStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAEvF,eAAO,MAAM,6BAA6B,4DAEzC,CAAC;AAEF;;;GAGG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IAWlE,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI;IAV7B,oCAAoC;IACpC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;IACrD,sCAAsC;IACtC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;IAC3E,4CAA4C;IAC5C,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAC9C,8CAA8C;IAC9C,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;IAElD,YACqB,EAAE,EAAE,IAAI,EAC3B,OAAO,CAAC,EAAE,yBAAyB,EAcpC;IAED;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAI3B;;OAEG;IACH,OAAO,CAAC,q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