@teamkeel/functions-runtime 0.387.0 → 0.387.1-next.2
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/package.json +5 -2
- package/src/database.js +28 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamkeel/functions-runtime",
|
|
3
|
-
"version": "0.387.
|
|
3
|
+
"version": "0.387.1-next.2",
|
|
4
4
|
"description": "Internal package used by @teamkeel/sdk",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"vitest": "^0.34.6"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
+
"@neondatabase/serverless": "^0.9.3",
|
|
22
23
|
"@opentelemetry/api": "^1.7.0",
|
|
23
24
|
"@opentelemetry/exporter-trace-otlp-proto": "^0.46.0",
|
|
24
25
|
"@opentelemetry/resources": "^1.19.0",
|
|
@@ -28,7 +29,9 @@
|
|
|
28
29
|
"json-rpc-2.0": "^1.7.0",
|
|
29
30
|
"ksuid": "^3.0.0",
|
|
30
31
|
"kysely": "^0.25.0",
|
|
32
|
+
"kysely-neon": "^1.3.0",
|
|
31
33
|
"pg": "^8.11.3",
|
|
32
|
-
"traceparent": "^1.0.0"
|
|
34
|
+
"traceparent": "^1.0.0",
|
|
35
|
+
"ws": "^8.17.1"
|
|
33
36
|
}
|
|
34
37
|
}
|
package/src/database.js
CHANGED
|
@@ -4,6 +4,8 @@ const { AuditContextPlugin } = require("./auditing");
|
|
|
4
4
|
const pg = require("pg");
|
|
5
5
|
const { PROTO_ACTION_TYPES } = require("./consts");
|
|
6
6
|
const { withSpan } = require("./tracing");
|
|
7
|
+
import { NeonDialect } from "kysely-neon";
|
|
8
|
+
import ws from 'ws';
|
|
7
9
|
|
|
8
10
|
// withDatabase is responsible for setting the correct database client in our AsyncLocalStorage
|
|
9
11
|
// so that the the code in a custom function uses the correct client.
|
|
@@ -148,26 +150,34 @@ function getDialect() {
|
|
|
148
150
|
return parseFloat(val);
|
|
149
151
|
});
|
|
150
152
|
|
|
151
|
-
return new
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// Increased idle time before closing a connection in the local pool (from 10s default).
|
|
155
|
-
// Establising a new connection on (almost) every functions query can be expensive, so this
|
|
156
|
-
// will reduce having to open connections as regularly. https://node-postgres.com/apis/pool
|
|
157
|
-
//
|
|
158
|
-
// NOTE: We should consider setting this to 0 (i.e. never pool locally) and open and close
|
|
159
|
-
// connections with each invocation. This is because the freeze/thaw nature of lambdas can cause problems
|
|
160
|
-
// with long-lived connections - see https://github.com/brianc/node-postgres/issues/2718
|
|
161
|
-
// Once we're "fully regional" this should not be a performance problem anymore.
|
|
162
|
-
//
|
|
163
|
-
// Although I doubt we will run into these freeze/thaw issues if idleTimeoutMillis is always shorter than the
|
|
164
|
-
// time is takes for a lambda to freeze (which is not a constant, but could be as short as several minutes,
|
|
165
|
-
// https://www.pluralsight.com/resources/blog/cloud/how-long-does-aws-lambda-keep-your-idle-functions-around-before-a-cold-start)
|
|
166
|
-
idleTimeoutMillis: 120000,
|
|
167
|
-
connectionString: mustEnv("KEEL_DB_CONN"),
|
|
168
|
-
}),
|
|
153
|
+
return new NeonDialect({
|
|
154
|
+
connectionString: "postgresql://neondb_owner:MKdyUwxQIj48@ep-aged-silence-a2c04fyv.eu-central-1.aws.neon.tech/neondb?sslmode=require",//mustEnv("KEEL_DB_CONN"),
|
|
155
|
+
webSocketConstructor: ws,
|
|
169
156
|
});
|
|
170
157
|
|
|
158
|
+
// return new PostgresDialect({
|
|
159
|
+
// connectisonString: mustEnv("KEEL_DB_CONN"),
|
|
160
|
+
// client: new InstrumentedClient,
|
|
161
|
+
// // pool: new InstrumentedPool({
|
|
162
|
+
// // Client: InstrumentedClient,
|
|
163
|
+
// // // Increased idle time before closing a connection in the local pool (from 10s default).
|
|
164
|
+
// // // Establising a new connection on (almost) every functions query can be expensive, so this
|
|
165
|
+
// // // will reduce having to open connections as regularly. https://node-postgres.com/apis/pool
|
|
166
|
+
// // //
|
|
167
|
+
// // // NOTE: We should consider setting this to 0 (i.e. never pool locally) and open and close
|
|
168
|
+
// // // connections with each invocation. This is because the freeze/thaw nature of lambdas can cause problems
|
|
169
|
+
// // // with long-lived connections - see https://github.com/brianc/node-postgres/issues/2718
|
|
170
|
+
// // // Once we're "fully regional" this should not be a performance problem anymore.
|
|
171
|
+
// // //
|
|
172
|
+
// // // Although I doubt we will run into these freeze/thaw issues if idleTimeoutMillis is always shorter than the
|
|
173
|
+
// // // time is takes for a lambda to freeze (which is not a constant, but could be as short as several minutes,
|
|
174
|
+
// // // https://www.pluralsight.com/resources/blog/cloud/how-long-does-aws-lambda-keep-your-idle-functions-around-before-a-cold-start)
|
|
175
|
+
// // idleTimeoutMillis: 0,
|
|
176
|
+
// // connectionTimeoutMillis: 0,
|
|
177
|
+
// // connectionString: mustEnv("KEEL_DB_CONN"),
|
|
178
|
+
// // }),
|
|
179
|
+
// });
|
|
180
|
+
|
|
171
181
|
default:
|
|
172
182
|
throw Error("unexpected KEEL_DB_CONN_TYPE: " + dbConnType);
|
|
173
183
|
}
|