@514labs/moose-lib 0.6.449 → 0.6.450
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/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs.map +1 -1
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +23 -20
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +23 -20
- package/dist/moose-runner.mjs.map +1 -1
- package/package.json +1 -1
package/dist/moose-runner.js
CHANGED
|
@@ -3375,14 +3375,16 @@ var init_internal = __esm({
|
|
|
3375
3375
|
name: destinationName,
|
|
3376
3376
|
version: config.version,
|
|
3377
3377
|
metadata: config.metadata,
|
|
3378
|
-
sourceFile: config.sourceFile
|
|
3378
|
+
sourceFile: config.sourceFile,
|
|
3379
|
+
deadLetterQueue: config.deadLetterQueue?.name
|
|
3379
3380
|
});
|
|
3380
3381
|
});
|
|
3381
3382
|
});
|
|
3382
3383
|
stream._consumers.forEach((consumer) => {
|
|
3383
3384
|
consumers.push({
|
|
3384
3385
|
version: consumer.config.version,
|
|
3385
|
-
sourceFile: consumer.config.sourceFile
|
|
3386
|
+
sourceFile: consumer.config.sourceFile,
|
|
3387
|
+
deadLetterQueue: consumer.config.deadLetterQueue?.name
|
|
3386
3388
|
});
|
|
3387
3389
|
});
|
|
3388
3390
|
topics[stream.name] = {
|
|
@@ -4477,7 +4479,7 @@ var stopConsumer = async (logger2, consumer, sourceTopic) => {
|
|
|
4477
4479
|
}
|
|
4478
4480
|
}
|
|
4479
4481
|
};
|
|
4480
|
-
var handleMessage = async (logger2, streamingFunctionWithConfigList, message, producer, fieldMutations, logPayloads) => {
|
|
4482
|
+
var handleMessage = async (logger2, streamingFunctionWithConfigList, message, producer, fieldMutations, logPayloads, dlqTopicName) => {
|
|
4481
4483
|
if (message.value === void 0 || message.value === null) {
|
|
4482
4484
|
logger2.log(`Received message with no value, skipping...`);
|
|
4483
4485
|
return void 0;
|
|
@@ -4497,12 +4499,10 @@ var handleMessage = async (logger2, streamingFunctionWithConfigList, message, pr
|
|
|
4497
4499
|
try {
|
|
4498
4500
|
return await fn(parsedData);
|
|
4499
4501
|
} catch (e) {
|
|
4500
|
-
|
|
4501
|
-
if (deadLetterQueue) {
|
|
4502
|
+
if (dlqTopicName) {
|
|
4502
4503
|
const deadLetterRecord = {
|
|
4503
4504
|
originalRecord: {
|
|
4504
4505
|
...parsedData,
|
|
4505
|
-
// Include original Kafka message metadata
|
|
4506
4506
|
__sourcePartition: message.partition,
|
|
4507
4507
|
__sourceOffset: message.offset,
|
|
4508
4508
|
__sourceTimestamp: message.timestamp
|
|
@@ -4514,12 +4514,12 @@ var handleMessage = async (logger2, streamingFunctionWithConfigList, message, pr
|
|
|
4514
4514
|
};
|
|
4515
4515
|
cliLog({
|
|
4516
4516
|
action: "DeadLetter",
|
|
4517
|
-
message: `Sending message to DLQ ${
|
|
4517
|
+
message: `Sending message to DLQ ${dlqTopicName}: ${e instanceof Error ? e.message : String(e)}`,
|
|
4518
4518
|
message_type: "Error"
|
|
4519
4519
|
});
|
|
4520
4520
|
try {
|
|
4521
4521
|
await producer.send({
|
|
4522
|
-
topic:
|
|
4522
|
+
topic: dlqTopicName,
|
|
4523
4523
|
messages: [{ value: JSON.stringify(deadLetterRecord) }]
|
|
4524
4524
|
});
|
|
4525
4525
|
} catch (dlqError) {
|
|
@@ -4536,15 +4536,14 @@ var handleMessage = async (logger2, streamingFunctionWithConfigList, message, pr
|
|
|
4536
4536
|
}
|
|
4537
4537
|
})
|
|
4538
4538
|
);
|
|
4539
|
-
const processedMessages = transformedData.map((userFunctionOutput
|
|
4540
|
-
const [_, config] = streamingFunctionWithConfigList[i];
|
|
4539
|
+
const processedMessages = transformedData.map((userFunctionOutput) => {
|
|
4541
4540
|
if (userFunctionOutput) {
|
|
4542
4541
|
if (Array.isArray(userFunctionOutput)) {
|
|
4543
4542
|
return userFunctionOutput.flat().filter((item) => item !== void 0 && item !== null).map((item) => ({
|
|
4544
4543
|
value: JSON.stringify(item),
|
|
4545
4544
|
originalValue: parsedData,
|
|
4546
4545
|
originalMessage: message,
|
|
4547
|
-
|
|
4546
|
+
dlqTopicName
|
|
4548
4547
|
}));
|
|
4549
4548
|
} else {
|
|
4550
4549
|
return [
|
|
@@ -4552,7 +4551,7 @@ var handleMessage = async (logger2, streamingFunctionWithConfigList, message, pr
|
|
|
4552
4551
|
value: JSON.stringify(userFunctionOutput),
|
|
4553
4552
|
originalValue: parsedData,
|
|
4554
4553
|
originalMessage: message,
|
|
4555
|
-
|
|
4554
|
+
dlqTopicName
|
|
4556
4555
|
}
|
|
4557
4556
|
];
|
|
4558
4557
|
}
|
|
@@ -4580,11 +4579,10 @@ var handleDLQForFailedMessages = async (logger2, producer, messages, error) => {
|
|
|
4580
4579
|
let messagesWithoutDLQ = 0;
|
|
4581
4580
|
let dlqErrors = 0;
|
|
4582
4581
|
for (const msg of messages) {
|
|
4583
|
-
if (msg.
|
|
4582
|
+
if (msg.dlqTopicName && msg.originalValue) {
|
|
4584
4583
|
const deadLetterRecord = {
|
|
4585
4584
|
originalRecord: {
|
|
4586
4585
|
...msg.originalValue,
|
|
4587
|
-
// Include original Kafka message metadata
|
|
4588
4586
|
__sourcePartition: msg.originalMessage.partition,
|
|
4589
4587
|
__sourceOffset: msg.originalMessage.offset,
|
|
4590
4588
|
__sourceTimestamp: msg.originalMessage.timestamp
|
|
@@ -4596,21 +4594,21 @@ var handleDLQForFailedMessages = async (logger2, producer, messages, error) => {
|
|
|
4596
4594
|
};
|
|
4597
4595
|
cliLog({
|
|
4598
4596
|
action: "DeadLetter",
|
|
4599
|
-
message: `Sending failed message to DLQ ${msg.
|
|
4597
|
+
message: `Sending failed message to DLQ ${msg.dlqTopicName}: ${error instanceof Error ? error.message : String(error)}`,
|
|
4600
4598
|
message_type: "Error"
|
|
4601
4599
|
});
|
|
4602
4600
|
try {
|
|
4603
4601
|
await producer.send({
|
|
4604
|
-
topic: msg.
|
|
4602
|
+
topic: msg.dlqTopicName,
|
|
4605
4603
|
messages: [{ value: JSON.stringify(deadLetterRecord) }]
|
|
4606
4604
|
});
|
|
4607
|
-
logger2.log(`Sent failed message to DLQ ${msg.
|
|
4605
|
+
logger2.log(`Sent failed message to DLQ ${msg.dlqTopicName}`);
|
|
4608
4606
|
messagesHandledByDLQ++;
|
|
4609
4607
|
} catch (dlqError) {
|
|
4610
4608
|
logger2.error(`Failed to send to DLQ: ${dlqError}`);
|
|
4611
4609
|
dlqErrors++;
|
|
4612
4610
|
}
|
|
4613
|
-
} else if (!msg.
|
|
4611
|
+
} else if (!msg.dlqTopicName) {
|
|
4614
4612
|
messagesWithoutDLQ++;
|
|
4615
4613
|
logger2.warn(`Cannot send to DLQ: no DLQ configured for message`);
|
|
4616
4614
|
} else {
|
|
@@ -4765,7 +4763,8 @@ var startConsumer = async (args, logger2, metrics, _parallelism, consumer, produ
|
|
|
4765
4763
|
message,
|
|
4766
4764
|
producer,
|
|
4767
4765
|
fieldMutations,
|
|
4768
|
-
args.logPayloads
|
|
4766
|
+
args.logPayloads,
|
|
4767
|
+
args.dlqTopic?.name
|
|
4769
4768
|
);
|
|
4770
4769
|
},
|
|
4771
4770
|
{
|
|
@@ -5424,11 +5423,15 @@ program.command("consumption-apis").description("Run consumption APIs").argument
|
|
|
5424
5423
|
program.command("streaming-functions").description("Run streaming functions").argument("<source-topic>", "Source topic configuration as JSON").argument("<function-file-path>", "Path to the function file").argument(
|
|
5425
5424
|
"<broker>",
|
|
5426
5425
|
"Kafka broker address(es) - comma-separated for multiple brokers (e.g., 'broker1:9092, broker2:9092'). Whitespace around commas is automatically trimmed."
|
|
5427
|
-
).argument("<max-subscriber-count>", "Maximum number of subscribers").option("--target-topic <target-topic>", "Target topic configuration as JSON").option(
|
|
5426
|
+
).argument("<max-subscriber-count>", "Maximum number of subscribers").option("--target-topic <target-topic>", "Target topic configuration as JSON").option(
|
|
5427
|
+
"--dlq-topic <dlq-topic>",
|
|
5428
|
+
"Dead letter queue topic configuration as JSON"
|
|
5429
|
+
).option("--sasl-username <username>", "SASL username").option("--sasl-password <password>", "SASL password").option("--sasl-mechanism <mechanism>", "SASL mechanism").option("--security-protocol <protocol>", "Security protocol").option("--log-payloads", "Log payloads for debugging", false).action(
|
|
5428
5430
|
(sourceTopic, functionFilePath, broker, maxSubscriberCount, options) => {
|
|
5429
5431
|
const config = {
|
|
5430
5432
|
sourceTopic: JSON.parse(sourceTopic),
|
|
5431
5433
|
targetTopic: options.targetTopic ? JSON.parse(options.targetTopic) : void 0,
|
|
5434
|
+
dlqTopic: options.dlqTopic ? JSON.parse(options.dlqTopic) : void 0,
|
|
5432
5435
|
functionFilePath,
|
|
5433
5436
|
broker,
|
|
5434
5437
|
maxSubscriberCount: parseInt(maxSubscriberCount),
|