@forklaunch/implementation-worker-database 0.5.0 → 0.5.1
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/lib/consumers/index.js
CHANGED
|
@@ -26,6 +26,11 @@ module.exports = __toCommonJS(consumers_exports);
|
|
|
26
26
|
|
|
27
27
|
// consumers/databaseWorker.consumer.ts
|
|
28
28
|
var DatabaseWorkerConsumer = class {
|
|
29
|
+
entityName;
|
|
30
|
+
em;
|
|
31
|
+
options;
|
|
32
|
+
processEvents;
|
|
33
|
+
failureHandler;
|
|
29
34
|
constructor(entityName, em, options, processEvents, failureHandler) {
|
|
30
35
|
this.entityName = entityName;
|
|
31
36
|
this.em = em;
|
package/lib/consumers/index.mjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
// consumers/databaseWorker.consumer.ts
|
|
2
2
|
var DatabaseWorkerConsumer = class {
|
|
3
|
+
entityName;
|
|
4
|
+
em;
|
|
5
|
+
options;
|
|
6
|
+
processEvents;
|
|
7
|
+
failureHandler;
|
|
3
8
|
constructor(entityName, em, options, processEvents, failureHandler) {
|
|
4
9
|
this.entityName = entityName;
|
|
5
10
|
this.em = em;
|
|
@@ -12,13 +12,25 @@ export class DatabaseWorkerConsumer<
|
|
|
12
12
|
Options extends DatabaseWorkerOptions
|
|
13
13
|
> implements WorkerConsumer<EventEntity>
|
|
14
14
|
{
|
|
15
|
+
protected readonly entityName: EntityName<EventEntity>;
|
|
16
|
+
protected readonly em: EntityManager;
|
|
17
|
+
protected readonly options: Options;
|
|
18
|
+
protected readonly processEvents: WorkerProcessFunction<EventEntity>;
|
|
19
|
+
protected readonly failureHandler: WorkerFailureHandler<EventEntity>;
|
|
20
|
+
|
|
15
21
|
constructor(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
) {
|
|
22
|
+
entityName: EntityName<EventEntity>,
|
|
23
|
+
em: EntityManager,
|
|
24
|
+
options: Options,
|
|
25
|
+
processEvents: WorkerProcessFunction<EventEntity>,
|
|
26
|
+
failureHandler: WorkerFailureHandler<EventEntity>
|
|
27
|
+
) {
|
|
28
|
+
this.entityName = entityName;
|
|
29
|
+
this.em = em;
|
|
30
|
+
this.options = options;
|
|
31
|
+
this.processEvents = processEvents;
|
|
32
|
+
this.failureHandler = failureHandler;
|
|
33
|
+
}
|
|
22
34
|
|
|
23
35
|
private async retrieveEvents(): Promise<EventEntity[]> {
|
|
24
36
|
return this.em.getRepository(this.entityName).find(
|
|
@@ -6,10 +6,13 @@ export class DatabaseWorkerProducer<
|
|
|
6
6
|
EventEntity extends WorkerEventEntity & BaseEntity,
|
|
7
7
|
Options extends DatabaseWorkerOptions
|
|
8
8
|
> {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
) {
|
|
9
|
+
private readonly em: EntityManager;
|
|
10
|
+
private readonly options: Options;
|
|
11
|
+
|
|
12
|
+
constructor(em: EntityManager, options: Options) {
|
|
13
|
+
this.em = em;
|
|
14
|
+
this.options = options;
|
|
15
|
+
}
|
|
13
16
|
|
|
14
17
|
async enqueueJob(event: EventEntity): Promise<void> {
|
|
15
18
|
await this.em.persistAndFlush(event);
|
package/lib/producers/index.js
CHANGED
package/lib/producers/index.mjs
CHANGED
package/package.json
CHANGED