@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.
@@ -26,6 +26,36 @@ function isTruthy(value) {
26
26
  return false;
27
27
  }
28
28
  }
29
+ function parseLogLevel(value) {
30
+ if (!value) return "Info" /* Info */;
31
+ const normalized = value.trim();
32
+ switch (normalized) {
33
+ case "Debug":
34
+ case "debug":
35
+ case "DEBUG":
36
+ return "Debug" /* Debug */;
37
+ case "Info":
38
+ case "info":
39
+ case "INFO":
40
+ return "Info" /* Info */;
41
+ case "Warn":
42
+ case "warn":
43
+ case "WARN":
44
+ return "Warn" /* Warn */;
45
+ case "Error":
46
+ case "error":
47
+ case "ERROR":
48
+ return "Error" /* Error */;
49
+ default:
50
+ return "Info" /* Info */;
51
+ }
52
+ }
53
+ function getLogLevel() {
54
+ if (cachedLogLevel === null) {
55
+ cachedLogLevel = parseLogLevel(process.env.MOOSE_LOGGER__LEVEL);
56
+ }
57
+ return cachedLogLevel;
58
+ }
29
59
  function createProducerConfig(maxMessageBytes) {
30
60
  return {
31
61
  kafkaJS: {
@@ -42,13 +72,24 @@ function createProducerConfig(maxMessageBytes) {
42
72
  ...maxMessageBytes && { "message.max.bytes": maxMessageBytes }
43
73
  };
44
74
  }
45
- var Kafka, compilerLog, getClickhouseClient, cliLog, MAX_RETRIES, MAX_RETRY_TIME_MS, RETRY_INITIAL_TIME_MS, MAX_RETRIES_PRODUCER, ACKs, parseBrokerString, logError, buildSaslConfig, getKafkaClient;
75
+ var Kafka, cachedLogLevel, compilerLog, getClickhouseClient, cliLog, MAX_RETRIES, MAX_RETRY_TIME_MS, RETRY_INITIAL_TIME_MS, MAX_RETRIES_PRODUCER, ACKs, parseBrokerString, logError, buildSaslConfig, getKafkaClient;
46
76
  var init_commons = __esm({
47
77
  "src/commons.ts"() {
48
78
  "use strict";
49
79
  ({ Kafka } = KafkaJS);
50
- compilerLog = (message) => {
51
- if (!isTruthy(process.env.MOOSE_DISABLE_COMPILER_LOGS)) {
80
+ cachedLogLevel = null;
81
+ compilerLog = (message, level = "Debug" /* Debug */) => {
82
+ if (isTruthy(process.env.MOOSE_DISABLE_COMPILER_LOGS)) {
83
+ return;
84
+ }
85
+ const currentLevel = getLogLevel();
86
+ const levelPriority = {
87
+ ["Debug" /* Debug */]: 0,
88
+ ["Info" /* Info */]: 1,
89
+ ["Warn" /* Warn */]: 2,
90
+ ["Error" /* Error */]: 3
91
+ };
92
+ if (levelPriority[level] >= levelPriority[currentLevel]) {
52
93
  console.log(message);
53
94
  }
54
95
  };
@@ -67,7 +108,17 @@ var init_commons = __esm({
67
108
  username,
68
109
  password,
69
110
  database,
70
- application: "moose"
111
+ application: "moose",
112
+ // Connection pool configuration for high load (100+ concurrent users)
113
+ max_open_connections: 50,
114
+ // Increased from default 10 to handle 100 concurrent users
115
+ request_timeout: 6e4,
116
+ // 60s timeout for HTTP requests (queries and inserts)
117
+ keep_alive: {
118
+ enabled: true,
119
+ idle_socket_ttl: 2e3
120
+ // 2s idle time (lower than default to prevent socket hang-ups)
121
+ }
71
122
  // Note: wait_end_of_query is configured per operation type, not globally
72
123
  // to preserve SELECT query performance while ensuring INSERT/DDL reliability
73
124
  });
@@ -456,7 +507,21 @@ async function getTemporalClient(temporalUrl, namespace, clientCert, clientKey,
456
507
  );
457
508
  let connectionOptions = {
458
509
  address: temporalUrl,
459
- connectTimeout: "3s"
510
+ connectTimeout: "30s",
511
+ // Increased from 3s to handle high load
512
+ // Add gRPC keepalive to prevent connection drops
513
+ channelArgs: {
514
+ "grpc.keepalive_time_ms": 3e4,
515
+ // Send keepalive every 30s
516
+ "grpc.keepalive_timeout_ms": 15e3,
517
+ // Wait 15s for keepalive response
518
+ "grpc.keepalive_permit_without_calls": 1,
519
+ // Allow keepalive without active calls
520
+ "grpc.http2.max_pings_without_data": 0,
521
+ // No limit on pings without data
522
+ "grpc.http2.min_time_between_pings_ms": 1e4
523
+ // Min 10s between pings
524
+ }
460
525
  };
461
526
  if (clientCert && clientKey) {
462
527
  console.log("Using TLS for secure Temporal");
@@ -2555,7 +2620,22 @@ async function createTemporalConnection(logger2, temporalConfig) {
2555
2620
  `<workflow> Using temporal_url: ${temporalConfig.url} and namespace: ${temporalConfig.namespace}`
2556
2621
  );
2557
2622
  let connectionOptions = {
2558
- address: temporalConfig.url
2623
+ address: temporalConfig.url,
2624
+ connectTimeout: 3e4,
2625
+ // 30s connection timeout
2626
+ // Add gRPC keepalive for worker stability
2627
+ channelArgs: {
2628
+ "grpc.keepalive_time_ms": 3e4,
2629
+ // Send keepalive every 30s
2630
+ "grpc.keepalive_timeout_ms": 15e3,
2631
+ // Wait 15s for keepalive response
2632
+ "grpc.keepalive_permit_without_calls": 1,
2633
+ // Allow keepalive without active calls
2634
+ "grpc.http2.max_pings_without_data": 0,
2635
+ // No limit on pings without data
2636
+ "grpc.http2.min_time_between_pings_ms": 1e4
2637
+ // Min 10s between pings
2638
+ }
2559
2639
  };
2560
2640
  if (temporalConfig.clientCert && temporalConfig.clientKey) {
2561
2641
  logger2.info("Using TLS for secure Temporal");