@uns-kit/core 2.0.72 → 2.0.73
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/MIGRATIONS.md +83 -0
- package/README.md +4 -0
- package/package.json +3 -2
package/MIGRATIONS.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# @uns-kit/core migrations
|
|
2
|
+
|
|
3
|
+
Use this document when upgrading an existing application. Before changing
|
|
4
|
+
`@uns-kit/*` versions, record the installed source version and the intended
|
|
5
|
+
target version. Apply every migration whose version boundary is crossed; do not
|
|
6
|
+
apply migrations that are outside that range.
|
|
7
|
+
|
|
8
|
+
Agents must inspect the application's existing ownership and shutdown flow
|
|
9
|
+
before editing it. The examples below describe the intended behavior, not a
|
|
10
|
+
mechanical search-and-replace operation.
|
|
11
|
+
|
|
12
|
+
## 2.0.71 - MQTT publishing and shutdown lifecycle
|
|
13
|
+
|
|
14
|
+
Apply this migration when upgrading from `@uns-kit/core` `<2.0.71` to
|
|
15
|
+
`>=2.0.71`. No shutdown rewrite is required solely for an upgrade from
|
|
16
|
+
`2.0.71` or newer.
|
|
17
|
+
|
|
18
|
+
### Process-owned MQTT proxies
|
|
19
|
+
|
|
20
|
+
An MQTT proxy created by `UnsProxyProcess.createUnsMqttProxy()` is owned by that
|
|
21
|
+
process. Shut it down through `UnsProxyProcess.shutdown()` only. Do not flush or
|
|
22
|
+
stop the same proxy separately during normal process shutdown.
|
|
23
|
+
|
|
24
|
+
Before:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
await mqttOutput.flush();
|
|
28
|
+
await mqttOutput.stop();
|
|
29
|
+
await unsProcess.shutdown();
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
After:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
await unsProcess.shutdown();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`UnsProxyProcess.shutdown()` closes all process-owned proxies, waits for their
|
|
39
|
+
accepted publishes to drain, and attempts every cleanup even if one fails. It
|
|
40
|
+
rejects with an `AggregateError` when any cleanup fails, so callers must report
|
|
41
|
+
or otherwise handle that rejection.
|
|
42
|
+
|
|
43
|
+
Long-running applications should initiate this process-level shutdown from both
|
|
44
|
+
`SIGINT` and `SIGTERM`. Keep startup-failure cleanup on the same process-level
|
|
45
|
+
path as well.
|
|
46
|
+
|
|
47
|
+
### Standalone MQTT proxies
|
|
48
|
+
|
|
49
|
+
For an independently constructed `UnsMqttProxy`, call:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
await proxy.stop();
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`stop()` closes publish admission immediately and drains accepted work by
|
|
56
|
+
default. Repeated calls share the same result. Use
|
|
57
|
+
`await proxy.stop({ drain: false })` only when intentionally dropping queued
|
|
58
|
+
messages is acceptable.
|
|
59
|
+
|
|
60
|
+
### Publish completion and errors
|
|
61
|
+
|
|
62
|
+
- `publishMessage()` and `publishMqttMessage()` resolve when the bounded worker
|
|
63
|
+
queue accepts a message, not when the broker confirms the publish.
|
|
64
|
+
- Call `await proxy.flush()` when the application needs all previously accepted
|
|
65
|
+
messages to complete while the proxy remains running.
|
|
66
|
+
- A full bounded queue rejects the publish instead of creating an unbounded
|
|
67
|
+
main-thread backlog. Decide whether the caller should retry, slow down, or
|
|
68
|
+
fail.
|
|
69
|
+
- Asynchronous broker publish failures are emitted on the proxy `error` event.
|
|
70
|
+
Keep an error listener or another explicit error-handling path.
|
|
71
|
+
|
|
72
|
+
### Upgrade check
|
|
73
|
+
|
|
74
|
+
For every affected application, verify all of the following:
|
|
75
|
+
|
|
76
|
+
- Identify whether each proxy is process-owned or standalone.
|
|
77
|
+
- Remove duplicate process-owned proxy `flush()` or `stop()` calls from the
|
|
78
|
+
shutdown path.
|
|
79
|
+
- Handle rejection from `UnsProxyProcess.shutdown()` and standalone `stop()`.
|
|
80
|
+
- Confirm both `SIGINT` and `SIGTERM` use the intended shutdown owner.
|
|
81
|
+
- Confirm producers handle queue-full rejection at their required reliability
|
|
82
|
+
level.
|
|
83
|
+
- Test that shutdown waits for accepted publishes and does not accept new work.
|
package/README.md
CHANGED
|
@@ -268,6 +268,10 @@ If the bounded queue is full, `publishMessage()` / `publishMqttMessage()` reject
|
|
|
268
268
|
|
|
269
269
|
Use `await proxy.flush()` or `await proxy.drainPublishes()` before assuming all accepted messages have reached the broker. `await proxy.stop()` closes publish admission immediately and drains by default with a timeout; repeated `stop()` calls share the same result. Use `await proxy.stop({ drain: false })` only when dropping queued messages is acceptable. When a proxy belongs to `UnsProxyProcess`, call `await process.shutdown()` instead of stopping the proxy separately. Process shutdown attempts every cleanup and rejects with an `AggregateError` if any drain or stop fails.
|
|
270
270
|
|
|
271
|
+
When upgrading an existing application, read [`MIGRATIONS.md`](./MIGRATIONS.md)
|
|
272
|
+
and apply only the migrations whose version boundaries are crossed. The
|
|
273
|
+
`2.0.71` migration documents the MQTT publish and shutdown ownership changes.
|
|
274
|
+
|
|
271
275
|
## Sync UNS schema from the controller
|
|
272
276
|
|
|
273
277
|
`sync-uns-schema` fetches the canonical UNS dictionary and measurements from the controller REST API and refreshes local JSON files and generated TypeScript artifacts.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uns-kit/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.73",
|
|
4
4
|
"description": "Core utilities and runtime building blocks for UNS-based realtime transformers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"realtime"
|
|
20
20
|
],
|
|
21
21
|
"files": [
|
|
22
|
-
"dist"
|
|
22
|
+
"dist",
|
|
23
|
+
"MIGRATIONS.md"
|
|
23
24
|
],
|
|
24
25
|
"exports": {
|
|
25
26
|
"./*": "./dist/*",
|