@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.
package/dist/index.mjs CHANGED
@@ -18,6 +18,7 @@ var __export = (target, all) => {
18
18
  var commons_exports = {};
19
19
  __export(commons_exports, {
20
20
  ACKs: () => ACKs,
21
+ LogLevel: () => LogLevel,
21
22
  MAX_RETRIES: () => MAX_RETRIES,
22
23
  MAX_RETRIES_PRODUCER: () => MAX_RETRIES_PRODUCER,
23
24
  MAX_RETRY_TIME_MS: () => MAX_RETRY_TIME_MS,
@@ -49,6 +50,36 @@ function isTruthy(value) {
49
50
  return false;
50
51
  }
51
52
  }
53
+ function parseLogLevel(value) {
54
+ if (!value) return "Info" /* Info */;
55
+ const normalized = value.trim();
56
+ switch (normalized) {
57
+ case "Debug":
58
+ case "debug":
59
+ case "DEBUG":
60
+ return "Debug" /* Debug */;
61
+ case "Info":
62
+ case "info":
63
+ case "INFO":
64
+ return "Info" /* Info */;
65
+ case "Warn":
66
+ case "warn":
67
+ case "WARN":
68
+ return "Warn" /* Warn */;
69
+ case "Error":
70
+ case "error":
71
+ case "ERROR":
72
+ return "Error" /* Error */;
73
+ default:
74
+ return "Info" /* Info */;
75
+ }
76
+ }
77
+ function getLogLevel() {
78
+ if (cachedLogLevel === null) {
79
+ cachedLogLevel = parseLogLevel(process.env.MOOSE_LOGGER__LEVEL);
80
+ }
81
+ return cachedLogLevel;
82
+ }
52
83
  function mapTstoJs(filePath) {
53
84
  return filePath.replace(/\.ts$/, ".js").replace(/\.cts$/, ".cjs").replace(/\.mts$/, ".mjs");
54
85
  }
@@ -74,13 +105,31 @@ async function getKafkaProducer(cfg, logger, maxMessageBytes) {
74
105
  await producer.connect();
75
106
  return producer;
76
107
  }
77
- var Kafka, compilerLog, antiCachePath, getFileName, getClickhouseClient, cliLog, MAX_RETRIES, MAX_RETRY_TIME_MS, RETRY_INITIAL_TIME_MS, MAX_RETRIES_PRODUCER, RETRY_FACTOR_PRODUCER, ACKs, parseBrokerString, logError, buildSaslConfig, getKafkaClient;
108
+ var Kafka, LogLevel, cachedLogLevel, compilerLog, antiCachePath, getFileName, getClickhouseClient, cliLog, MAX_RETRIES, MAX_RETRY_TIME_MS, RETRY_INITIAL_TIME_MS, MAX_RETRIES_PRODUCER, RETRY_FACTOR_PRODUCER, ACKs, parseBrokerString, logError, buildSaslConfig, getKafkaClient;
78
109
  var init_commons = __esm({
79
110
  "src/commons.ts"() {
80
111
  "use strict";
81
112
  ({ Kafka } = KafkaJS);
82
- compilerLog = (message) => {
83
- if (!isTruthy(process.env.MOOSE_DISABLE_COMPILER_LOGS)) {
113
+ LogLevel = /* @__PURE__ */ ((LogLevel2) => {
114
+ LogLevel2["Debug"] = "Debug";
115
+ LogLevel2["Info"] = "Info";
116
+ LogLevel2["Warn"] = "Warn";
117
+ LogLevel2["Error"] = "Error";
118
+ return LogLevel2;
119
+ })(LogLevel || {});
120
+ cachedLogLevel = null;
121
+ compilerLog = (message, level = "Debug" /* Debug */) => {
122
+ if (isTruthy(process.env.MOOSE_DISABLE_COMPILER_LOGS)) {
123
+ return;
124
+ }
125
+ const currentLevel = getLogLevel();
126
+ const levelPriority = {
127
+ ["Debug" /* Debug */]: 0,
128
+ ["Info" /* Info */]: 1,
129
+ ["Warn" /* Warn */]: 2,
130
+ ["Error" /* Error */]: 3
131
+ };
132
+ if (levelPriority[level] >= levelPriority[currentLevel]) {
84
133
  console.log(message);
85
134
  }
86
135
  };
@@ -108,7 +157,17 @@ var init_commons = __esm({
108
157
  username,
109
158
  password,
110
159
  database,
111
- application: "moose"
160
+ application: "moose",
161
+ // Connection pool configuration for high load (100+ concurrent users)
162
+ max_open_connections: 50,
163
+ // Increased from default 10 to handle 100 concurrent users
164
+ request_timeout: 6e4,
165
+ // 60s timeout for HTTP requests (queries and inserts)
166
+ keep_alive: {
167
+ enabled: true,
168
+ idle_socket_ttl: 2e3
169
+ // 2s idle time (lower than default to prevent socket hang-ups)
170
+ }
112
171
  // Note: wait_end_of_query is configured per operation type, not globally
113
172
  // to preserve SELECT query performance while ensuring INSERT/DDL reliability
114
173
  });
@@ -2830,7 +2889,21 @@ async function getTemporalClient(temporalUrl, namespace, clientCert, clientKey,
2830
2889
  );
2831
2890
  let connectionOptions = {
2832
2891
  address: temporalUrl,
2833
- connectTimeout: "3s"
2892
+ connectTimeout: "30s",
2893
+ // Increased from 3s to handle high load
2894
+ // Add gRPC keepalive to prevent connection drops
2895
+ channelArgs: {
2896
+ "grpc.keepalive_time_ms": 3e4,
2897
+ // Send keepalive every 30s
2898
+ "grpc.keepalive_timeout_ms": 15e3,
2899
+ // Wait 15s for keepalive response
2900
+ "grpc.keepalive_permit_without_calls": 1,
2901
+ // Allow keepalive without active calls
2902
+ "grpc.http2.max_pings_without_data": 0,
2903
+ // No limit on pings without data
2904
+ "grpc.http2.min_time_between_pings_ms": 1e4
2905
+ // Min 10s between pings
2906
+ }
2834
2907
  };
2835
2908
  if (clientCert && clientKey) {
2836
2909
  console.log("Using TLS for secure Temporal");
@@ -3286,6 +3359,7 @@ export {
3286
3359
  IngestApi,
3287
3360
  IngestPipeline,
3288
3361
  LifeCycle,
3362
+ LogLevel,
3289
3363
  MAX_RETRIES,
3290
3364
  MAX_RETRIES_PRODUCER,
3291
3365
  MAX_RETRY_TIME_MS,