@intelligems/sst 2.49.6-ig.6 → 2.49.6-ig.8
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/cli/sst.js +0 -0
- package/iot.d.ts +31 -0
- package/iot.js +79 -0
- package/package.json +9 -8
- package/runtime/iot.js +5 -2
- package/support/dotnet31-bootstrap/release/Amazon.Lambda.Core.dll +0 -0
- package/support/dotnet31-bootstrap/release/Amazon.Lambda.RuntimeSupport.dll +0 -0
- package/support/dotnet31-bootstrap/release/System.Runtime.CompilerServices.Unsafe.dll +0 -0
- package/support/dotnet31-bootstrap/release/System.Text.Encodings.Web.dll +0 -0
- package/support/dotnet31-bootstrap/release/System.Text.Json.dll +0 -0
- package/support/dotnet31-bootstrap/release/dotnet-bootstrap +0 -0
- package/support/dotnet6-bootstrap/release/Amazon.Lambda.Core.dll +0 -0
- package/support/dotnet6-bootstrap/release/Amazon.Lambda.RuntimeSupport.dll +0 -0
- package/support/dotnet6-bootstrap/release/dotnet-bootstrap +0 -0
- package/support/dotnet8-bootstrap/release/Amazon.Lambda.Core.dll +0 -0
- package/support/dotnet8-bootstrap/release/Amazon.Lambda.RuntimeSupport.dll +0 -0
- package/support/dotnet8-bootstrap/release/dotnet-bootstrap +0 -0
- package/support/java-runtime/install.sh +0 -0
- package/package.json.bak +0 -156
package/cli/sst.js
CHANGED
|
File without changes
|
package/iot.d.ts
CHANGED
|
@@ -4,4 +4,35 @@ export declare const useIOT: () => Promise<{
|
|
|
4
4
|
prefix: string;
|
|
5
5
|
publish<Type extends keyof Events>(topic: string, type: Type, properties: Events[Type]): Promise<void>;
|
|
6
6
|
}>;
|
|
7
|
+
/**
|
|
8
|
+
* A second connection, carrying only small control messages.
|
|
9
|
+
*
|
|
10
|
+
* `useIOT` also carries response bodies. Those are fragmented into 50KB chunks
|
|
11
|
+
* and published at QoS 1, so every chunk waits on a broker round trip, and they
|
|
12
|
+
* queue on the same socket as everything else.
|
|
13
|
+
*
|
|
14
|
+
* `function.ack` cannot afford to wait behind them. The Lambda re-invokes if the
|
|
15
|
+
* ack does not arrive within two seconds, and each re-invocation re-runs the
|
|
16
|
+
* handler and puts another response body on the socket that is already busy —
|
|
17
|
+
* so a late ack makes the next ack later still. Measured on one machine before
|
|
18
|
+
* this change: ack publish went from 105ms to 10.2s inside a minute, publishes
|
|
19
|
+
* in flight from 15 to 439, and a single request executed fifteen times before
|
|
20
|
+
* the gateway returned 504 at 29s.
|
|
21
|
+
*
|
|
22
|
+
* Round-trip latency decides who sees it. A chunk costs a round trip to the
|
|
23
|
+
* region — roughly 90ms from Europe against 15ms from the US — so the same
|
|
24
|
+
* payload lands either side of the two second budget depending on where the
|
|
25
|
+
* developer sits.
|
|
26
|
+
*
|
|
27
|
+
* **The client id must differ from `useIOT`'s.** AWS IoT drops an existing
|
|
28
|
+
* connection when a new one presents the same id, so a shared id would make the
|
|
29
|
+
* two sockets disconnect each other in a loop.
|
|
30
|
+
*
|
|
31
|
+
* This connection deliberately does not subscribe. Inbound traffic still arrives
|
|
32
|
+
* on `useIOT`; this one only publishes.
|
|
33
|
+
*/
|
|
34
|
+
export declare const useIOTControl: () => Promise<{
|
|
35
|
+
prefix: string;
|
|
36
|
+
publish<Type extends keyof Events>(topic: string, type: Type, properties: Events[Type]): Promise<void>;
|
|
37
|
+
}>;
|
|
7
38
|
export declare const isSupported: () => boolean;
|
package/iot.js
CHANGED
|
@@ -189,6 +189,85 @@ export const useIOT = lazy(async () => {
|
|
|
189
189
|
},
|
|
190
190
|
};
|
|
191
191
|
});
|
|
192
|
+
/**
|
|
193
|
+
* A second connection, carrying only small control messages.
|
|
194
|
+
*
|
|
195
|
+
* `useIOT` also carries response bodies. Those are fragmented into 50KB chunks
|
|
196
|
+
* and published at QoS 1, so every chunk waits on a broker round trip, and they
|
|
197
|
+
* queue on the same socket as everything else.
|
|
198
|
+
*
|
|
199
|
+
* `function.ack` cannot afford to wait behind them. The Lambda re-invokes if the
|
|
200
|
+
* ack does not arrive within two seconds, and each re-invocation re-runs the
|
|
201
|
+
* handler and puts another response body on the socket that is already busy —
|
|
202
|
+
* so a late ack makes the next ack later still. Measured on one machine before
|
|
203
|
+
* this change: ack publish went from 105ms to 10.2s inside a minute, publishes
|
|
204
|
+
* in flight from 15 to 439, and a single request executed fifteen times before
|
|
205
|
+
* the gateway returned 504 at 29s.
|
|
206
|
+
*
|
|
207
|
+
* Round-trip latency decides who sees it. A chunk costs a round trip to the
|
|
208
|
+
* region — roughly 90ms from Europe against 15ms from the US — so the same
|
|
209
|
+
* payload lands either side of the two second budget depending on where the
|
|
210
|
+
* developer sits.
|
|
211
|
+
*
|
|
212
|
+
* **The client id must differ from `useIOT`'s.** AWS IoT drops an existing
|
|
213
|
+
* connection when a new one presents the same id, so a shared id would make the
|
|
214
|
+
* two sockets disconnect each other in a loop.
|
|
215
|
+
*
|
|
216
|
+
* This connection deliberately does not subscribe. Inbound traffic still arrives
|
|
217
|
+
* on `useIOT`; this one only publishes.
|
|
218
|
+
*/
|
|
219
|
+
export const useIOTControl = lazy(async () => {
|
|
220
|
+
const bus = useBus();
|
|
221
|
+
const endpoint = await useIOTEndpoint();
|
|
222
|
+
const creds = await useAWSCredentials();
|
|
223
|
+
const project = useProject();
|
|
224
|
+
const device = new iot.device({
|
|
225
|
+
protocol: "wss",
|
|
226
|
+
host: endpoint,
|
|
227
|
+
region: project.config.region,
|
|
228
|
+
accessKeyId: creds.accessKeyId,
|
|
229
|
+
secretKey: creds.secretAccessKey,
|
|
230
|
+
sessionToken: creds.sessionToken,
|
|
231
|
+
reconnectPeriod: 1,
|
|
232
|
+
keepalive: 60,
|
|
233
|
+
clientId: `sst-control-${Math.random().toString(16).slice(2)}`,
|
|
234
|
+
});
|
|
235
|
+
const PREFIX = `/sst/${project.config.name}/${project.config.stage}`;
|
|
236
|
+
device.on("connect", () => {
|
|
237
|
+
Logger.debug("IoT control connected");
|
|
238
|
+
});
|
|
239
|
+
device.on("error", (err) => {
|
|
240
|
+
Logger.debug("IoT control error", err);
|
|
241
|
+
});
|
|
242
|
+
device.on("close", () => {
|
|
243
|
+
Logger.debug("IoT control closed");
|
|
244
|
+
});
|
|
245
|
+
device.on("reconnect", () => {
|
|
246
|
+
Logger.debug("IoT control reconnecting...");
|
|
247
|
+
});
|
|
248
|
+
return {
|
|
249
|
+
prefix: PREFIX,
|
|
250
|
+
async publish(topic, type, properties) {
|
|
251
|
+
const payload = {
|
|
252
|
+
type,
|
|
253
|
+
properties,
|
|
254
|
+
sourceID: bus.sourceID,
|
|
255
|
+
};
|
|
256
|
+
// Control messages sit far below the fragment size, but the envelope has
|
|
257
|
+
// to match what the Lambda reassembles, so it is built the same way
|
|
258
|
+
// rather than assumed to be a single part.
|
|
259
|
+
const json = JSON.stringify(payload);
|
|
260
|
+
const parts = json.match(/.{1,50000}/g) ?? [];
|
|
261
|
+
const id = Math.random().toString();
|
|
262
|
+
await Promise.all(parts.map((data, index) => new Promise((r) => {
|
|
263
|
+
device.publish(topic, JSON.stringify({ id, index, count: parts.length, data }), { qos: 1 }, () => {
|
|
264
|
+
r();
|
|
265
|
+
});
|
|
266
|
+
})));
|
|
267
|
+
Logger.debug("IOT Control Published", topic, type);
|
|
268
|
+
},
|
|
269
|
+
};
|
|
270
|
+
});
|
|
192
271
|
export const isSupported = () => [
|
|
193
272
|
"eu-central-1",
|
|
194
273
|
"eu-west-1",
|
package/package.json
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sideEffects": false,
|
|
3
3
|
"name": "@intelligems/sst",
|
|
4
|
-
"version": "2.49.6-ig.
|
|
4
|
+
"version": "2.49.6-ig.8",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sst": "cli/sst.js"
|
|
7
7
|
},
|
|
8
8
|
"description": "A CLI to help deploy SST apps.",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"license": "MIT",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"prepare": "",
|
|
13
|
+
"build": "node build.mjs && tsc",
|
|
14
|
+
"test": "vitest run",
|
|
15
|
+
"dev": "source .env && tsc-watch --onSuccess \"rsync -av dist/* ${TO} --checksum\""
|
|
16
|
+
},
|
|
11
17
|
"repository": {
|
|
12
18
|
"type": "git",
|
|
13
19
|
"url": "git+https://github.com/sst/v2.git",
|
|
@@ -142,10 +148,5 @@
|
|
|
142
148
|
"test": "test"
|
|
143
149
|
},
|
|
144
150
|
"keywords": [],
|
|
145
|
-
"author": ""
|
|
146
|
-
|
|
147
|
-
"build": "node build.mjs && tsc",
|
|
148
|
-
"test": "vitest run",
|
|
149
|
-
"dev": "source .env && tsc-watch --onSuccess \"rsync -av dist/* ${TO} --checksum\""
|
|
150
|
-
}
|
|
151
|
-
}
|
|
151
|
+
"author": ""
|
|
152
|
+
}
|
package/runtime/iot.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useBus } from "../bus.js";
|
|
2
|
-
import { useIOT } from "../iot.js";
|
|
2
|
+
import { useIOT, useIOTControl } from "../iot.js";
|
|
3
3
|
import { lazy } from "../util/lazy.js";
|
|
4
4
|
import { logInvokeTrace } from "./worker-pool-logging.js";
|
|
5
5
|
import { logIot } from "./debug-bridge-logging.js";
|
|
@@ -7,6 +7,9 @@ import { logEventTrace } from "./event-trace-logging.js";
|
|
|
7
7
|
export const useIOTBridge = lazy(async () => {
|
|
8
8
|
const bus = useBus();
|
|
9
9
|
const iot = await useIOT();
|
|
10
|
+
// The ack goes out on its own socket so it can never queue behind a response
|
|
11
|
+
// body. See `useIOTControl`.
|
|
12
|
+
const control = await useIOTControl();
|
|
10
13
|
const topic = `${iot.prefix}/events`;
|
|
11
14
|
bus.subscribe("function.success", async (evt) => {
|
|
12
15
|
const { workerID, requestID } = evt.properties;
|
|
@@ -27,7 +30,7 @@ export const useIOTBridge = lazy(async () => {
|
|
|
27
30
|
logIot(`reqId=${requestID?.slice(0, 8)} Publishing function.ack to worker ${workerID.slice(0, 8)}`);
|
|
28
31
|
logInvokeTrace("IOT_ACK_START", workerID, `worker=${workerID.slice(0, 8)}`);
|
|
29
32
|
const startTime = Date.now();
|
|
30
|
-
await
|
|
33
|
+
await control.publish(topic + "/" + workerID, "function.ack", evt.properties);
|
|
31
34
|
const elapsed = Date.now() - startTime;
|
|
32
35
|
logIot(`reqId=${requestID?.slice(0, 8)} function.ack published in ${elapsed}ms`);
|
|
33
36
|
logInvokeTrace("IOT_ACK_DONE", workerID, `worker=${workerID.slice(0, 8)}`);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json.bak
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"publishConfig": {
|
|
3
|
-
"directory": "dist",
|
|
4
|
-
"access": "public"
|
|
5
|
-
},
|
|
6
|
-
"sideEffects": false,
|
|
7
|
-
"name": "@intelligems/sst",
|
|
8
|
-
"version": "2.49.6-ig.6",
|
|
9
|
-
"bin": {
|
|
10
|
-
"sst": "cli/sst.js"
|
|
11
|
-
},
|
|
12
|
-
"description": "A CLI to help deploy SST apps.",
|
|
13
|
-
"type": "module",
|
|
14
|
-
"license": "MIT",
|
|
15
|
-
"scripts": {
|
|
16
|
-
"prepare": "",
|
|
17
|
-
"build": "node build.mjs && tsc",
|
|
18
|
-
"test": "vitest run",
|
|
19
|
-
"dev": "source .env && tsc-watch --onSuccess \"rsync -av dist/* ${TO} --checksum\""
|
|
20
|
-
},
|
|
21
|
-
"repository": {
|
|
22
|
-
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/sst/v2.git",
|
|
24
|
-
"directory": "packages/cli"
|
|
25
|
-
},
|
|
26
|
-
"exports": {
|
|
27
|
-
"./constructs/deprecated": "./constructs/deprecated/index.js",
|
|
28
|
-
"./constructs/future": "./constructs/future/index.js",
|
|
29
|
-
"./constructs": "./constructs/index.js",
|
|
30
|
-
"./context": "./context/index.js",
|
|
31
|
-
"./node/future/*": "./node/future/*/index.js",
|
|
32
|
-
"./node/*": "./node/*/index.js",
|
|
33
|
-
".": "./index.js",
|
|
34
|
-
"./*": "./*"
|
|
35
|
-
},
|
|
36
|
-
"homepage": "https://sst.dev",
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"@aws-cdk/aws-lambda-python-alpha": "2.201.0-alpha.0",
|
|
39
|
-
"@aws-cdk/cloud-assembly-schema": "44.5.0",
|
|
40
|
-
"@aws-cdk/cloudformation-diff": "2.182.0",
|
|
41
|
-
"@aws-cdk/cx-api": "2.201.0",
|
|
42
|
-
"@aws-cdk/toolkit-lib": "1.1.1",
|
|
43
|
-
"@aws-crypto/sha256-js": "^5.2.0",
|
|
44
|
-
"@aws-sdk/client-cloudformation": "3.699.0",
|
|
45
|
-
"@aws-sdk/client-ecs": "3.699.0",
|
|
46
|
-
"@aws-sdk/client-eventbridge": "3.699.0",
|
|
47
|
-
"@aws-sdk/client-iam": "3.699.0",
|
|
48
|
-
"@aws-sdk/client-iot": "3.699.0",
|
|
49
|
-
"@aws-sdk/client-iot-data-plane": "3.699.0",
|
|
50
|
-
"@aws-sdk/client-lambda": "3.699.0",
|
|
51
|
-
"@aws-sdk/client-rds-data": "3.699.0",
|
|
52
|
-
"@aws-sdk/client-s3": "3.699.0",
|
|
53
|
-
"@aws-sdk/client-ssm": "3.699.0",
|
|
54
|
-
"@aws-sdk/client-sts": "3.699.0",
|
|
55
|
-
"@aws-sdk/config-resolver": "3.374.0",
|
|
56
|
-
"@aws-sdk/credential-providers": "3.699.0",
|
|
57
|
-
"@aws-sdk/middleware-retry": "3.374.0",
|
|
58
|
-
"@aws-sdk/middleware-signing": "3.451.0",
|
|
59
|
-
"@aws-sdk/signature-v4-crt": "3.451.0",
|
|
60
|
-
"@aws-sdk/smithy-client": "3.374.0",
|
|
61
|
-
"@babel/core": "^7.0.0-0",
|
|
62
|
-
"@babel/generator": "^7.20.5",
|
|
63
|
-
"@babel/plugin-syntax-typescript": "^7.21.4",
|
|
64
|
-
"@smithy/signature-v4": "2.0.16",
|
|
65
|
-
"@trpc/server": "9.18.0",
|
|
66
|
-
"adm-zip": "0.5.14",
|
|
67
|
-
"aws-cdk-lib": "2.201.0",
|
|
68
|
-
"aws-iot-device-sdk": "^2.2.13",
|
|
69
|
-
"aws-sdk": "^2.1501.0",
|
|
70
|
-
"builtin-modules": "3.2.0",
|
|
71
|
-
"cdk-assets": "3.3.1",
|
|
72
|
-
"chalk": "^5.2.0",
|
|
73
|
-
"chokidar": "^3.5.3",
|
|
74
|
-
"ci-info": "^3.7.0",
|
|
75
|
-
"colorette": "^2.0.19",
|
|
76
|
-
"conf": "^10.2.0",
|
|
77
|
-
"constructs": "10.3.0",
|
|
78
|
-
"cross-spawn": "^7.0.3",
|
|
79
|
-
"dendriform-immer-patch-optimiser": "^2.1.0",
|
|
80
|
-
"dotenv": "^16.0.3",
|
|
81
|
-
"esbuild": "0.18.13",
|
|
82
|
-
"express": "^4.18.2",
|
|
83
|
-
"fast-jwt": "^5.0.5",
|
|
84
|
-
"get-port": "^6.1.2",
|
|
85
|
-
"glob": "^10.0.0",
|
|
86
|
-
"graphql": "*",
|
|
87
|
-
"graphql-yoga": "^3.9.0",
|
|
88
|
-
"immer": "9",
|
|
89
|
-
"ink": "^4.0.0",
|
|
90
|
-
"ink-spinner": "^5.0.0",
|
|
91
|
-
"kysely": "^0.25.0",
|
|
92
|
-
"kysely-codegen": "^0.10.1",
|
|
93
|
-
"kysely-data-api": "^0.2.1",
|
|
94
|
-
"minimatch": "^6.1.6",
|
|
95
|
-
"openid-client": "^5.1.8",
|
|
96
|
-
"ora": "^6.1.2",
|
|
97
|
-
"react": "^18.0.0",
|
|
98
|
-
"remeda": "^1.3.0",
|
|
99
|
-
"tree-kill": "^1.2.2",
|
|
100
|
-
"undici": "^5.12.0",
|
|
101
|
-
"uuid": "^9.0.0",
|
|
102
|
-
"ws": "^8.11.0",
|
|
103
|
-
"yargs": "^17.6.2",
|
|
104
|
-
"zod": "^3.21.4"
|
|
105
|
-
},
|
|
106
|
-
"devDependencies": {
|
|
107
|
-
"dotenv-cli": "^8.0.0",
|
|
108
|
-
"@aws-sdk/client-api-gateway": "3.699.0",
|
|
109
|
-
"@aws-sdk/client-cloudfront": "3.699.0",
|
|
110
|
-
"@aws-sdk/client-codebuild": "3.699.0",
|
|
111
|
-
"@aws-sdk/client-sqs": "3.699.0",
|
|
112
|
-
"@aws-sdk/types": "3.451.0",
|
|
113
|
-
"@graphql-tools/merge": "^8.3.16",
|
|
114
|
-
"@sls-next/lambda-at-edge": "^3.7.0",
|
|
115
|
-
"@smithy/types": "4.1.0",
|
|
116
|
-
"@tsconfig/node16": "^1.0.3",
|
|
117
|
-
"@tsconfig/node18": "^18.2.2",
|
|
118
|
-
"@types/adm-zip": "^0.5.0",
|
|
119
|
-
"@types/async": "^3.2.24",
|
|
120
|
-
"@types/aws-iot-device-sdk": "^2.2.8",
|
|
121
|
-
"@types/aws-lambda": "^8.10.128",
|
|
122
|
-
"@types/babel__core": "^7.1.20",
|
|
123
|
-
"@types/babel__generator": "^7.6.4",
|
|
124
|
-
"@types/cross-spawn": "^6.0.2",
|
|
125
|
-
"@types/express": "^4.17.14",
|
|
126
|
-
"@types/node": "22.13.14",
|
|
127
|
-
"@types/react": "^18.0.28",
|
|
128
|
-
"@types/uuid": "^8.3.4",
|
|
129
|
-
"@types/ws": "8.5.3",
|
|
130
|
-
"@types/yargs": "^17.0.13",
|
|
131
|
-
"archiver": "^5.3.1",
|
|
132
|
-
"astro-sst": "2.45.1",
|
|
133
|
-
"async": "^3.2.4",
|
|
134
|
-
"tsx": "^3.12.1",
|
|
135
|
-
"typescript": "5.2.2",
|
|
136
|
-
"vitest": "^0.33.0",
|
|
137
|
-
"tsc-watch": "^6.2.1"
|
|
138
|
-
},
|
|
139
|
-
"peerDependencies": {
|
|
140
|
-
"@sls-next/lambda-at-edge": "^3.7.0"
|
|
141
|
-
},
|
|
142
|
-
"peerDependenciesMeta": {
|
|
143
|
-
"@sls-next/lambda-at-edge": {
|
|
144
|
-
"optional": true
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
"bugs": {
|
|
148
|
-
"url": "https://github.com/sst/v2/issues"
|
|
149
|
-
},
|
|
150
|
-
"main": "index.js",
|
|
151
|
-
"directories": {
|
|
152
|
-
"test": "test"
|
|
153
|
-
},
|
|
154
|
-
"keywords": [],
|
|
155
|
-
"author": ""
|
|
156
|
-
}
|