@514labs/moose-lib 0.6.256 → 0.6.257

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/index.mjs CHANGED
@@ -26,6 +26,7 @@ __export(commons_exports, {
26
26
  antiCachePath: () => antiCachePath,
27
27
  cliLog: () => cliLog,
28
28
  compilerLog: () => compilerLog,
29
+ createProducerConfig: () => createProducerConfig,
29
30
  getClickhouseClient: () => getClickhouseClient,
30
31
  getFileName: () => getFileName,
31
32
  getKafkaClient: () => getKafkaClient,
@@ -51,18 +52,25 @@ function isTruthy(value) {
51
52
  function mapTstoJs(filePath) {
52
53
  return filePath.replace(/\.ts$/, ".js").replace(/\.cts$/, ".cjs").replace(/\.mts$/, ".mjs");
53
54
  }
54
- async function getKafkaProducer(cfg, logger) {
55
- const kafka = await getKafkaClient(cfg, logger);
56
- const producer = kafka.producer({
55
+ function createProducerConfig(maxMessageBytes) {
56
+ return {
57
57
  kafkaJS: {
58
- idempotent: true,
58
+ idempotent: false,
59
+ // Not needed for at-least-once delivery
59
60
  acks: ACKs,
60
61
  retry: {
61
62
  retries: MAX_RETRIES_PRODUCER,
62
63
  maxRetryTime: MAX_RETRY_TIME_MS
63
64
  }
64
- }
65
- });
65
+ },
66
+ "linger.ms": 0,
67
+ // This is to make sure at least once delivery with immediate feedback on the send
68
+ ...maxMessageBytes && { "message.max.bytes": maxMessageBytes }
69
+ };
70
+ }
71
+ async function getKafkaProducer(cfg, logger, maxMessageBytes) {
72
+ const kafka = await getKafkaClient(cfg, logger);
73
+ const producer = kafka.producer(createProducerConfig(maxMessageBytes));
66
74
  await producer.connect();
67
75
  return producer;
68
76
  }
@@ -3304,6 +3312,7 @@ export {
3304
3312
  createClickhouseParameter,
3305
3313
  createConsumptionApi,
3306
3314
  createMaterializedView,
3315
+ createProducerConfig,
3307
3316
  dropView,
3308
3317
  expressMiddleware,
3309
3318
  getApi,