ravenflow 0.4.0 → 0.4.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/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
- import { Job, ConnectionOptions, Queue } from 'bullmq';
1
+ import { Job, ConnectionOptions } from 'bullmq';
2
2
  import pino from 'pino';
3
- import { Db } from 'mongodb';
4
3
 
5
4
  declare const CONTINUATION: unique symbol;
6
5
  interface Continuation<TPayload> {
@@ -133,125 +132,6 @@ interface QueuesRetentionConfig {
133
132
  }
134
133
  declare function defineConfig<const T extends RavenflowConfig>(config: T): T;
135
134
 
136
- declare class MongoConnection {
137
- private readonly uri;
138
- private client;
139
- private database;
140
- private connecting;
141
- constructor(uri: string);
142
- connect(): Promise<Db>;
143
- close(): Promise<void>;
144
- private openTheDatabase;
145
- private forgetTheAttempt;
146
- }
147
-
148
- type ControlKey = `job:${string}`;
149
-
150
- interface ControlPublisher {
151
- publish(key: ControlKey): Promise<void>;
152
- }
153
- declare class ControlChannel implements ControlPublisher {
154
- private readonly connection;
155
- private readonly logger;
156
- private publisher;
157
- private subscriber;
158
- constructor(connection: ConnectionOptions, logger: Logger);
159
- publish(key: ControlKey): Promise<void>;
160
- subscribe(onInvalidate: (key: ControlKey) => void): Promise<void>;
161
- close(): Promise<void>;
162
- private deliver;
163
- private listenOn;
164
- private open;
165
- }
166
-
167
- declare const LEVERS: readonly ["executionPaused", "triggerPaused", "ingestPaused"];
168
- type Lever = (typeof LEVERS)[number];
169
- type JobControls = Record<Lever, boolean>;
170
-
171
- interface ControlReads {
172
- read(jobName: string): Promise<JobControls>;
173
- }
174
- interface JobControlPlane extends ControlReads {
175
- write(jobName: string, patch: Partial<JobControls>): Promise<void>;
176
- }
177
-
178
- interface LeverEntry {
179
- key: ControlKey;
180
- lever: Lever;
181
- value: string;
182
- }
183
- interface StoredLever {
184
- jobName: string;
185
- lever: Lever;
186
- value: string;
187
- }
188
- declare class ControlHash {
189
- private readonly options;
190
- private readonly logger;
191
- private connection;
192
- constructor(options: ConnectionOptions, logger: Logger);
193
- readLevers(key: ControlKey): Promise<Map<Lever, string>>;
194
- readEveryLever(): Promise<StoredLever[]>;
195
- write(entry: LeverEntry): Promise<void>;
196
- writeIfAbsent(entry: LeverEntry): Promise<boolean>;
197
- close(): Promise<void>;
198
- private get redis();
199
- }
200
-
201
- interface MirroredControls extends Partial<JobControls> {
202
- _id: string;
203
- updatedAt: Date;
204
- }
205
- interface ControlMirror {
206
- mirrorJobControls(jobName: string, patch: Partial<JobControls>): Promise<void>;
207
- listAll(): Promise<MirroredControls[]>;
208
- }
209
-
210
- type LiveControls = Map<string, JobControls>;
211
-
212
- interface RehydrationReport {
213
- restored: number;
214
- alreadyLive: number;
215
- truncated: boolean;
216
- }
217
-
218
- interface ControlStoreParts {
219
- hash: ControlHash;
220
- publisher: ControlPublisher;
221
- mirror: ControlMirror;
222
- logger: Logger;
223
- }
224
- declare class ControlStore implements JobControlPlane {
225
- private readonly parts;
226
- constructor(parts: ControlStoreParts);
227
- read(jobName: string): Promise<JobControls>;
228
- write(jobName: string, patch: Partial<JobControls>): Promise<void>;
229
- readAll(): Promise<LiveControls>;
230
- rehydrate(): Promise<RehydrationReport>;
231
- close(): Promise<void>;
232
- private isPulled;
233
- private writeLevers;
234
- private announce;
235
- private writeMirror;
236
- }
237
-
238
- declare class ControlPlane implements JobControlPlane {
239
- private readonly parts;
240
- private readonly cache;
241
- constructor(parts: {
242
- store: ControlStore;
243
- channel: ControlChannel;
244
- logger: Logger;
245
- });
246
- read(jobName: string): Promise<JobControls>;
247
- write(jobName: string, patch: Partial<JobControls>): Promise<void>;
248
- rehydrate(): Promise<void>;
249
- close(): Promise<void>;
250
- private closeQuietly;
251
- }
252
-
253
- type QueuesByName = Record<string, Queue>;
254
-
255
135
  interface SpoolPurgeReport {
256
136
  dropped: number;
257
137
  inFlight: number;
@@ -301,23 +181,21 @@ interface SpoolFedControls extends ExecutionControls, TriggerControls, IngestCon
301
181
  purgeBacklog(): Promise<SpoolPurgeReport>;
302
182
  }
303
183
 
304
- declare class RavenflowClient<TConfig extends RavenflowConfig = RavenflowConfig> {
184
+ interface RavenflowClient<TConfig extends RavenflowConfig = RavenflowConfig> {
305
185
  readonly jobs: JobsProxy<TConfig["jobs"]>;
306
- protected readonly redisConnectionOptions: ConnectionOptions;
307
- protected readonly mongoUri: string;
308
- protected readonly mongo: MongoConnection;
309
- protected readonly config: TConfig;
310
- protected readonly controlPlane: ControlPlane;
311
- protected readonly queues: QueuesByName;
312
- protected readonly logger: Logger;
313
- constructor(config: TConfig, options: {
314
- redis: ConnectionOptions;
315
- mongo: string;
316
- });
317
186
  close(): Promise<void>;
318
187
  }
188
+ interface RavenflowClientOptions {
189
+ redis: ConnectionOptions;
190
+ mongo: string;
191
+ }
192
+
193
+ declare function createRavenflowClient<TConfig extends RavenflowConfig>(config: TConfig, options: RavenflowClientOptions): RavenflowClient<TConfig>;
319
194
 
320
- declare function createRavenflowClient<TConfig extends RavenflowConfig>(config: TConfig, options: ConstructorParameters<typeof RavenflowClient>[1]): RavenflowClient<TConfig>;
195
+ interface RavenflowWorker {
196
+ start(): Promise<void>;
197
+ close(): Promise<void>;
198
+ }
321
199
 
322
200
  interface RavenflowWorkerOptions {
323
201
  redis: ConnectionOptions;
@@ -331,33 +209,6 @@ interface WithdrawalOptions {
331
209
  onWithdraw?: (reason: string) => void | Promise<void>;
332
210
  }
333
211
 
334
- declare class RavenflowWorker {
335
- private readonly config;
336
- private readonly options;
337
- private readonly jobs;
338
- private readonly logger;
339
- private serving;
340
- private starting;
341
- private closing;
342
- constructor(config: RavenflowConfig, options: RavenflowWorkerOptions);
343
- start(): Promise<void>;
344
- close(): Promise<void>;
345
- private serveOrStop;
346
- private stopServing;
347
- private refuseASecondStart;
348
- private openServing;
349
- private buildControlPlaneReader;
350
- private buildJobResultsRecorder;
351
- private buildJobResultsAggregator;
352
- private buildSpoolFeeder;
353
- private buildMongoWatch;
354
- private beginAWithdrawal;
355
- private serve;
356
- private openRecorder;
357
- private sayJobResultsAreNotRecorded;
358
- private takeJobs;
359
- }
360
-
361
212
  declare function createRavenflowWorker(config: RavenflowConfig, options: RavenflowWorkerOptions): RavenflowWorker;
362
213
 
363
- export { type JobDefinition, RavenflowClient, type RavenflowConfig, RavenflowWorker, type RavenflowWorkerOptions, createRavenflowClient, createRavenflowWorker, defineConfig, defineJob };
214
+ export { type ClockFedJob, type JobDefinition, type RavenflowClient, type RavenflowConfig, type RavenflowWorker, type RavenflowWorkerOptions, type SpoolFedJob, createRavenflowClient, createRavenflowWorker, defineConfig, defineJob };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { Job, ConnectionOptions, Queue } from 'bullmq';
1
+ import { Job, ConnectionOptions } from 'bullmq';
2
2
  import pino from 'pino';
3
- import { Db } from 'mongodb';
4
3
 
5
4
  declare const CONTINUATION: unique symbol;
6
5
  interface Continuation<TPayload> {
@@ -133,125 +132,6 @@ interface QueuesRetentionConfig {
133
132
  }
134
133
  declare function defineConfig<const T extends RavenflowConfig>(config: T): T;
135
134
 
136
- declare class MongoConnection {
137
- private readonly uri;
138
- private client;
139
- private database;
140
- private connecting;
141
- constructor(uri: string);
142
- connect(): Promise<Db>;
143
- close(): Promise<void>;
144
- private openTheDatabase;
145
- private forgetTheAttempt;
146
- }
147
-
148
- type ControlKey = `job:${string}`;
149
-
150
- interface ControlPublisher {
151
- publish(key: ControlKey): Promise<void>;
152
- }
153
- declare class ControlChannel implements ControlPublisher {
154
- private readonly connection;
155
- private readonly logger;
156
- private publisher;
157
- private subscriber;
158
- constructor(connection: ConnectionOptions, logger: Logger);
159
- publish(key: ControlKey): Promise<void>;
160
- subscribe(onInvalidate: (key: ControlKey) => void): Promise<void>;
161
- close(): Promise<void>;
162
- private deliver;
163
- private listenOn;
164
- private open;
165
- }
166
-
167
- declare const LEVERS: readonly ["executionPaused", "triggerPaused", "ingestPaused"];
168
- type Lever = (typeof LEVERS)[number];
169
- type JobControls = Record<Lever, boolean>;
170
-
171
- interface ControlReads {
172
- read(jobName: string): Promise<JobControls>;
173
- }
174
- interface JobControlPlane extends ControlReads {
175
- write(jobName: string, patch: Partial<JobControls>): Promise<void>;
176
- }
177
-
178
- interface LeverEntry {
179
- key: ControlKey;
180
- lever: Lever;
181
- value: string;
182
- }
183
- interface StoredLever {
184
- jobName: string;
185
- lever: Lever;
186
- value: string;
187
- }
188
- declare class ControlHash {
189
- private readonly options;
190
- private readonly logger;
191
- private connection;
192
- constructor(options: ConnectionOptions, logger: Logger);
193
- readLevers(key: ControlKey): Promise<Map<Lever, string>>;
194
- readEveryLever(): Promise<StoredLever[]>;
195
- write(entry: LeverEntry): Promise<void>;
196
- writeIfAbsent(entry: LeverEntry): Promise<boolean>;
197
- close(): Promise<void>;
198
- private get redis();
199
- }
200
-
201
- interface MirroredControls extends Partial<JobControls> {
202
- _id: string;
203
- updatedAt: Date;
204
- }
205
- interface ControlMirror {
206
- mirrorJobControls(jobName: string, patch: Partial<JobControls>): Promise<void>;
207
- listAll(): Promise<MirroredControls[]>;
208
- }
209
-
210
- type LiveControls = Map<string, JobControls>;
211
-
212
- interface RehydrationReport {
213
- restored: number;
214
- alreadyLive: number;
215
- truncated: boolean;
216
- }
217
-
218
- interface ControlStoreParts {
219
- hash: ControlHash;
220
- publisher: ControlPublisher;
221
- mirror: ControlMirror;
222
- logger: Logger;
223
- }
224
- declare class ControlStore implements JobControlPlane {
225
- private readonly parts;
226
- constructor(parts: ControlStoreParts);
227
- read(jobName: string): Promise<JobControls>;
228
- write(jobName: string, patch: Partial<JobControls>): Promise<void>;
229
- readAll(): Promise<LiveControls>;
230
- rehydrate(): Promise<RehydrationReport>;
231
- close(): Promise<void>;
232
- private isPulled;
233
- private writeLevers;
234
- private announce;
235
- private writeMirror;
236
- }
237
-
238
- declare class ControlPlane implements JobControlPlane {
239
- private readonly parts;
240
- private readonly cache;
241
- constructor(parts: {
242
- store: ControlStore;
243
- channel: ControlChannel;
244
- logger: Logger;
245
- });
246
- read(jobName: string): Promise<JobControls>;
247
- write(jobName: string, patch: Partial<JobControls>): Promise<void>;
248
- rehydrate(): Promise<void>;
249
- close(): Promise<void>;
250
- private closeQuietly;
251
- }
252
-
253
- type QueuesByName = Record<string, Queue>;
254
-
255
135
  interface SpoolPurgeReport {
256
136
  dropped: number;
257
137
  inFlight: number;
@@ -301,23 +181,21 @@ interface SpoolFedControls extends ExecutionControls, TriggerControls, IngestCon
301
181
  purgeBacklog(): Promise<SpoolPurgeReport>;
302
182
  }
303
183
 
304
- declare class RavenflowClient<TConfig extends RavenflowConfig = RavenflowConfig> {
184
+ interface RavenflowClient<TConfig extends RavenflowConfig = RavenflowConfig> {
305
185
  readonly jobs: JobsProxy<TConfig["jobs"]>;
306
- protected readonly redisConnectionOptions: ConnectionOptions;
307
- protected readonly mongoUri: string;
308
- protected readonly mongo: MongoConnection;
309
- protected readonly config: TConfig;
310
- protected readonly controlPlane: ControlPlane;
311
- protected readonly queues: QueuesByName;
312
- protected readonly logger: Logger;
313
- constructor(config: TConfig, options: {
314
- redis: ConnectionOptions;
315
- mongo: string;
316
- });
317
186
  close(): Promise<void>;
318
187
  }
188
+ interface RavenflowClientOptions {
189
+ redis: ConnectionOptions;
190
+ mongo: string;
191
+ }
192
+
193
+ declare function createRavenflowClient<TConfig extends RavenflowConfig>(config: TConfig, options: RavenflowClientOptions): RavenflowClient<TConfig>;
319
194
 
320
- declare function createRavenflowClient<TConfig extends RavenflowConfig>(config: TConfig, options: ConstructorParameters<typeof RavenflowClient>[1]): RavenflowClient<TConfig>;
195
+ interface RavenflowWorker {
196
+ start(): Promise<void>;
197
+ close(): Promise<void>;
198
+ }
321
199
 
322
200
  interface RavenflowWorkerOptions {
323
201
  redis: ConnectionOptions;
@@ -331,33 +209,6 @@ interface WithdrawalOptions {
331
209
  onWithdraw?: (reason: string) => void | Promise<void>;
332
210
  }
333
211
 
334
- declare class RavenflowWorker {
335
- private readonly config;
336
- private readonly options;
337
- private readonly jobs;
338
- private readonly logger;
339
- private serving;
340
- private starting;
341
- private closing;
342
- constructor(config: RavenflowConfig, options: RavenflowWorkerOptions);
343
- start(): Promise<void>;
344
- close(): Promise<void>;
345
- private serveOrStop;
346
- private stopServing;
347
- private refuseASecondStart;
348
- private openServing;
349
- private buildControlPlaneReader;
350
- private buildJobResultsRecorder;
351
- private buildJobResultsAggregator;
352
- private buildSpoolFeeder;
353
- private buildMongoWatch;
354
- private beginAWithdrawal;
355
- private serve;
356
- private openRecorder;
357
- private sayJobResultsAreNotRecorded;
358
- private takeJobs;
359
- }
360
-
361
212
  declare function createRavenflowWorker(config: RavenflowConfig, options: RavenflowWorkerOptions): RavenflowWorker;
362
213
 
363
- export { type JobDefinition, RavenflowClient, type RavenflowConfig, RavenflowWorker, type RavenflowWorkerOptions, createRavenflowClient, createRavenflowWorker, defineConfig, defineJob };
214
+ export { type ClockFedJob, type JobDefinition, type RavenflowClient, type RavenflowConfig, type RavenflowWorker, type RavenflowWorkerOptions, type SpoolFedJob, createRavenflowClient, createRavenflowWorker, defineConfig, defineJob };