appmesh 3.1.18 → 3.1.20
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/README.md +33 -5
- package/dist/appmesh.esm.js +1 -1
- package/package.json +2 -2
- package/src/appmesh.js +192 -8
- package/src/appmesh_tcp.js +162 -40
- package/src/worker.js +5 -5
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# App Mesh JavaScript SDK
|
|
2
2
|
|
|
3
|
-
> **Naming**: public methods use camelCase (`listApps`, `runAppSync`).
|
|
4
|
-
> deprecated snake_case aliases (`list_apps`, ...) were removed in 3.1.7 —
|
|
5
|
-
> migrate callers to the camelCase names.
|
|
3
|
+
> **Naming**: public methods use camelCase (`listApps`, `runAppSync`).
|
|
6
4
|
|
|
7
5
|
## Client SDK
|
|
8
6
|
|
|
@@ -29,6 +27,36 @@ const client = new AppMeshClient();
|
|
|
29
27
|
client.setBearerToken(process.env.APPMESH_BEARER_TOKEN);
|
|
30
28
|
```
|
|
31
29
|
|
|
30
|
+
#### Run an app synchronously
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
// Resolves to the exit code (null when the daemon sent none); the stdout handler
|
|
34
|
+
// receives the complete output in one call.
|
|
35
|
+
const exitCode = await client.runAppSync({ command: "cat big.log", shell: true }, (output) => process.stdout.write(output));
|
|
36
|
+
// Optional 5th parameter: reject instead of returning when the output grows past a byte ceiling.
|
|
37
|
+
await client.runAppSync(app, (output) => process.stdout.write(output), 30, 60, 10 * 1024 * 1024);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
One `runAppSync` reply carries at most 5 MiB of output. When the output fills a page,
|
|
41
|
+
the SDK pages the rest from the daemon (in raw bytes, decoded once in the charset of the
|
|
42
|
+
first reply) and only then calls the stdout handler, so the complete output is always
|
|
43
|
+
delivered. The same applies to `AppMeshClientTCP`. When the output grows past
|
|
44
|
+
`maxOutputBytes` the call rejects with `AppMeshRequestError` (the message names the run
|
|
45
|
+
instance that keeps the remaining output readable for 600 seconds) instead of returning a
|
|
46
|
+
partial result; the instance is left in place for the daemon to clean up.
|
|
47
|
+
|
|
48
|
+
#### Forwarding and streaming in a cluster
|
|
49
|
+
|
|
50
|
+
`client.forwardingHost` (the `X-Target-Host` header) applies to every call, the streaming
|
|
51
|
+
ones included (`runTaskStream`, `followOutput`, `streamRun`): the task runs on the target
|
|
52
|
+
node and its stream is served from there, and a target the gateway cannot reach rejects
|
|
53
|
+
the call with 502 like any other forwarded request. `AppMeshClientTCP` streams over a
|
|
54
|
+
direct HTTPS side channel: a forwarded stream on it dials the agent REST listener on the
|
|
55
|
+
same host (`agentPort`, default 6060), because the engine listener itself answers a
|
|
56
|
+
forwarded stream with 400. An `AppMeshClient` whose base URL points at the engine listener
|
|
57
|
+
(default port 6063) therefore cannot forward a stream: the call rejects with a 400 whose
|
|
58
|
+
message says so; use the agent REST listener (default port 6060) as the base URL.
|
|
59
|
+
|
|
32
60
|
#### Browser (VUE Example)
|
|
33
61
|
|
|
34
62
|
```js
|
|
@@ -153,7 +181,7 @@ const sslConfig = {
|
|
|
153
181
|
|
|
154
182
|
// Auto-cleanup with context manager
|
|
155
183
|
await withServer(
|
|
156
|
-
() => new AppMeshWorkerTCP(sslConfig, ["127.0.0.1",
|
|
184
|
+
() => new AppMeshWorkerTCP(sslConfig, ["127.0.0.1", 6062]),
|
|
157
185
|
async (server) => {
|
|
158
186
|
const payload = await server.fetchTask();
|
|
159
187
|
const result = processPayload(payload);
|
|
@@ -251,7 +279,7 @@ new AppMeshWorkerTCP(sslConfig, tcpAddress, options);
|
|
|
251
279
|
**Parameters:**
|
|
252
280
|
|
|
253
281
|
- `sslConfig` (object, optional) - SSL configuration (same as AppMeshWorker)
|
|
254
|
-
- `tcpAddress` (array or object, optional) - `[host, port]` (legacy) or `{host, port}`. Default: `['127.0.0.1',
|
|
282
|
+
- `tcpAddress` (array or object, optional) - `[host, port]` (legacy) or `{host, port}`. Default: `['127.0.0.1', 6062]`. The `{host, port}` object form is also accepted as the first argument: `new AppMeshWorkerTCP({host, port}, sslConfig)`
|
|
255
283
|
- `options` (object, optional) - Same as AppMeshWorker
|
|
256
284
|
|
|
257
285
|
##### Methods
|