@gravito/stream 1.0.0-alpha.6 → 1.0.0-beta.2
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/README.md +94 -5
- package/dist/index.cjs +2265 -31639
- package/dist/index.d.cts +1814 -0
- package/dist/index.d.ts +1805 -36
- package/dist/index.js +2700 -0
- package/package.json +11 -7
- package/dist/Consumer.d.ts +0 -67
- package/dist/Consumer.d.ts.map +0 -1
- package/dist/Job.d.ts +0 -76
- package/dist/Job.d.ts.map +0 -1
- package/dist/OrbitQueue.d.ts +0 -74
- package/dist/OrbitQueue.d.ts.map +0 -1
- package/dist/QueueManager.d.ts +0 -86
- package/dist/QueueManager.d.ts.map +0 -1
- package/dist/Queueable.d.ts +0 -63
- package/dist/Queueable.d.ts.map +0 -1
- package/dist/Worker.d.ts +0 -48
- package/dist/Worker.d.ts.map +0 -1
- package/dist/core/src/ConfigManager.d.ts +0 -26
- package/dist/core/src/ConfigManager.d.ts.map +0 -1
- package/dist/core/src/Container.d.ts +0 -39
- package/dist/core/src/Container.d.ts.map +0 -1
- package/dist/core/src/Event.d.ts +0 -6
- package/dist/core/src/Event.d.ts.map +0 -1
- package/dist/core/src/EventManager.d.ts +0 -124
- package/dist/core/src/EventManager.d.ts.map +0 -1
- package/dist/core/src/GlobalErrorHandlers.d.ts +0 -32
- package/dist/core/src/GlobalErrorHandlers.d.ts.map +0 -1
- package/dist/core/src/HookManager.d.ts +0 -29
- package/dist/core/src/HookManager.d.ts.map +0 -1
- package/dist/core/src/Listener.d.ts +0 -5
- package/dist/core/src/Listener.d.ts.map +0 -1
- package/dist/core/src/Logger.d.ts +0 -21
- package/dist/core/src/Logger.d.ts.map +0 -1
- package/dist/core/src/PlanetCore.d.ts +0 -116
- package/dist/core/src/PlanetCore.d.ts.map +0 -1
- package/dist/core/src/Route.d.ts +0 -13
- package/dist/core/src/Route.d.ts.map +0 -1
- package/dist/core/src/Router.d.ts +0 -168
- package/dist/core/src/Router.d.ts.map +0 -1
- package/dist/core/src/ServiceProvider.d.ts +0 -17
- package/dist/core/src/ServiceProvider.d.ts.map +0 -1
- package/dist/core/src/exceptions/AuthenticationException.d.ts +0 -5
- package/dist/core/src/exceptions/AuthenticationException.d.ts.map +0 -1
- package/dist/core/src/exceptions/AuthorizationException.d.ts +0 -5
- package/dist/core/src/exceptions/AuthorizationException.d.ts.map +0 -1
- package/dist/core/src/exceptions/GravitoException.d.ts +0 -15
- package/dist/core/src/exceptions/GravitoException.d.ts.map +0 -1
- package/dist/core/src/exceptions/ModelNotFoundException.d.ts +0 -7
- package/dist/core/src/exceptions/ModelNotFoundException.d.ts.map +0 -1
- package/dist/core/src/exceptions/ValidationException.d.ts +0 -15
- package/dist/core/src/exceptions/ValidationException.d.ts.map +0 -1
- package/dist/core/src/exceptions/index.d.ts +0 -6
- package/dist/core/src/exceptions/index.d.ts.map +0 -1
- package/dist/core/src/helpers/Arr.d.ts +0 -15
- package/dist/core/src/helpers/Arr.d.ts.map +0 -1
- package/dist/core/src/helpers/Str.d.ts +0 -19
- package/dist/core/src/helpers/Str.d.ts.map +0 -1
- package/dist/core/src/helpers/data.d.ts +0 -6
- package/dist/core/src/helpers/data.d.ts.map +0 -1
- package/dist/core/src/helpers/errors.d.ts +0 -13
- package/dist/core/src/helpers/errors.d.ts.map +0 -1
- package/dist/core/src/helpers/response.d.ts +0 -19
- package/dist/core/src/helpers/response.d.ts.map +0 -1
- package/dist/core/src/helpers.d.ts +0 -39
- package/dist/core/src/helpers.d.ts.map +0 -1
- package/dist/core/src/http/CookieJar.d.ts +0 -34
- package/dist/core/src/http/CookieJar.d.ts.map +0 -1
- package/dist/core/src/http/middleware/ThrottleRequests.d.ts +0 -13
- package/dist/core/src/http/middleware/ThrottleRequests.d.ts.map +0 -1
- package/dist/core/src/index.d.ts +0 -32
- package/dist/core/src/index.d.ts.map +0 -1
- package/dist/core/src/security/Encrypter.d.ts +0 -25
- package/dist/core/src/security/Encrypter.d.ts.map +0 -1
- package/dist/core/src/security/Hasher.d.ts +0 -30
- package/dist/core/src/security/Hasher.d.ts.map +0 -1
- package/dist/core/src/types/events.d.ts +0 -95
- package/dist/core/src/types/events.d.ts.map +0 -1
- package/dist/drivers/DatabaseDriver.d.ts +0 -60
- package/dist/drivers/DatabaseDriver.d.ts.map +0 -1
- package/dist/drivers/KafkaDriver.d.ts +0 -134
- package/dist/drivers/KafkaDriver.d.ts.map +0 -1
- package/dist/drivers/MemoryDriver.d.ts +0 -45
- package/dist/drivers/MemoryDriver.d.ts.map +0 -1
- package/dist/drivers/QueueDriver.d.ts +0 -89
- package/dist/drivers/QueueDriver.d.ts.map +0 -1
- package/dist/drivers/RedisDriver.d.ts +0 -79
- package/dist/drivers/RedisDriver.d.ts.map +0 -1
- package/dist/drivers/SQSDriver.d.ts +0 -100
- package/dist/drivers/SQSDriver.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -422
- package/dist/index.d.ts.map +0 -1
- package/dist/index.mjs +0 -32096
- package/dist/index.mjs.map +0 -422
- package/dist/orbit-db/src/DBService.d.ts +0 -270
- package/dist/orbit-db/src/DBService.d.ts.map +0 -1
- package/dist/orbit-db/src/EventBus.d.ts +0 -53
- package/dist/orbit-db/src/EventBus.d.ts.map +0 -1
- package/dist/orbit-db/src/MigrationDriver.d.ts +0 -55
- package/dist/orbit-db/src/MigrationDriver.d.ts.map +0 -1
- package/dist/orbit-db/src/Model.d.ts +0 -564
- package/dist/orbit-db/src/Model.d.ts.map +0 -1
- package/dist/orbit-db/src/ModelCollection.d.ts +0 -35
- package/dist/orbit-db/src/ModelCollection.d.ts.map +0 -1
- package/dist/orbit-db/src/index.d.ts +0 -34
- package/dist/orbit-db/src/index.d.ts.map +0 -1
- package/dist/orbit-db/src/types.d.ts +0 -146
- package/dist/orbit-db/src/types.d.ts.map +0 -1
- package/dist/orbit-queue/src/Consumer.d.ts +0 -67
- package/dist/orbit-queue/src/Consumer.d.ts.map +0 -1
- package/dist/orbit-queue/src/Job.d.ts +0 -76
- package/dist/orbit-queue/src/Job.d.ts.map +0 -1
- package/dist/orbit-queue/src/OrbitQueue.d.ts +0 -74
- package/dist/orbit-queue/src/OrbitQueue.d.ts.map +0 -1
- package/dist/orbit-queue/src/QueueManager.d.ts +0 -86
- package/dist/orbit-queue/src/QueueManager.d.ts.map +0 -1
- package/dist/orbit-queue/src/Queueable.d.ts +0 -63
- package/dist/orbit-queue/src/Queueable.d.ts.map +0 -1
- package/dist/orbit-queue/src/Worker.d.ts +0 -48
- package/dist/orbit-queue/src/Worker.d.ts.map +0 -1
- package/dist/orbit-queue/src/drivers/DatabaseDriver.d.ts +0 -60
- package/dist/orbit-queue/src/drivers/DatabaseDriver.d.ts.map +0 -1
- package/dist/orbit-queue/src/drivers/KafkaDriver.d.ts +0 -134
- package/dist/orbit-queue/src/drivers/KafkaDriver.d.ts.map +0 -1
- package/dist/orbit-queue/src/drivers/MemoryDriver.d.ts +0 -45
- package/dist/orbit-queue/src/drivers/MemoryDriver.d.ts.map +0 -1
- package/dist/orbit-queue/src/drivers/QueueDriver.d.ts +0 -89
- package/dist/orbit-queue/src/drivers/QueueDriver.d.ts.map +0 -1
- package/dist/orbit-queue/src/drivers/RedisDriver.d.ts +0 -79
- package/dist/orbit-queue/src/drivers/RedisDriver.d.ts.map +0 -1
- package/dist/orbit-queue/src/drivers/SQSDriver.d.ts +0 -100
- package/dist/orbit-queue/src/drivers/SQSDriver.d.ts.map +0 -1
- package/dist/orbit-queue/src/index.d.ts +0 -45
- package/dist/orbit-queue/src/index.d.ts.map +0 -1
- package/dist/orbit-queue/src/serializers/ClassNameSerializer.d.ts +0 -46
- package/dist/orbit-queue/src/serializers/ClassNameSerializer.d.ts.map +0 -1
- package/dist/orbit-queue/src/serializers/JobSerializer.d.ts +0 -36
- package/dist/orbit-queue/src/serializers/JobSerializer.d.ts.map +0 -1
- package/dist/orbit-queue/src/serializers/JsonSerializer.d.ts +0 -32
- package/dist/orbit-queue/src/serializers/JsonSerializer.d.ts.map +0 -1
- package/dist/orbit-queue/src/types.d.ts +0 -85
- package/dist/orbit-queue/src/types.d.ts.map +0 -1
- package/dist/serializers/ClassNameSerializer.d.ts +0 -46
- package/dist/serializers/ClassNameSerializer.d.ts.map +0 -1
- package/dist/serializers/JobSerializer.d.ts +0 -36
- package/dist/serializers/JobSerializer.d.ts.map +0 -1
- package/dist/serializers/JsonSerializer.d.ts +0 -32
- package/dist/serializers/JsonSerializer.d.ts.map +0 -1
- package/dist/types.d.ts +0 -85
- package/dist/types.d.ts.map +0 -1
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Database type.
|
|
3
|
-
*/
|
|
4
|
-
export type DatabaseType = 'postgresql' | 'sqlite' | 'mysql' | 'auto';
|
|
5
|
-
/**
|
|
6
|
-
* Pagination options.
|
|
7
|
-
*/
|
|
8
|
-
export interface PaginateOptions {
|
|
9
|
-
page: number;
|
|
10
|
-
limit: number;
|
|
11
|
-
orderBy?: unknown;
|
|
12
|
-
orderDirection?: 'asc' | 'desc';
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Pagination result.
|
|
16
|
-
*/
|
|
17
|
-
export interface PaginateResult<T> {
|
|
18
|
-
data: T[];
|
|
19
|
-
pagination: {
|
|
20
|
-
page: number;
|
|
21
|
-
limit: number;
|
|
22
|
-
total: number;
|
|
23
|
-
totalPages: number;
|
|
24
|
-
hasNext: boolean;
|
|
25
|
-
hasPrev: boolean;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Health check result.
|
|
30
|
-
*/
|
|
31
|
-
export interface HealthCheckResult {
|
|
32
|
-
healthy?: boolean | undefined;
|
|
33
|
-
status?: string | undefined;
|
|
34
|
-
message?: string | undefined;
|
|
35
|
-
duration?: number | undefined;
|
|
36
|
-
latency?: number | undefined;
|
|
37
|
-
error?: string | undefined;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Query log info.
|
|
41
|
-
*/
|
|
42
|
-
export interface QueryLogInfo {
|
|
43
|
-
query: string;
|
|
44
|
-
params: unknown[];
|
|
45
|
-
duration: number;
|
|
46
|
-
timestamp: number;
|
|
47
|
-
error?: string;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Migration result.
|
|
51
|
-
*/
|
|
52
|
-
export interface MigrateResult {
|
|
53
|
-
success: boolean;
|
|
54
|
-
migrationsApplied?: number | undefined;
|
|
55
|
-
appliedMigrations?: string[] | undefined;
|
|
56
|
-
message?: string | undefined;
|
|
57
|
-
error?: string | undefined;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Seed function.
|
|
61
|
-
*/
|
|
62
|
-
export type SeedFunction = (db: any) => Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Seed result.
|
|
65
|
-
*/
|
|
66
|
-
export interface SeedResult {
|
|
67
|
-
success: boolean;
|
|
68
|
-
seedName?: string | undefined;
|
|
69
|
-
seededFiles?: string[] | undefined;
|
|
70
|
-
message?: string | undefined;
|
|
71
|
-
error?: string | undefined;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Deployment options.
|
|
75
|
-
*/
|
|
76
|
-
export interface DeployOptions {
|
|
77
|
-
skipHealthCheck?: boolean;
|
|
78
|
-
skipMigrations?: boolean;
|
|
79
|
-
skipSeeding?: boolean;
|
|
80
|
-
runMigrations?: boolean;
|
|
81
|
-
runSeeds?: boolean;
|
|
82
|
-
validateBeforeDeploy?: boolean;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Deployment result.
|
|
86
|
-
*/
|
|
87
|
-
export interface DeployResult {
|
|
88
|
-
success: boolean;
|
|
89
|
-
healthCheck?: HealthCheckResult | undefined;
|
|
90
|
-
migrations?: MigrateResult | undefined;
|
|
91
|
-
seeding?: SeedResult[] | undefined;
|
|
92
|
-
seeds?: SeedResult | SeedResult[] | undefined;
|
|
93
|
-
message?: string | undefined;
|
|
94
|
-
duration?: number | undefined;
|
|
95
|
-
error?: string | undefined;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Relation query options.
|
|
99
|
-
*/
|
|
100
|
-
export interface RelationOptions {
|
|
101
|
-
[relationName: string]: boolean | RelationOptions;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Upsert options.
|
|
105
|
-
*/
|
|
106
|
-
export interface UpsertOptions {
|
|
107
|
-
conflictColumns?: string[];
|
|
108
|
-
updateColumns?: string[];
|
|
109
|
-
excludeColumns?: string[];
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Increment/Decrement options.
|
|
113
|
-
*/
|
|
114
|
-
export interface IncrementOptions {
|
|
115
|
-
amount?: number;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Truncate options.
|
|
119
|
-
*/
|
|
120
|
-
export interface TruncateOptions {
|
|
121
|
-
cascade?: boolean;
|
|
122
|
-
restartIdentity?: boolean;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Lock options.
|
|
126
|
-
*/
|
|
127
|
-
export interface LockOptions {
|
|
128
|
-
nowait?: boolean;
|
|
129
|
-
skipLocked?: boolean;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Execute options.
|
|
133
|
-
*/
|
|
134
|
-
export interface ExecuteOptions {
|
|
135
|
-
params?: unknown[];
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Event source info.
|
|
139
|
-
*/
|
|
140
|
-
export interface EventSource {
|
|
141
|
-
file?: string | undefined;
|
|
142
|
-
line?: number | undefined;
|
|
143
|
-
method?: string | undefined;
|
|
144
|
-
stack?: string | undefined;
|
|
145
|
-
}
|
|
146
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../orbit-db/src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,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IAC9B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,GAAG,eAAe,CAAA;CAClD;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAC1B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,OAAO,EAAE,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC3B"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { QueueManager } from './QueueManager';
|
|
2
|
-
import type { WorkerOptions } from './Worker';
|
|
3
|
-
/**
|
|
4
|
-
* Consumer options.
|
|
5
|
-
*/
|
|
6
|
-
export interface ConsumerOptions {
|
|
7
|
-
/**
|
|
8
|
-
* Queues to listen on.
|
|
9
|
-
*/
|
|
10
|
-
queues: string[];
|
|
11
|
-
/**
|
|
12
|
-
* Connection name.
|
|
13
|
-
*/
|
|
14
|
-
connection?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Worker options.
|
|
17
|
-
*/
|
|
18
|
-
workerOptions?: WorkerOptions;
|
|
19
|
-
/**
|
|
20
|
-
* Polling interval (milliseconds).
|
|
21
|
-
*/
|
|
22
|
-
pollInterval?: number;
|
|
23
|
-
/**
|
|
24
|
-
* Whether to keep polling when queues are empty.
|
|
25
|
-
*/
|
|
26
|
-
keepAlive?: boolean;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Consumer
|
|
30
|
-
*
|
|
31
|
-
* Consumes and executes jobs from queues.
|
|
32
|
-
* Supports embedded mode (inside the main app) and standalone mode (as a worker service).
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```typescript
|
|
36
|
-
* // Embedded mode
|
|
37
|
-
* const consumer = new Consumer(queueManager, {
|
|
38
|
-
* queues: ['default', 'emails'],
|
|
39
|
-
* pollInterval: 1000
|
|
40
|
-
* })
|
|
41
|
-
*
|
|
42
|
-
* consumer.start()
|
|
43
|
-
*
|
|
44
|
-
* // Standalone mode (CLI)
|
|
45
|
-
* // Start via CLI tooling with graceful shutdown
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export declare class Consumer {
|
|
49
|
-
private queueManager;
|
|
50
|
-
private options;
|
|
51
|
-
private running;
|
|
52
|
-
private stopRequested;
|
|
53
|
-
constructor(queueManager: QueueManager, options: ConsumerOptions);
|
|
54
|
-
/**
|
|
55
|
-
* Start the consumer loop.
|
|
56
|
-
*/
|
|
57
|
-
start(): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Stop the consumer loop (graceful shutdown).
|
|
60
|
-
*/
|
|
61
|
-
stop(): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Check whether the consumer is running.
|
|
64
|
-
*/
|
|
65
|
-
isRunning(): boolean;
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=Consumer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Consumer.d.ts","sourceRoot":"","sources":["../../../src/Consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAG7C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAA;IAEhB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAE7B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,QAAQ;IAKjB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,OAAO;IALjB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,aAAa,CAAQ;gBAGnB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,eAAe;IAGlC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAmD5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAU3B;;OAEG;IACH,SAAS,IAAI,OAAO;CAGrB"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { Queueable } from './Queueable';
|
|
2
|
-
/**
|
|
3
|
-
* Base Job.
|
|
4
|
-
*
|
|
5
|
-
* All tasks that should be pushed to a queue should extend this class.
|
|
6
|
-
* Implements the `Queueable` interface, providing a fluent API for queue/connection/delay.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* class SendWelcomeEmail extends Job {
|
|
11
|
-
* constructor(private userId: string) {
|
|
12
|
-
* super()
|
|
13
|
-
* }
|
|
14
|
-
*
|
|
15
|
-
* async handle(): Promise<void> {
|
|
16
|
-
* const user = await User.find(this.userId)
|
|
17
|
-
* await mail.send(new WelcomeEmail(user))
|
|
18
|
-
* }
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* // Usage
|
|
22
|
-
* await queue.push(new SendWelcomeEmail('123'))
|
|
23
|
-
* .onQueue('emails')
|
|
24
|
-
* .delay(60)
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare abstract class Job implements Queueable {
|
|
28
|
-
/**
|
|
29
|
-
* Queue name.
|
|
30
|
-
*/
|
|
31
|
-
queueName?: string;
|
|
32
|
-
/**
|
|
33
|
-
* Connection name.
|
|
34
|
-
*/
|
|
35
|
-
connectionName?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Delay before execution (seconds).
|
|
38
|
-
*/
|
|
39
|
-
delaySeconds?: number;
|
|
40
|
-
/**
|
|
41
|
-
* Current attempt number.
|
|
42
|
-
*/
|
|
43
|
-
attempts?: number;
|
|
44
|
-
/**
|
|
45
|
-
* Maximum attempts.
|
|
46
|
-
*/
|
|
47
|
-
maxAttempts?: number;
|
|
48
|
-
/**
|
|
49
|
-
* Set target queue.
|
|
50
|
-
*/
|
|
51
|
-
onQueue(queue: string): this;
|
|
52
|
-
/**
|
|
53
|
-
* Set target connection.
|
|
54
|
-
*/
|
|
55
|
-
onConnection(connection: string): this;
|
|
56
|
-
/**
|
|
57
|
-
* Set delay (seconds).
|
|
58
|
-
*/
|
|
59
|
-
delay(delay: number): this;
|
|
60
|
-
/**
|
|
61
|
-
* Job handler logic.
|
|
62
|
-
*
|
|
63
|
-
* Subclasses must implement this method.
|
|
64
|
-
*/
|
|
65
|
-
abstract handle(): Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* Failure handler (optional).
|
|
68
|
-
*
|
|
69
|
-
* Called when the job fails and reaches the maximum number of attempts.
|
|
70
|
-
* Subclasses can override to implement custom failure handling.
|
|
71
|
-
*
|
|
72
|
-
* @param error - Error instance
|
|
73
|
-
*/
|
|
74
|
-
failed(_error: Error): Promise<void>;
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=Job.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Job.d.ts","sourceRoot":"","sources":["../../../src/Job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,8BAAsB,GAAI,YAAW,SAAS;IAC5C;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK5B;;OAEG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAKtC;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK1B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAEhC;;;;;;;OAOG;IACG,MAAM,CAAC,MAAM,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3C"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { GravitoOrbit, PlanetCore } from 'gravito-core';
|
|
2
|
-
import type { ConsumerOptions } from './Consumer';
|
|
3
|
-
import { QueueManager } from './QueueManager';
|
|
4
|
-
import type { QueueConfig } from './types';
|
|
5
|
-
/**
|
|
6
|
-
* Orbit Queue configuration options.
|
|
7
|
-
*/
|
|
8
|
-
export interface OrbitQueueOptions extends QueueConfig {
|
|
9
|
-
/**
|
|
10
|
-
* Whether to auto-start an embedded worker in development.
|
|
11
|
-
*/
|
|
12
|
-
autoStartWorker?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Embedded worker options.
|
|
15
|
-
*/
|
|
16
|
-
workerOptions?: ConsumerOptions;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Orbit Queue
|
|
20
|
-
*
|
|
21
|
-
* Gravito Orbit implementation providing queue functionality.
|
|
22
|
-
* Integrates with PlanetCore and injects a `queue` service into the Hono Context.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* const core = await PlanetCore.boot({
|
|
27
|
-
* orbits: [
|
|
28
|
-
* OrbitQueue.configure({
|
|
29
|
-
* default: 'database',
|
|
30
|
-
* connections: {
|
|
31
|
-
* database: { driver: 'database', table: 'jobs' }
|
|
32
|
-
* }
|
|
33
|
-
* })
|
|
34
|
-
* ]
|
|
35
|
-
* })
|
|
36
|
-
*
|
|
37
|
-
* // Use in a controller/handler
|
|
38
|
-
* const queue = c.get('queue')
|
|
39
|
-
* await queue.push(new SendEmail('user@example.com'))
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare class OrbitQueue implements GravitoOrbit {
|
|
43
|
-
private options;
|
|
44
|
-
private queueManager?;
|
|
45
|
-
private consumer?;
|
|
46
|
-
constructor(options?: OrbitQueueOptions);
|
|
47
|
-
/**
|
|
48
|
-
* Static configuration helper.
|
|
49
|
-
*/
|
|
50
|
-
static configure(options: OrbitQueueOptions): OrbitQueue;
|
|
51
|
-
/**
|
|
52
|
-
* Install into PlanetCore.
|
|
53
|
-
*/
|
|
54
|
-
install(core: PlanetCore): void;
|
|
55
|
-
/**
|
|
56
|
-
* Start embedded worker.
|
|
57
|
-
*/
|
|
58
|
-
startWorker(options: ConsumerOptions): void;
|
|
59
|
-
/**
|
|
60
|
-
* Stop embedded worker.
|
|
61
|
-
*/
|
|
62
|
-
stopWorker(): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Get QueueManager instance.
|
|
65
|
-
*/
|
|
66
|
-
getQueueManager(): QueueManager | undefined;
|
|
67
|
-
}
|
|
68
|
-
declare module 'hono' {
|
|
69
|
-
interface ContextVariableMap {
|
|
70
|
-
queue: QueueManager;
|
|
71
|
-
db?: unknown;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=OrbitQueue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OrbitQueue.d.ts","sourceRoot":"","sources":["../../../src/OrbitQueue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IACpD;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IAEzB;;OAEG;IACH,aAAa,CAAC,EAAE,eAAe,CAAA;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,UAAW,YAAW,YAAY;IAIjC,OAAO,CAAC,OAAO;IAH3B,OAAO,CAAC,YAAY,CAAC,CAAc;IACnC,OAAO,CAAC,QAAQ,CAAC,CAAU;gBAEP,OAAO,GAAE,iBAAsB;IAEnD;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU;IAIxD;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAqD/B;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAe3C;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAMjC;;OAEG;IACH,eAAe,IAAI,YAAY,GAAG,SAAS;CAG5C;AAED,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,kBAAkB;QAC1B,KAAK,EAAE,YAAY,CAAA;QACnB,EAAE,CAAC,EAAE,OAAO,CAAA;KACb;CACF"}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import type { QueueDriver } from './drivers/QueueDriver';
|
|
2
|
-
import type { Job } from './Job';
|
|
3
|
-
import type { Queueable } from './Queueable';
|
|
4
|
-
import type { JobSerializer } from './serializers/JobSerializer';
|
|
5
|
-
import type { QueueConfig } from './types';
|
|
6
|
-
/**
|
|
7
|
-
* Queue Manager
|
|
8
|
-
*
|
|
9
|
-
* Manages multiple queue connections and drivers, exposing a unified API for pushing and consuming jobs.
|
|
10
|
-
* Supports lazy-loading drivers to keep the core lightweight.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const manager = new QueueManager({
|
|
15
|
-
* default: 'database',
|
|
16
|
-
* connections: {
|
|
17
|
-
* database: { driver: 'database', table: 'jobs' },
|
|
18
|
-
* redis: { driver: 'redis', url: 'redis://...' }
|
|
19
|
-
* }
|
|
20
|
-
* })
|
|
21
|
-
*
|
|
22
|
-
* await manager.push(new SendEmail('user@example.com'))
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export declare class QueueManager {
|
|
26
|
-
private drivers;
|
|
27
|
-
private serializers;
|
|
28
|
-
private defaultConnection;
|
|
29
|
-
private defaultSerializer;
|
|
30
|
-
constructor(config?: QueueConfig);
|
|
31
|
-
/**
|
|
32
|
-
* Register a connection.
|
|
33
|
-
* @param name - Connection name
|
|
34
|
-
* @param config - Connection config
|
|
35
|
-
*/
|
|
36
|
-
registerConnection(name: string, config: unknown): void;
|
|
37
|
-
/**
|
|
38
|
-
* Get a driver for a connection.
|
|
39
|
-
* @param connection - Connection name
|
|
40
|
-
* @returns Driver instance
|
|
41
|
-
*/
|
|
42
|
-
getDriver(connection: string): QueueDriver;
|
|
43
|
-
/**
|
|
44
|
-
* Get a serializer.
|
|
45
|
-
* @param type - Serializer type
|
|
46
|
-
* @returns Serializer instance
|
|
47
|
-
*/
|
|
48
|
-
getSerializer(type?: string): JobSerializer;
|
|
49
|
-
/**
|
|
50
|
-
* Register Job classes (used by ClassNameSerializer).
|
|
51
|
-
* @param jobClasses - Job class array
|
|
52
|
-
*/
|
|
53
|
-
registerJobClasses(jobClasses: Array<new (...args: unknown[]) => Job>): void;
|
|
54
|
-
/**
|
|
55
|
-
* Push a Job to the queue.
|
|
56
|
-
* @param job - Job instance
|
|
57
|
-
* @returns The same job instance (for fluent chaining)
|
|
58
|
-
*/
|
|
59
|
-
push<T extends Job & Queueable>(job: T): Promise<T>;
|
|
60
|
-
/**
|
|
61
|
-
* Push multiple jobs.
|
|
62
|
-
* @param jobs - Job array
|
|
63
|
-
*/
|
|
64
|
-
pushMany<T extends Job & Queueable>(jobs: T[]): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Pop a job from the queue.
|
|
67
|
-
* @param queue - Queue name
|
|
68
|
-
* @param connection - Connection name
|
|
69
|
-
* @returns Job instance or null
|
|
70
|
-
*/
|
|
71
|
-
pop(queue?: string, connection?: string): Promise<Job | null>;
|
|
72
|
-
/**
|
|
73
|
-
* Get queue size.
|
|
74
|
-
* @param queue - Queue name
|
|
75
|
-
* @param connection - Connection name
|
|
76
|
-
* @returns Number of jobs in the queue
|
|
77
|
-
*/
|
|
78
|
-
size(queue?: string, connection?: string): Promise<number>;
|
|
79
|
-
/**
|
|
80
|
-
* Clear a queue.
|
|
81
|
-
* @param queue - Queue name
|
|
82
|
-
* @param connection - Connection name
|
|
83
|
-
*/
|
|
84
|
-
clear(queue?: string, connection?: string): Promise<void>;
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=QueueManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueueManager.d.ts","sourceRoot":"","sources":["../../../src/QueueManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACx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M,CAAC;IAK3F;;;;OAIG;IACG,KAAK,CAAC,KAAK,SAAY,EAAE,UAAU,GAAE,MAA+B,GAAG,OAAO,CAAC,IAAI,CAAC;CAI3F"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Queueable interface.
|
|
3
|
-
*
|
|
4
|
-
* Classes implementing this interface can be pushed to a queue for execution.
|
|
5
|
-
* Provides a fluent API for queue/connection/delay configuration.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* class MyJob implements Queueable {
|
|
10
|
-
* queueName?: string
|
|
11
|
-
* connectionName?: string
|
|
12
|
-
* delaySeconds?: number
|
|
13
|
-
*
|
|
14
|
-
* onQueue(queue: string): this {
|
|
15
|
-
* this.queueName = queue
|
|
16
|
-
* return this
|
|
17
|
-
* }
|
|
18
|
-
*
|
|
19
|
-
* onConnection(connection: string): this {
|
|
20
|
-
* this.connectionName = connection
|
|
21
|
-
* return this
|
|
22
|
-
* }
|
|
23
|
-
*
|
|
24
|
-
* delay(seconds: number): this {
|
|
25
|
-
* this.delaySeconds = seconds
|
|
26
|
-
* return this
|
|
27
|
-
* }
|
|
28
|
-
* }
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export interface Queueable {
|
|
32
|
-
/**
|
|
33
|
-
* Queue name where the job should be pushed.
|
|
34
|
-
*/
|
|
35
|
-
queueName?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Connection name the job should use.
|
|
38
|
-
*/
|
|
39
|
-
connectionName?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Delay before execution (seconds).
|
|
42
|
-
*/
|
|
43
|
-
delaySeconds?: number;
|
|
44
|
-
/**
|
|
45
|
-
* Set target queue.
|
|
46
|
-
* @param queue - Queue name
|
|
47
|
-
* @returns Self for fluent chaining
|
|
48
|
-
*/
|
|
49
|
-
onQueue(queue: string): this;
|
|
50
|
-
/**
|
|
51
|
-
* Set target connection.
|
|
52
|
-
* @param connection - Connection name
|
|
53
|
-
* @returns Self for fluent chaining
|
|
54
|
-
*/
|
|
55
|
-
onConnection(connection: string): this;
|
|
56
|
-
/**
|
|
57
|
-
* Set delay (seconds).
|
|
58
|
-
* @param delay - Delay seconds
|
|
59
|
-
* @returns Self for fluent chaining
|
|
60
|
-
*/
|
|
61
|
-
delay(delay: number): this;
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=Queueable.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Queueable.d.ts","sourceRoot":"","sources":["../../../src/Queueable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAE5B;;;;OAIG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAEtC;;;;OAIG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { Job } from './Job';
|
|
2
|
-
/**
|
|
3
|
-
* Worker options.
|
|
4
|
-
*/
|
|
5
|
-
export interface WorkerOptions {
|
|
6
|
-
/**
|
|
7
|
-
* Maximum retry attempts.
|
|
8
|
-
*/
|
|
9
|
-
maxAttempts?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Job timeout (seconds).
|
|
12
|
-
*/
|
|
13
|
-
timeout?: number;
|
|
14
|
-
/**
|
|
15
|
-
* Failure callback.
|
|
16
|
-
*/
|
|
17
|
-
onFailed?: (job: Job, error: Error) => Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Base Worker.
|
|
21
|
-
*
|
|
22
|
-
* Responsible for executing `Job` instances.
|
|
23
|
-
* Provides error handling, retry logic, and timeout support.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* const worker = new Worker({
|
|
28
|
-
* maxAttempts: 3,
|
|
29
|
-
* timeout: 60
|
|
30
|
-
* })
|
|
31
|
-
*
|
|
32
|
-
* await worker.process(job)
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare class Worker {
|
|
36
|
-
private options;
|
|
37
|
-
constructor(options?: WorkerOptions);
|
|
38
|
-
/**
|
|
39
|
-
* Process a Job.
|
|
40
|
-
* @param job - Job instance
|
|
41
|
-
*/
|
|
42
|
-
process(job: Job): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Handle failure.
|
|
45
|
-
*/
|
|
46
|
-
private handleFailure;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=Worker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../../../src/Worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACrD;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,MAAM;IACL,OAAO,CAAC,OAAO;gBAAP,OAAO,GAAE,aAAkB;IAE/C;;;OAGG;IACG,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IA4CtC;;OAEG;YACW,aAAa;CAiB5B"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { DBService } from '@gravito/orbit-db';
|
|
2
|
-
import type { SerializedJob } from '../types';
|
|
3
|
-
import type { QueueDriver } from './QueueDriver';
|
|
4
|
-
/**
|
|
5
|
-
* Database driver configuration.
|
|
6
|
-
*/
|
|
7
|
-
export interface DatabaseDriverConfig {
|
|
8
|
-
/**
|
|
9
|
-
* Table name (default: `jobs`).
|
|
10
|
-
*/
|
|
11
|
-
table?: string;
|
|
12
|
-
/**
|
|
13
|
-
* DBService instance (from `orbit-db`).
|
|
14
|
-
* If not provided, it can be resolved from Context in OrbitQueue.
|
|
15
|
-
*/
|
|
16
|
-
dbService?: DBService;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Database Driver
|
|
20
|
-
*
|
|
21
|
-
* Uses a database as the queue backend.
|
|
22
|
-
* Reuses the `orbit-db` connection instead of creating a new connection.
|
|
23
|
-
*
|
|
24
|
-
* Requires `@gravito/orbit-db` to be installed and configured.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* // Get DBService from Context
|
|
29
|
-
* const dbService = c.get('db')
|
|
30
|
-
* const driver = new DatabaseDriver({ dbService, table: 'jobs' })
|
|
31
|
-
*
|
|
32
|
-
* await driver.push('default', serializedJob)
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare class DatabaseDriver implements QueueDriver {
|
|
36
|
-
private tableName;
|
|
37
|
-
private dbService;
|
|
38
|
-
constructor(config: DatabaseDriverConfig);
|
|
39
|
-
/**
|
|
40
|
-
* Push a job to a queue.
|
|
41
|
-
*/
|
|
42
|
-
push(queue: string, job: SerializedJob): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Pop a job from the queue (FIFO, with delay support).
|
|
45
|
-
*/
|
|
46
|
-
pop(queue: string): Promise<SerializedJob | null>;
|
|
47
|
-
/**
|
|
48
|
-
* Get queue size.
|
|
49
|
-
*/
|
|
50
|
-
size(queue: string): Promise<number>;
|
|
51
|
-
/**
|
|
52
|
-
* Clear a queue.
|
|
53
|
-
*/
|
|
54
|
-
clear(queue: string): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Push multiple jobs.
|
|
57
|
-
*/
|
|
58
|
-
pushMany(queue: string, jobs: SerializedJob[]): Promise<void>;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=DatabaseDriver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseDriver.d.ts","sourceRoot":"","sources":["../../../../src/drivers/DatabaseDriver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAe,YAAW,WAAW;IAChD,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,SAAS,CAAW;gBAEhB,MAAM,EAAE,oBAAoB;IAWxC;;OAEG;IACG,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAa5D;;OAEG;IACG,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAyEvD;;OAEG;IACG,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAa1C;;OAEG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC;;OAEG;IACG,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAoBpE"}
|