@514labs/moose-lib 0.6.260-ci-3-g63948580 → 0.6.260-ci-2-g1b93253f

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.
@@ -39,6 +39,36 @@ function isTruthy(value) {
39
39
  return false;
40
40
  }
41
41
  }
42
+ function parseLogLevel(value) {
43
+ if (!value) return "Info" /* Info */;
44
+ const normalized = value.trim();
45
+ switch (normalized) {
46
+ case "Debug":
47
+ case "debug":
48
+ case "DEBUG":
49
+ return "Debug" /* Debug */;
50
+ case "Info":
51
+ case "info":
52
+ case "INFO":
53
+ return "Info" /* Info */;
54
+ case "Warn":
55
+ case "warn":
56
+ case "WARN":
57
+ return "Warn" /* Warn */;
58
+ case "Error":
59
+ case "error":
60
+ case "ERROR":
61
+ return "Error" /* Error */;
62
+ default:
63
+ return "Info" /* Info */;
64
+ }
65
+ }
66
+ function getLogLevel() {
67
+ if (cachedLogLevel === null) {
68
+ cachedLogLevel = parseLogLevel(process.env.MOOSE_LOGGER__LEVEL);
69
+ }
70
+ return cachedLogLevel;
71
+ }
42
72
  function createProducerConfig(maxMessageBytes) {
43
73
  return {
44
74
  kafkaJS: {
@@ -55,7 +85,7 @@ function createProducerConfig(maxMessageBytes) {
55
85
  ...maxMessageBytes && { "message.max.bytes": maxMessageBytes }
56
86
  };
57
87
  }
58
- var import_http, import_client, import_kafka_javascript, Kafka, compilerLog, getClickhouseClient, cliLog, MAX_RETRIES, MAX_RETRY_TIME_MS, RETRY_INITIAL_TIME_MS, MAX_RETRIES_PRODUCER, ACKs, parseBrokerString, logError, buildSaslConfig, getKafkaClient;
88
+ var import_http, import_client, import_kafka_javascript, Kafka, cachedLogLevel, compilerLog, getClickhouseClient, cliLog, MAX_RETRIES, MAX_RETRY_TIME_MS, RETRY_INITIAL_TIME_MS, MAX_RETRIES_PRODUCER, ACKs, parseBrokerString, logError, buildSaslConfig, getKafkaClient;
59
89
  var init_commons = __esm({
60
90
  "src/commons.ts"() {
61
91
  "use strict";
@@ -63,8 +93,19 @@ var init_commons = __esm({
63
93
  import_client = require("@clickhouse/client");
64
94
  import_kafka_javascript = require("@confluentinc/kafka-javascript");
65
95
  ({ Kafka } = import_kafka_javascript.KafkaJS);
66
- compilerLog = (message) => {
67
- if (!isTruthy(process.env.MOOSE_DISABLE_COMPILER_LOGS)) {
96
+ cachedLogLevel = null;
97
+ compilerLog = (message, level = "Debug" /* Debug */) => {
98
+ if (isTruthy(process.env.MOOSE_DISABLE_COMPILER_LOGS)) {
99
+ return;
100
+ }
101
+ const currentLevel = getLogLevel();
102
+ const levelPriority = {
103
+ ["Debug" /* Debug */]: 0,
104
+ ["Info" /* Info */]: 1,
105
+ ["Warn" /* Warn */]: 2,
106
+ ["Error" /* Error */]: 3
107
+ };
108
+ if (levelPriority[level] >= levelPriority[currentLevel]) {
68
109
  console.log(message);
69
110
  }
70
111
  };
@@ -83,7 +124,17 @@ var init_commons = __esm({
83
124
  username,
84
125
  password,
85
126
  database,
86
- application: "moose"
127
+ application: "moose",
128
+ // Connection pool configuration for high load (100+ concurrent users)
129
+ max_open_connections: 50,
130
+ // Increased from default 10 to handle 100 concurrent users
131
+ request_timeout: 6e4,
132
+ // 60s timeout for HTTP requests (queries and inserts)
133
+ keep_alive: {
134
+ enabled: true,
135
+ idle_socket_ttl: 2e3
136
+ // 2s idle time (lower than default to prevent socket hang-ups)
137
+ }
87
138
  // Note: wait_end_of_query is configured per operation type, not globally
88
139
  // to preserve SELECT query performance while ensuring INSERT/DDL reliability
89
140
  });
@@ -469,7 +520,21 @@ async function getTemporalClient(temporalUrl, namespace, clientCert, clientKey,
469
520
  );
470
521
  let connectionOptions = {
471
522
  address: temporalUrl,
472
- connectTimeout: "3s"
523
+ connectTimeout: "30s",
524
+ // Increased from 3s to handle high load
525
+ // Add gRPC keepalive to prevent connection drops
526
+ channelArgs: {
527
+ "grpc.keepalive_time_ms": 3e4,
528
+ // Send keepalive every 30s
529
+ "grpc.keepalive_timeout_ms": 15e3,
530
+ // Wait 15s for keepalive response
531
+ "grpc.keepalive_permit_without_calls": 1,
532
+ // Allow keepalive without active calls
533
+ "grpc.http2.max_pings_without_data": 0,
534
+ // No limit on pings without data
535
+ "grpc.http2.min_time_between_pings_ms": 1e4
536
+ // Min 10s between pings
537
+ }
473
538
  };
474
539
  if (clientCert && clientKey) {
475
540
  console.log("Using TLS for secure Temporal");
@@ -2560,7 +2625,22 @@ async function createTemporalConnection(logger2, temporalConfig) {
2560
2625
  `<workflow> Using temporal_url: ${temporalConfig.url} and namespace: ${temporalConfig.namespace}`
2561
2626
  );
2562
2627
  let connectionOptions = {
2563
- address: temporalConfig.url
2628
+ address: temporalConfig.url,
2629
+ connectTimeout: 3e4,
2630
+ // 30s connection timeout
2631
+ // Add gRPC keepalive for worker stability
2632
+ channelArgs: {
2633
+ "grpc.keepalive_time_ms": 3e4,
2634
+ // Send keepalive every 30s
2635
+ "grpc.keepalive_timeout_ms": 15e3,
2636
+ // Wait 15s for keepalive response
2637
+ "grpc.keepalive_permit_without_calls": 1,
2638
+ // Allow keepalive without active calls
2639
+ "grpc.http2.max_pings_without_data": 0,
2640
+ // No limit on pings without data
2641
+ "grpc.http2.min_time_between_pings_ms": 1e4
2642
+ // Min 10s between pings
2643
+ }
2564
2644
  };
2565
2645
  if (temporalConfig.clientCert && temporalConfig.clientKey) {
2566
2646
  logger2.info("Using TLS for secure Temporal");