@514labs/moose-lib 0.6.303 → 0.6.304
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/moose-runner.js +18 -4
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +18 -4
- package/dist/moose-runner.mjs.map +1 -1
- package/package.json +1 -1
package/dist/moose-runner.js
CHANGED
|
@@ -2621,7 +2621,7 @@ var stopConsumer = async (logger2, consumer, sourceTopic) => {
|
|
|
2621
2621
|
}
|
|
2622
2622
|
}
|
|
2623
2623
|
};
|
|
2624
|
-
var handleMessage = async (logger2, streamingFunctionWithConfigList, message, producer, fieldMutations) => {
|
|
2624
|
+
var handleMessage = async (logger2, streamingFunctionWithConfigList, message, producer, fieldMutations, logPayloads) => {
|
|
2625
2625
|
if (message.value === void 0 || message.value === null) {
|
|
2626
2626
|
logger2.log(`Received message with no value, skipping...`);
|
|
2627
2627
|
return void 0;
|
|
@@ -2633,6 +2633,9 @@ var handleMessage = async (logger2, streamingFunctionWithConfigList, message, pr
|
|
|
2633
2633
|
}
|
|
2634
2634
|
const parsedData = JSON.parse(payloadBuffer.toString());
|
|
2635
2635
|
mutateParsedJson(parsedData, fieldMutations);
|
|
2636
|
+
if (logPayloads) {
|
|
2637
|
+
logger2.log(`[PAYLOAD:STREAM_IN] ${JSON.stringify(parsedData)}`);
|
|
2638
|
+
}
|
|
2636
2639
|
const transformedData = await Promise.all(
|
|
2637
2640
|
streamingFunctionWithConfigList.map(async ([fn, config]) => {
|
|
2638
2641
|
try {
|
|
@@ -2677,7 +2680,7 @@ var handleMessage = async (logger2, streamingFunctionWithConfigList, message, pr
|
|
|
2677
2680
|
}
|
|
2678
2681
|
})
|
|
2679
2682
|
);
|
|
2680
|
-
|
|
2683
|
+
const processedMessages = transformedData.map((userFunctionOutput, i) => {
|
|
2681
2684
|
const [_, config] = streamingFunctionWithConfigList[i];
|
|
2682
2685
|
if (userFunctionOutput) {
|
|
2683
2686
|
if (Array.isArray(userFunctionOutput)) {
|
|
@@ -2699,6 +2702,15 @@ var handleMessage = async (logger2, streamingFunctionWithConfigList, message, pr
|
|
|
2699
2702
|
}
|
|
2700
2703
|
}
|
|
2701
2704
|
}).flat().filter((item) => item !== void 0 && item !== null);
|
|
2705
|
+
if (logPayloads) {
|
|
2706
|
+
if (processedMessages.length > 0) {
|
|
2707
|
+
const outgoingJsonStrings = processedMessages.map((msg) => msg.value);
|
|
2708
|
+
logger2.log(`[PAYLOAD:STREAM_OUT] [${outgoingJsonStrings.join(",")}]`);
|
|
2709
|
+
} else {
|
|
2710
|
+
logger2.log(`[PAYLOAD:STREAM_OUT] (no output from streaming function)`);
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
return processedMessages;
|
|
2702
2714
|
} catch (e) {
|
|
2703
2715
|
logger2.error(`Failed to transform data`);
|
|
2704
2716
|
if (e instanceof Error) {
|
|
@@ -2911,7 +2923,8 @@ var startConsumer = async (args, logger2, metrics, _parallelism, consumer, produ
|
|
|
2911
2923
|
streamingFunctions,
|
|
2912
2924
|
message,
|
|
2913
2925
|
producer,
|
|
2914
|
-
fieldMutations
|
|
2926
|
+
fieldMutations,
|
|
2927
|
+
args.logPayloads
|
|
2915
2928
|
);
|
|
2916
2929
|
},
|
|
2917
2930
|
{
|
|
@@ -3576,7 +3589,7 @@ program.command("consumption-apis").description("Run consumption APIs").argument
|
|
|
3576
3589
|
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(
|
|
3577
3590
|
"<broker>",
|
|
3578
3591
|
"Kafka broker address(es) - comma-separated for multiple brokers (e.g., 'broker1:9092, broker2:9092'). Whitespace around commas is automatically trimmed."
|
|
3579
|
-
).argument("<max-subscriber-count>", "Maximum number of subscribers").option("--target-topic <target-topic>", "Target topic configuration as JSON").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("--is-dmv2", "Whether this is a DMv2 function", false).action(
|
|
3592
|
+
).argument("<max-subscriber-count>", "Maximum number of subscribers").option("--target-topic <target-topic>", "Target topic configuration as JSON").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("--is-dmv2", "Whether this is a DMv2 function", false).option("--log-payloads", "Log payloads for debugging", false).action(
|
|
3580
3593
|
(sourceTopic, functionFilePath, broker, maxSubscriberCount, options) => {
|
|
3581
3594
|
const config = {
|
|
3582
3595
|
sourceTopic: JSON.parse(sourceTopic),
|
|
@@ -3585,6 +3598,7 @@ program.command("streaming-functions").description("Run streaming functions").ar
|
|
|
3585
3598
|
broker,
|
|
3586
3599
|
maxSubscriberCount: parseInt(maxSubscriberCount),
|
|
3587
3600
|
isDmv2: options.isDmv2,
|
|
3601
|
+
logPayloads: options.logPayloads,
|
|
3588
3602
|
saslUsername: options.saslUsername,
|
|
3589
3603
|
saslPassword: options.saslPassword,
|
|
3590
3604
|
saslMechanism: options.saslMechanism,
|