@zudojs/adapters 1.0.0 → 1.0.1
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.
|
@@ -130,6 +130,17 @@ export declare class AdapterRegistry {
|
|
|
130
130
|
* @throws {AggregateError} After attempting all adapters, if any failed.
|
|
131
131
|
*/
|
|
132
132
|
disposeAll(): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Stops, then disposes, one adapter.
|
|
135
|
+
*
|
|
136
|
+
* `dispose()` runs even when `stop()` throws: the adapter has already
|
|
137
|
+
* left the registry by the time this is called, so skipping disposal
|
|
138
|
+
* would orphan its connections and timers with nothing left holding a
|
|
139
|
+
* reference to release them. A `stop()` failure is still reported — on
|
|
140
|
+
* its own when disposal succeeds, alongside the disposal error when
|
|
141
|
+
* both fail.
|
|
142
|
+
*/
|
|
143
|
+
private teardown;
|
|
133
144
|
/**
|
|
134
145
|
* Runs an operation against every adapter, collecting failures rather than
|
|
135
146
|
* stopping at the first one — a half-applied lifecycle transition leaves
|
|
@@ -85,8 +85,7 @@ export class AdapterRegistry {
|
|
|
85
85
|
return false;
|
|
86
86
|
}
|
|
87
87
|
this.adapters.delete(key);
|
|
88
|
-
await
|
|
89
|
-
await adapter.dispose?.();
|
|
88
|
+
await this.teardown(adapter);
|
|
90
89
|
return true;
|
|
91
90
|
}
|
|
92
91
|
/**
|
|
@@ -187,8 +186,7 @@ export class AdapterRegistry {
|
|
|
187
186
|
const failures = [];
|
|
188
187
|
for (const adapter of adapters) {
|
|
189
188
|
try {
|
|
190
|
-
await
|
|
191
|
-
await adapter.dispose?.();
|
|
189
|
+
await this.teardown(adapter);
|
|
192
190
|
}
|
|
193
191
|
catch (error) {
|
|
194
192
|
failures.push(error);
|
|
@@ -198,6 +196,38 @@ export class AdapterRegistry {
|
|
|
198
196
|
throw new AggregateError(failures, "One or more adapters failed to dispose.");
|
|
199
197
|
}
|
|
200
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Stops, then disposes, one adapter.
|
|
201
|
+
*
|
|
202
|
+
* `dispose()` runs even when `stop()` throws: the adapter has already
|
|
203
|
+
* left the registry by the time this is called, so skipping disposal
|
|
204
|
+
* would orphan its connections and timers with nothing left holding a
|
|
205
|
+
* reference to release them. A `stop()` failure is still reported — on
|
|
206
|
+
* its own when disposal succeeds, alongside the disposal error when
|
|
207
|
+
* both fail.
|
|
208
|
+
*/
|
|
209
|
+
async teardown(adapter) {
|
|
210
|
+
let stopError;
|
|
211
|
+
let stopFailed = false;
|
|
212
|
+
try {
|
|
213
|
+
await adapter.stop?.();
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
stopFailed = true;
|
|
217
|
+
stopError = error;
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
await adapter.dispose?.();
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
if (stopFailed) {
|
|
224
|
+
throw new AggregateError([stopError, error], `Adapter "${adapter.name}" failed to stop and to dispose.`);
|
|
225
|
+
}
|
|
226
|
+
throw error;
|
|
227
|
+
}
|
|
228
|
+
if (stopFailed)
|
|
229
|
+
throw stopError;
|
|
230
|
+
}
|
|
201
231
|
/**
|
|
202
232
|
* Runs an operation against every adapter, collecting failures rather than
|
|
203
233
|
* stopping at the first one — a half-applied lifecycle transition leaves
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zudojs/adapters",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Boundary layer between Zudojs and external platforms — adapter contracts, registry, capabilities, and transport abstractions.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Oluwayemi Oyinlola",
|
|
8
|
+
"url": "https://github.com/oyinlola-tech"
|
|
9
|
+
},
|
|
6
10
|
"type": "module",
|
|
7
11
|
"main": "./dist/index.js",
|
|
8
12
|
"module": "./dist/index.js",
|
|
@@ -23,10 +27,10 @@
|
|
|
23
27
|
"node": ">=24.0.0"
|
|
24
28
|
},
|
|
25
29
|
"dependencies": {
|
|
26
|
-
"@zudojs/errors": "1.0.
|
|
27
|
-
"@zudojs/constants": "1.0.
|
|
30
|
+
"@zudojs/errors": "1.0.1",
|
|
31
|
+
"@zudojs/constants": "1.0.1",
|
|
28
32
|
"@zudojs/types": "1.0.0",
|
|
29
|
-
"@zudojs/lifecycle": "1.
|
|
33
|
+
"@zudojs/lifecycle": "1.1.0"
|
|
30
34
|
},
|
|
31
35
|
"devDependencies": {
|
|
32
36
|
"typescript": "7.0.2",
|