@epztickets/common 1.23.1 → 1.25.0
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.
|
@@ -31,7 +31,6 @@ class JetStreamListener {
|
|
|
31
31
|
opts.ackExplicit();
|
|
32
32
|
opts.deliverAll();
|
|
33
33
|
opts.maxDeliver(5);
|
|
34
|
-
opts.maxDeliver(5);
|
|
35
34
|
opts.filterSubject(this.subject);
|
|
36
35
|
opts.deliverTo(`${this.queueGroup}.${this.durableName}`);
|
|
37
36
|
const sub = yield this.js.subscribe(this.subject, opts);
|
|
@@ -42,20 +42,52 @@ function ensureStreams(jsm) {
|
|
|
42
42
|
retention: nats_1.RetentionPolicy.Limits, // FAN-OUT
|
|
43
43
|
storage: nats_1.StorageType.File,
|
|
44
44
|
discard: nats_1.DiscardPolicy.Old,
|
|
45
|
-
max_age: 7 * 24 * 60 * 60 *
|
|
45
|
+
max_age: 7 * 24 * 60 * 60 * 1000000000,
|
|
46
46
|
});
|
|
47
47
|
console.log("Created stream:", subjects_1.Streams.Events);
|
|
48
48
|
}
|
|
49
49
|
/* ---------------- JOBS STREAM ---------------- */
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
if (!has(subjects_1.Streams.Jobs)) {
|
|
51
|
+
yield jsm.streams.add({
|
|
52
|
+
name: subjects_1.Streams.Jobs,
|
|
53
|
+
subjects: ["jobs.>"],
|
|
54
|
+
retention: nats_1.RetentionPolicy.Workqueue, // EXACTLY-ONCE
|
|
55
|
+
storage: nats_1.StorageType.File,
|
|
56
|
+
discard: nats_1.DiscardPolicy.Old,
|
|
57
|
+
});
|
|
58
|
+
console.log("Created stream:", subjects_1.Streams.Jobs);
|
|
59
|
+
}
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
+
// import {
|
|
63
|
+
// JetStreamManager,
|
|
64
|
+
// RetentionPolicy,
|
|
65
|
+
// StorageType,
|
|
66
|
+
// DiscardPolicy,
|
|
67
|
+
// } from "nats";
|
|
68
|
+
// import { Streams } from "../events/subjects";
|
|
69
|
+
// export async function ensureStreams(jsm: JetStreamManager) {
|
|
70
|
+
// const streams = await jsm.streams.list().next();
|
|
71
|
+
// const hasEvents = streams.some(s => s.config.name === Streams.Events);
|
|
72
|
+
// // 1️⃣ Stream already exists → validate config
|
|
73
|
+
// if (hasEvents) {
|
|
74
|
+
// const info = await jsm.streams.info(Streams.Events);
|
|
75
|
+
// if (info.config.retention !== RetentionPolicy.Limits) {
|
|
76
|
+
// throw new Error(
|
|
77
|
+
// `EVENTS stream has invalid retention: ${info.config.retention}`
|
|
78
|
+
// );
|
|
79
|
+
// }
|
|
80
|
+
// console.log("✅ EVENTS stream already exists with correct retention");
|
|
81
|
+
// return;
|
|
82
|
+
// }
|
|
83
|
+
// // 2️⃣ Stream does not exist → create it
|
|
84
|
+
// await jsm.streams.add({
|
|
85
|
+
// name: Streams.Events,
|
|
86
|
+
// subjects: ["events.>"],
|
|
87
|
+
// retention: RetentionPolicy.Limits, // FAN-OUT
|
|
88
|
+
// storage: StorageType.File,
|
|
89
|
+
// discard: DiscardPolicy.Old,
|
|
90
|
+
// max_age: 7 * 24 * 60 * 60 * 1_000_000_000 // ✅ nanoseconds
|
|
91
|
+
// });
|
|
92
|
+
// console.log("✅ Created EVENTS stream");
|
|
93
|
+
// }
|