@gaonjs/async 0.2.1 → 0.2.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/listeners.js +4 -1
- package/dist/worker.js +4 -1
- package/package.json +2 -2
package/dist/listeners.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// 이벤트는 알림성이라 잡보다 단순하게 다룬다: 성공→ack, 실패→백오프 후
|
|
8
8
|
// 재전달(nak), max_deliver 소진→폐기(term, 로깅). 잡 같은 DLQ 는 두지 않되
|
|
9
9
|
// 재시도는 준다.
|
|
10
|
+
import { runWithLogContext } from '@gaonjs/core';
|
|
10
11
|
import { jetstreamManager } from '@nats-io/jetstream';
|
|
11
12
|
import { EVENTS_STREAM, eventSubject, listenerConsumerName, toNanos, ensureEventsStream, } from './streams.js';
|
|
12
13
|
import { decodePayloadBytes } from './codec.js';
|
|
@@ -39,7 +40,9 @@ export async function runListeners(opts) {
|
|
|
39
40
|
const attempt = m.info.deliveryCount;
|
|
40
41
|
try {
|
|
41
42
|
const payload = decodePayloadBytes(m.data);
|
|
42
|
-
|
|
43
|
+
// 리스너 실행을 로그 컨텍스트로 감싼다(§7) — 이벤트명·리스너 id·attempt 가
|
|
44
|
+
// 리스너 본문의 모든 log.* 에 자동 전파된다.
|
|
45
|
+
await runWithLogContext({ event: listener.eventName, listener: listener.id, attempt }, () => listener.handler(payload));
|
|
43
46
|
m.ack();
|
|
44
47
|
emit({ kind: 'handled', listener: listener.id, event: listener.eventName });
|
|
45
48
|
}
|
package/dist/worker.js
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
//
|
|
16
16
|
// Graceful drain(§7 line 885): 종료 시그널 → 신규 pull 중단 → 진행 잡 완료
|
|
17
17
|
// 대기(timeout) → 종료. 미완료 잡은 ack 타임아웃으로 스트림에 남는다.
|
|
18
|
+
import { runWithLogContext } from '@gaonjs/core';
|
|
18
19
|
import { jetstreamManager } from '@nats-io/jetstream';
|
|
19
20
|
import { JOBS_STREAM, DLQ_SUBJECT, jobConsumerName, jobSubject, toNanos, ensureJobsStream, ensureDlqStream, } from './streams.js';
|
|
20
21
|
import { encodePayloadBytes, decodePayloadBytes } from './codec.js';
|
|
@@ -81,7 +82,9 @@ export async function runWorker(opts) {
|
|
|
81
82
|
}, Math.max(1000, Math.floor(ackWaitMs / 2)));
|
|
82
83
|
try {
|
|
83
84
|
const run = def.handler;
|
|
84
|
-
|
|
85
|
+
// 잡 실행을 로그 컨텍스트로 감싼다(§7) — 잡 본문의 모든 log.* 에 잡
|
|
86
|
+
// 이름·상관 ID·attempt 가 자동으로 붙어 HTTP 요청과 같은 추적성을 준다.
|
|
87
|
+
await runWithLogContext({ requestId: msg.id, jobName: msg.name, attempt }, () => run(...msg.args));
|
|
85
88
|
clearInterval(heartbeat);
|
|
86
89
|
m.ack();
|
|
87
90
|
emit({ kind: 'succeeded', job: msg.name, id: msg.id });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaonjs/async",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Gaon NATS 통합: 잡·이벤트·스케줄러·채널(ws)·허브(프레즌스) (구현 예정)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@nats-io/jetstream": "^3.1.0",
|
|
29
29
|
"@nats-io/kv": "^3.1.0",
|
|
30
30
|
"kysely": "^0.29.4",
|
|
31
|
-
"@gaonjs/core": "0.1.
|
|
31
|
+
"@gaonjs/core": "0.1.4"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "node ../../node_modules/typescript/bin/tsc -p tsconfig.json"
|