@remit/account-worker 0.0.13 → 0.0.15
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/package.json
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { SendMessageCommand, type SQSClient } from "@aws-sdk/client-sqs";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createLogger,
|
|
4
|
+
type Logger,
|
|
5
|
+
queueNameFromEventSource,
|
|
6
|
+
recordQueueEvent,
|
|
7
|
+
withTelemetry,
|
|
8
|
+
} from "@remit/logger-lambda";
|
|
3
9
|
import type { SQSBatchResponse, SQSEvent, SQSHandler } from "aws-lambda";
|
|
4
10
|
import type { CascadeServices } from "../cascade.js";
|
|
5
11
|
import { enumerateCascadeEntities } from "../cascade.js";
|
|
@@ -157,6 +163,7 @@ export const handler: SQSHandler = withTelemetry(
|
|
|
157
163
|
"Processing account fanout event",
|
|
158
164
|
);
|
|
159
165
|
|
|
166
|
+
const start = Date.now();
|
|
160
167
|
const failed = await processAccountFanout(fanoutEvent, log)
|
|
161
168
|
.then(() => false)
|
|
162
169
|
.catch((error) => {
|
|
@@ -167,6 +174,13 @@ export const handler: SQSHandler = withTelemetry(
|
|
|
167
174
|
return true;
|
|
168
175
|
});
|
|
169
176
|
|
|
177
|
+
recordQueueEvent({
|
|
178
|
+
queue: queueNameFromEventSource(record.eventSourceARN),
|
|
179
|
+
eventType: fanoutEvent.type,
|
|
180
|
+
outcome: failed ? "failure" : "success",
|
|
181
|
+
durationMs: Date.now() - start,
|
|
182
|
+
});
|
|
183
|
+
|
|
170
184
|
if (failed) {
|
|
171
185
|
batchItemFailures.push({ itemIdentifier: record.messageId });
|
|
172
186
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { inspect } from "node:util";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createLogger,
|
|
4
|
+
type Logger,
|
|
5
|
+
queueNameFromEventSource,
|
|
6
|
+
recordQueueEvent,
|
|
7
|
+
withTelemetry,
|
|
8
|
+
} from "@remit/logger-lambda";
|
|
3
9
|
import type { SQSEvent, SQSHandler } from "aws-lambda";
|
|
4
10
|
import {
|
|
5
11
|
type CascadeEntity,
|
|
@@ -285,6 +291,7 @@ export const handler: SQSHandler = withTelemetry(async (event: SQSEvent) => {
|
|
|
285
291
|
"Processing account finalize event",
|
|
286
292
|
);
|
|
287
293
|
|
|
294
|
+
const start = Date.now();
|
|
288
295
|
const work =
|
|
289
296
|
finalizeEvent.type === "FinalizeAccountDataPurge"
|
|
290
297
|
? processAccountDataPurgeFinalize(finalizeEvent, log)
|
|
@@ -300,6 +307,13 @@ export const handler: SQSHandler = withTelemetry(async (event: SQSEvent) => {
|
|
|
300
307
|
return true;
|
|
301
308
|
});
|
|
302
309
|
|
|
310
|
+
recordQueueEvent({
|
|
311
|
+
queue: queueNameFromEventSource(record.eventSourceARN),
|
|
312
|
+
eventType: finalizeEvent.type,
|
|
313
|
+
outcome: failed ? "failure" : "success",
|
|
314
|
+
durationMs: Date.now() - start,
|
|
315
|
+
});
|
|
316
|
+
|
|
303
317
|
if (failed) {
|
|
304
318
|
batchItemFailures.push({ itemIdentifier: record.messageId });
|
|
305
319
|
}
|
|
@@ -39,14 +39,19 @@ export const processOrganizeJob = async (
|
|
|
39
39
|
|
|
40
40
|
try {
|
|
41
41
|
const predicate = predicateFromJob(job);
|
|
42
|
+
const matchDeps = buildOrganizeMatchDeps(client);
|
|
42
43
|
const { messageIds, semanticUnavailable } = await matchOrganize(
|
|
43
|
-
|
|
44
|
+
matchDeps,
|
|
44
45
|
accountConfigId,
|
|
45
46
|
predicate,
|
|
46
47
|
ORGANIZE_MATCH_LIMIT,
|
|
47
48
|
);
|
|
48
49
|
const { applied, failed } = await applyOrganize(
|
|
49
|
-
{
|
|
50
|
+
{
|
|
51
|
+
client,
|
|
52
|
+
moveService: buildOrganizeMoveService(client),
|
|
53
|
+
match: matchDeps,
|
|
54
|
+
},
|
|
50
55
|
accountConfigId,
|
|
51
56
|
messageIds,
|
|
52
57
|
predicate,
|
package/src/poller.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createLogger } from "@remit/logger-lambda";
|
|
1
|
+
import { createLogger, startMetricsServer } from "@remit/logger-lambda";
|
|
2
2
|
import { runQueuePoller } from "@remit/sqs-client/poller";
|
|
3
3
|
import { env } from "expect-env";
|
|
4
4
|
import { fanoutHandler, finalizeHandler } from "./index.js";
|
|
@@ -20,6 +20,11 @@ import { fanoutHandler, finalizeHandler } from "./index.js";
|
|
|
20
20
|
*/
|
|
21
21
|
const log = createLogger();
|
|
22
22
|
|
|
23
|
+
// /metrics and nothing else, on the compose network (standalone-observability
|
|
24
|
+
// D2). No health route on it: worker liveness is a heartbeat file, which keeps
|
|
25
|
+
// answering when this server does not.
|
|
26
|
+
startMetricsServer();
|
|
27
|
+
|
|
23
28
|
await runQueuePoller({
|
|
24
29
|
log,
|
|
25
30
|
targets: [
|