appmesh 3.1.19 → 3.1.21
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 +31 -1
- package/dist/appmesh.esm.js +1 -1
- package/package.json +2 -2
- package/src/appmesh.js +210 -19
- package/src/appmesh_tcp.js +226 -120
package/README.md
CHANGED
|
@@ -27,6 +27,36 @@ const client = new AppMeshClient();
|
|
|
27
27
|
client.setBearerToken(process.env.APPMESH_BEARER_TOKEN);
|
|
28
28
|
```
|
|
29
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
|
+
|
|
30
60
|
#### Browser (VUE Example)
|
|
31
61
|
|
|
32
62
|
```js
|
|
@@ -415,4 +445,4 @@ await server.sendTaskResult(JSON.stringify(result));
|
|
|
415
445
|
|
|
416
446
|
## Behavioral contract
|
|
417
447
|
|
|
418
|
-
Cross-SDK client guarantees (event demuxer ordering, `__disconnected__` event, buffering caps, timeout/cleanup policy, and bearer authentication) are defined in [SDKContract.md](https://github.com/laoshanxi/app-mesh/blob/main/docs/source/SDKContract.md).
|
|
448
|
+
Cross-SDK client guarantees (event demuxer ordering, `__disconnected__` event, buffering caps, timeout/cleanup policy, and bearer authentication) are defined in [SDKContract.md](https://github.com/laoshanxi/app-mesh/blob/main/docs/source/interfaces/SDKContract.md).
|