@ariestools/aries-dapp-core 0.1.14 → 0.1.16
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/dist/bin/dappServer.mjs +48 -260
- package/dist/node/DappActor.d.ts +19 -23
- package/dist/node/DappActor.d.ts.map +1 -1
- package/dist/node/actor/types.d.ts +11 -27
- package/dist/node/actor/types.d.ts.map +1 -1
- package/dist/node/boot/bootDappActors.d.ts +4 -3
- package/dist/node/boot/bootDappActors.d.ts.map +1 -1
- package/dist/node/index.d.ts +1 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.mjs +45 -264
- package/dist/node/index.mjs.map +4 -4
- package/package.json +12 -8
- package/dist/node/actor/AbstractActor.d.ts +0 -53
- package/dist/node/actor/AbstractActor.d.ts.map +0 -1
package/dist/bin/dappServer.mjs
CHANGED
|
@@ -4,166 +4,10 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { DAPP_BACKINGS, DAPP_BUCKETS, isDappBackingKind, resolveBacking, startDappServer } from "@ariestools/aries-dapp-serve";
|
|
7
|
-
import {
|
|
7
|
+
import { ConsoleLogger, assertEx, creatable } from "@ariestools/sdk";
|
|
8
|
+
import { PeriodicActor, bootActors } from "@ariestools/actor";
|
|
8
9
|
import { DeleteObjectCommand, GetObjectCommand, HeadObjectCommand, ListObjectsV2Command, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
9
10
|
import { pathToFileURL } from "node:url";
|
|
10
|
-
//#region src/actor/AbstractActor.ts
|
|
11
|
-
function createDeferred$1() {
|
|
12
|
-
let resolve;
|
|
13
|
-
let reject;
|
|
14
|
-
const promise = new Promise((res, rej) => {
|
|
15
|
-
resolve = res;
|
|
16
|
-
reject = rej;
|
|
17
|
-
});
|
|
18
|
-
promise.catch(() => {});
|
|
19
|
-
return {
|
|
20
|
-
promise,
|
|
21
|
-
reject,
|
|
22
|
-
resolve
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Lean, dapp-owned fork of the xl1 `ActorV3` pattern: the create/start/stop
|
|
27
|
-
* lifecycle from `AbstractCreatable`, plus non-overlapping interval timers and
|
|
28
|
-
* a readiness contract. It deliberately swaps the chain's
|
|
29
|
-
* `ProviderFactoryLocator`/`LocatorConfig` machinery for the small
|
|
30
|
-
* {@link DappProviderLocator} seam, so a dapp actor resolves providers by
|
|
31
|
-
* moniker without dragging the chain protocol config model in.
|
|
32
|
-
*
|
|
33
|
-
* The locator is process-wide: the daemon builds it once and passes the same
|
|
34
|
-
* instance to every actor via `params.locator` (see `bootDappActors`). When
|
|
35
|
-
* this graduates into a shared cli/actor toolkit — and, later, xl1-protocol —
|
|
36
|
-
* this base can re-adopt the real locator.
|
|
37
|
-
*/
|
|
38
|
-
var AbstractActor = class extends AbstractCreatable {
|
|
39
|
-
_intervals = /* @__PURE__ */ new Map();
|
|
40
|
-
_timeouts = /* @__PURE__ */ new Map();
|
|
41
|
-
_abortController = new AbortController();
|
|
42
|
-
_idLogger;
|
|
43
|
-
_inFlight = /* @__PURE__ */ new Map();
|
|
44
|
-
_readyDeferred = createDeferred$1();
|
|
45
|
-
_readyError;
|
|
46
|
-
_readyState = "pending";
|
|
47
|
-
get logger() {
|
|
48
|
-
this._idLogger ??= new IdLogger(assertEx(this.context.logger, () => `Logger is required in context for actor ${this.name}.`), () => this.name);
|
|
49
|
-
return this._idLogger;
|
|
50
|
-
}
|
|
51
|
-
get readyError() {
|
|
52
|
-
return this._readyError;
|
|
53
|
-
}
|
|
54
|
-
get readyState() {
|
|
55
|
-
return this._readyState;
|
|
56
|
-
}
|
|
57
|
-
get context() {
|
|
58
|
-
return this.locator.context;
|
|
59
|
-
}
|
|
60
|
-
get locator() {
|
|
61
|
-
return this.params.locator;
|
|
62
|
-
}
|
|
63
|
-
/** Abort signal cancelled when the actor stops (or is replaced on restart). */
|
|
64
|
-
get signal() {
|
|
65
|
-
return this._abortController.signal;
|
|
66
|
-
}
|
|
67
|
-
static async paramsHandler(params) {
|
|
68
|
-
const inParams = params ?? {};
|
|
69
|
-
const baseParams = await super.paramsHandler({
|
|
70
|
-
...inParams,
|
|
71
|
-
name: inParams.name ?? "UnknownActor"
|
|
72
|
-
});
|
|
73
|
-
const locator = assertEx(inParams.locator, () => `params.locator is required for actor ${String(baseParams.name)}.`);
|
|
74
|
-
return {
|
|
75
|
-
...baseParams,
|
|
76
|
-
locator
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
/** Override to prove the actor can do useful work. Default: no-op. */
|
|
80
|
-
async readyHandler() {}
|
|
81
|
-
/**
|
|
82
|
-
* Register a recurring task. The first invocation fires after `dueTimeMs`
|
|
83
|
-
* (the documented first-run delay); subsequent invocations fire every
|
|
84
|
-
* `periodMs` while the actor is `started`. A run is skipped if the previous
|
|
85
|
-
* one is still in flight, so a slow pass can never stack on top of itself.
|
|
86
|
-
* Must be called from `startHandler` (guards on `starting` status).
|
|
87
|
-
*/
|
|
88
|
-
registerTimer(timerName, callback, dueTimeMs, periodMs) {
|
|
89
|
-
if (this.status !== "starting") {
|
|
90
|
-
this.logger.warn(`Cannot register timer '${timerName}' because actor is not starting.`);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const tick = () => {
|
|
94
|
-
if (this.status !== "started") return;
|
|
95
|
-
if (this._inFlight.has(timerName)) {
|
|
96
|
-
this.logger.warn(`Skipping timer '${this.name}:${timerName}' because the previous run is still in flight.`);
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const run = (async () => {
|
|
100
|
-
const startTime = Date.now();
|
|
101
|
-
try {
|
|
102
|
-
await callback();
|
|
103
|
-
} catch (error) {
|
|
104
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
105
|
-
this.logger.error(`Error in timer '${this.name}:${timerName}': ${err.message}`);
|
|
106
|
-
} finally {
|
|
107
|
-
const duration = Date.now() - startTime;
|
|
108
|
-
if (duration > periodMs) this.logger.warn(`Timer '${this.name}:${timerName}' took ${duration}ms, longer than its ${periodMs}ms period.`);
|
|
109
|
-
}
|
|
110
|
-
})();
|
|
111
|
-
this._inFlight.set(timerName, run.finally(() => {
|
|
112
|
-
this._inFlight.delete(timerName);
|
|
113
|
-
}));
|
|
114
|
-
};
|
|
115
|
-
const timeoutId = setTimeout(() => {
|
|
116
|
-
if (this.status !== "started") return;
|
|
117
|
-
this._intervals.set(timerName, setInterval(tick, periodMs));
|
|
118
|
-
tick();
|
|
119
|
-
}, dueTimeMs);
|
|
120
|
-
this._timeouts.set(timerName, timeoutId);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Run the warm-pass once. The standard boot path invokes this after
|
|
124
|
-
* `start()` so readiness either resolves or rejects.
|
|
125
|
-
*/
|
|
126
|
-
async runReadyHandler() {
|
|
127
|
-
if (this._readyState !== "pending") return;
|
|
128
|
-
try {
|
|
129
|
-
await this.readyHandler();
|
|
130
|
-
this._readyState = "ready";
|
|
131
|
-
this._readyDeferred.resolve();
|
|
132
|
-
} catch (error) {
|
|
133
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
134
|
-
this._readyState = "failed";
|
|
135
|
-
this._readyError = err;
|
|
136
|
-
this._readyDeferred.reject(err);
|
|
137
|
-
throw err;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
async startHandler() {
|
|
141
|
-
if (this._abortController.signal.aborted) this._abortController = new AbortController();
|
|
142
|
-
await super.startHandler();
|
|
143
|
-
}
|
|
144
|
-
async stopHandler() {
|
|
145
|
-
await super.stopHandler();
|
|
146
|
-
this._abortController.abort();
|
|
147
|
-
for (const timeoutRef of this._timeouts.values()) clearTimeout(timeoutRef);
|
|
148
|
-
this._timeouts.clear();
|
|
149
|
-
for (const intervalRef of this._intervals.values()) clearInterval(intervalRef);
|
|
150
|
-
this._intervals.clear();
|
|
151
|
-
const inFlight = [...this._inFlight.values()];
|
|
152
|
-
this._inFlight.clear();
|
|
153
|
-
const timeoutMs = this.params.shutdownTimeoutMs;
|
|
154
|
-
if (timeoutMs === void 0) {
|
|
155
|
-
await Promise.allSettled(inFlight);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
await Promise.race([Promise.allSettled(inFlight), new Promise((resolve) => {
|
|
159
|
-
setTimeout(resolve, timeoutMs);
|
|
160
|
-
})]);
|
|
161
|
-
}
|
|
162
|
-
async whenReady() {
|
|
163
|
-
await this._readyDeferred.promise;
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
//#endregion
|
|
167
11
|
//#region src/providers/capabilities.ts
|
|
168
12
|
/** Thrown when a read-only capability wrapper receives a write. */
|
|
169
13
|
var ReadOnlyStoreError = class extends Error {
|
|
@@ -323,7 +167,7 @@ function failureStatusFields(prior, consecutiveFailures, error, now) {
|
|
|
323
167
|
};
|
|
324
168
|
}
|
|
325
169
|
//#endregion
|
|
326
|
-
//#region \0@oxc-project+runtime@0.
|
|
170
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/decorate.js
|
|
327
171
|
function __decorate(decorators, target, key, desc) {
|
|
328
172
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
329
173
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -333,22 +177,6 @@ function __decorate(decorators, target, key, desc) {
|
|
|
333
177
|
//#endregion
|
|
334
178
|
//#region src/DappActor.ts
|
|
335
179
|
const DEFAULT_REDUCE_INTERVAL_MS = 5e3;
|
|
336
|
-
const DEFAULT_FIRST_RUN_DELAY_MS = 2e3;
|
|
337
|
-
const REDUCE_TIMER = "DappReduce";
|
|
338
|
-
function createDeferred() {
|
|
339
|
-
let resolve;
|
|
340
|
-
let reject;
|
|
341
|
-
const promise = new Promise((res, rej) => {
|
|
342
|
-
resolve = res;
|
|
343
|
-
reject = rej;
|
|
344
|
-
});
|
|
345
|
-
promise.catch(() => {});
|
|
346
|
-
return {
|
|
347
|
-
promise,
|
|
348
|
-
reject,
|
|
349
|
-
resolve
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
180
|
function withDefaultGenerationRoot(result) {
|
|
353
181
|
if (result === void 0) return;
|
|
354
182
|
if (result.generation === void 0 || result.generationRoot !== void 0) return result;
|
|
@@ -357,7 +185,7 @@ function withDefaultGenerationRoot(result) {
|
|
|
357
185
|
generationRoot: HEAD_KEY
|
|
358
186
|
};
|
|
359
187
|
}
|
|
360
|
-
let DappActor = class DappActor extends
|
|
188
|
+
let DappActor = class DappActor extends PeriodicActor {
|
|
361
189
|
static dependencies = [
|
|
362
190
|
DappDataStoreMoniker,
|
|
363
191
|
DappStateStoreMoniker,
|
|
@@ -366,12 +194,13 @@ let DappActor = class DappActor extends AbstractActor {
|
|
|
366
194
|
_data;
|
|
367
195
|
_index;
|
|
368
196
|
_state;
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
197
|
+
/** Dapp actors require a logger in the locator context (see {@link DappContext}). */
|
|
198
|
+
get logger() {
|
|
199
|
+
return assertEx(super.logger, () => `Logger is required in context for actor ${this.name}.`);
|
|
200
|
+
}
|
|
201
|
+
/** Reduce cadence: `reduceIntervalMs` names the interval in dapp configs. */
|
|
202
|
+
get intervalMs() {
|
|
203
|
+
return this.params.reduceIntervalMs ?? DEFAULT_REDUCE_INTERVAL_MS;
|
|
375
204
|
}
|
|
376
205
|
async createHandler() {
|
|
377
206
|
await super.createHandler();
|
|
@@ -380,21 +209,25 @@ let DappActor = class DappActor extends AbstractActor {
|
|
|
380
209
|
this._state = await this.locator.getInstance(DappStateStoreMoniker);
|
|
381
210
|
this._index = await this.locator.getInstance(DappIndexStoreMoniker);
|
|
382
211
|
}
|
|
383
|
-
async readyHandler() {
|
|
384
|
-
await this._firstPass.promise;
|
|
385
|
-
}
|
|
386
212
|
async startHandler() {
|
|
387
213
|
await super.startHandler();
|
|
388
|
-
|
|
389
|
-
const firstRunDelay = this.params.firstRunDelayMs ?? DEFAULT_FIRST_RUN_DELAY_MS;
|
|
390
|
-
this.registerTimer(REDUCE_TIMER, async () => {
|
|
391
|
-
await this.runReducePass();
|
|
392
|
-
}, firstRunDelay, interval);
|
|
393
|
-
this.logger.info(`DappActor started: reducer '${this.params.reducer.name}' every ${interval}ms (first run in ${firstRunDelay}ms)`);
|
|
214
|
+
this.logger.info(`DappActor started: reducer '${this.params.reducer.name}' every ${this.intervalMs}ms (first run in ${this.firstRunDelayMs}ms)`);
|
|
394
215
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
await
|
|
216
|
+
/** Failure side-channel: publish durable failure status (count already incremented). */
|
|
217
|
+
async onPassError(error) {
|
|
218
|
+
await this.safePublishStatus(void 0, error);
|
|
219
|
+
}
|
|
220
|
+
async runPass({ signal }) {
|
|
221
|
+
const result = await this.params.reducer.reduce({
|
|
222
|
+
data: this._data,
|
|
223
|
+
index: this._index,
|
|
224
|
+
logger: this.logger,
|
|
225
|
+
signal,
|
|
226
|
+
state: this._state
|
|
227
|
+
});
|
|
228
|
+
if (signal.aborted) return;
|
|
229
|
+
const progress = withDefaultGenerationRoot(result === void 0 ? void 0 : result);
|
|
230
|
+
await this.safePublishStatus(progress);
|
|
398
231
|
}
|
|
399
232
|
async publishStatusFromProgress(progress, error) {
|
|
400
233
|
if (this.params.publishStatus === false) return;
|
|
@@ -405,40 +238,9 @@ let DappActor = class DappActor extends AbstractActor {
|
|
|
405
238
|
prior = void 0;
|
|
406
239
|
}
|
|
407
240
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
408
|
-
const fields = error === void 0 ? successStatusFields(progress, prior, now) : failureStatusFields(prior, this.
|
|
241
|
+
const fields = error === void 0 ? successStatusFields(progress, prior, now) : failureStatusFields(prior, this.consecutiveFailures, error, now);
|
|
409
242
|
await writeIndexerStatus(this._state, fields);
|
|
410
243
|
}
|
|
411
|
-
async runReducePass() {
|
|
412
|
-
const signal = this.signal;
|
|
413
|
-
try {
|
|
414
|
-
const result = await this.params.reducer.reduce({
|
|
415
|
-
data: this._data,
|
|
416
|
-
index: this._index,
|
|
417
|
-
logger: this.logger,
|
|
418
|
-
signal,
|
|
419
|
-
state: this._state
|
|
420
|
-
});
|
|
421
|
-
if (signal.aborted) return;
|
|
422
|
-
const progress = withDefaultGenerationRoot(result === void 0 ? void 0 : result);
|
|
423
|
-
this._consecutiveFailures = 0;
|
|
424
|
-
await this.safePublishStatus(progress);
|
|
425
|
-
this.settleFirstPass();
|
|
426
|
-
} catch (error) {
|
|
427
|
-
if (signal.aborted) return;
|
|
428
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
429
|
-
this._consecutiveFailures += 1;
|
|
430
|
-
await this.safePublishStatus(void 0, err);
|
|
431
|
-
this.settleFirstPass(err);
|
|
432
|
-
this.logger.error(`Error in reduce pass for '${this.params.reducer.name}': ${err.message}`);
|
|
433
|
-
const max = this.params.maxConsecutiveFailures;
|
|
434
|
-
if (max !== void 0 && this._consecutiveFailures >= max) {
|
|
435
|
-
this.logger.error(`Reducer '${this.params.reducer.name}' failed ${this._consecutiveFailures} consecutive times; stopping actor`);
|
|
436
|
-
setTimeout(() => {
|
|
437
|
-
this.stop();
|
|
438
|
-
}, 0);
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
244
|
async safePublishStatus(progress, error) {
|
|
443
245
|
try {
|
|
444
246
|
await this.publishStatusFromProgress(progress, error);
|
|
@@ -446,48 +248,34 @@ let DappActor = class DappActor extends AbstractActor {
|
|
|
446
248
|
this.logger.error(`Failed to publish indexer status: ${String(statusError)}`);
|
|
447
249
|
}
|
|
448
250
|
}
|
|
449
|
-
settleFirstPass(error) {
|
|
450
|
-
if (this._firstPassSettled) return;
|
|
451
|
-
this._firstPassSettled = true;
|
|
452
|
-
if (error === void 0) this._firstPass.resolve();
|
|
453
|
-
else this._firstPass.reject(error);
|
|
454
|
-
}
|
|
455
251
|
};
|
|
456
252
|
DappActor = __decorate([creatable()], DappActor);
|
|
457
253
|
//#endregion
|
|
458
254
|
//#region src/boot/bootDappActors.ts
|
|
459
255
|
/**
|
|
460
256
|
* Creates and starts one {@link DappActor} per spec, all sharing the single
|
|
461
|
-
* process-wide locator.
|
|
462
|
-
*
|
|
463
|
-
*
|
|
257
|
+
* process-wide locator. A thin wrapper over actor-kit's `bootActors`: on
|
|
258
|
+
* partial failure, actors already started are stopped (with shutdown
|
|
259
|
+
* fallback) before the error is rethrown. Returns them so the caller can
|
|
260
|
+
* stop them on shutdown.
|
|
464
261
|
*/
|
|
465
262
|
async function bootDappActors(locator, specs) {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
if (spec.runReady !== false) await actor.runReadyHandler();
|
|
483
|
-
}
|
|
484
|
-
return actors;
|
|
485
|
-
} catch (error) {
|
|
486
|
-
for (const actor of [...actors].reverse()) try {
|
|
487
|
-
await actor.stop();
|
|
488
|
-
} catch {}
|
|
489
|
-
throw error;
|
|
490
|
-
}
|
|
263
|
+
return await bootActors(specs.map((spec) => {
|
|
264
|
+
const params = {
|
|
265
|
+
locator,
|
|
266
|
+
name: spec.name,
|
|
267
|
+
reducer: spec.reducer,
|
|
268
|
+
...spec.reduceIntervalMs !== void 0 && { reduceIntervalMs: spec.reduceIntervalMs },
|
|
269
|
+
...spec.firstRunDelayMs !== void 0 && { firstRunDelayMs: spec.firstRunDelayMs },
|
|
270
|
+
...spec.maxConsecutiveFailures !== void 0 && { maxConsecutiveFailures: spec.maxConsecutiveFailures },
|
|
271
|
+
...spec.publishStatus !== void 0 && { publishStatus: spec.publishStatus },
|
|
272
|
+
...spec.shutdownTimeoutMs !== void 0 && { shutdownTimeoutMs: spec.shutdownTimeoutMs }
|
|
273
|
+
};
|
|
274
|
+
return {
|
|
275
|
+
create: () => DappActor.create(params),
|
|
276
|
+
...spec.runReady !== void 0 && { runReady: spec.runReady }
|
|
277
|
+
};
|
|
278
|
+
}));
|
|
491
279
|
}
|
|
492
280
|
//#endregion
|
|
493
281
|
//#region src/providers/errors.ts
|
package/dist/node/DappActor.d.ts
CHANGED
|
@@ -1,47 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { PeriodicActorParams, PeriodicPassContext } from '@ariestools/actor';
|
|
2
|
+
import { PeriodicActor } from '@ariestools/actor';
|
|
3
|
+
import type { Logger } from '@ariestools/sdk';
|
|
4
|
+
import type { DappProviderLocator } from './actor/types.ts';
|
|
3
5
|
import type { DappObjectReader, DappObjectWriter } from './providers/capabilities.ts';
|
|
4
6
|
import type { DappReducer } from './reducer/DappReducer.ts';
|
|
5
|
-
export interface DappActorParams extends
|
|
6
|
-
/** Delay before the first reduce pass. Defaults to 2000ms. */
|
|
7
|
-
firstRunDelayMs?: number;
|
|
8
|
-
/**
|
|
9
|
-
* When set, after this many consecutive reduce failures the actor stops so a
|
|
10
|
-
* supervisor can restart the process.
|
|
11
|
-
*/
|
|
12
|
-
maxConsecutiveFailures?: number;
|
|
7
|
+
export interface DappActorParams extends PeriodicActorParams<DappProviderLocator> {
|
|
13
8
|
/**
|
|
14
9
|
* When true (default), publish durable indexer status to the state store
|
|
15
10
|
* after each reduce pass (success or failure).
|
|
16
11
|
*/
|
|
17
12
|
publishStatus?: boolean;
|
|
13
|
+
/** Period between reduce passes. Defaults to 5000ms. */
|
|
18
14
|
reduceIntervalMs?: number;
|
|
19
15
|
reducer: DappReducer;
|
|
20
16
|
}
|
|
21
17
|
/**
|
|
22
18
|
* The stock dapp actor: resolves the three bucket stores from the shared
|
|
23
19
|
* locator, then drives its reducer on an interval to keep `state` and `index`
|
|
24
|
-
* derived from authoritative input.
|
|
25
|
-
*
|
|
26
|
-
* the
|
|
20
|
+
* derived from authoritative input. The loop policies (first-pass-gated
|
|
21
|
+
* readiness, non-overlap, consecutive-failure self-stop) come from
|
|
22
|
+
* `PeriodicActor`; this class contributes the reduce pass and durable status
|
|
23
|
+
* publication. Multiple actors (each with its own reducer) can share one
|
|
24
|
+
* locator; this is the default single-reducer instance the local daemon boots.
|
|
27
25
|
*/
|
|
28
|
-
export declare class DappActor extends
|
|
26
|
+
export declare class DappActor extends PeriodicActor<DappActorParams> {
|
|
29
27
|
static readonly dependencies: readonly ["DappDataStore", "DappStateStore", "DappIndexStore"];
|
|
30
28
|
protected _data: DappObjectReader;
|
|
31
29
|
protected _index: DappObjectWriter;
|
|
32
30
|
protected _state: DappObjectWriter;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
get consecutiveFailures(): number;
|
|
31
|
+
/** Dapp actors require a logger in the locator context (see {@link DappContext}). */
|
|
32
|
+
get logger(): Logger;
|
|
33
|
+
/** Reduce cadence: `reduceIntervalMs` names the interval in dapp configs. */
|
|
34
|
+
protected get intervalMs(): number;
|
|
38
35
|
createHandler(): Promise<void>;
|
|
39
|
-
readyHandler(): Promise<void>;
|
|
40
36
|
startHandler(): Promise<void>;
|
|
41
|
-
|
|
37
|
+
/** Failure side-channel: publish durable failure status (count already incremented). */
|
|
38
|
+
protected onPassError(error: Error): Promise<void>;
|
|
39
|
+
protected runPass({ signal }: PeriodicPassContext): Promise<void>;
|
|
42
40
|
private publishStatusFromProgress;
|
|
43
|
-
private runReducePass;
|
|
44
41
|
private safePublishStatus;
|
|
45
|
-
private settleFirstPass;
|
|
46
42
|
}
|
|
47
43
|
//# sourceMappingURL=DappActor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DappActor.d.ts","sourceRoot":"","sources":["../../src/DappActor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DappActor.d.ts","sourceRoot":"","sources":["../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iBAAiB;CAUhC"}
|
|
@@ -1,37 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ActorContext, InstanceLocator, OwnedLocator, RegistrableLocator } from '@ariestools/actor-model';
|
|
2
|
+
import type { Logger } from '@ariestools/sdk';
|
|
2
3
|
/** Identifier a provider is registered and resolved under in the locator. */
|
|
3
4
|
export type DappMoniker = string;
|
|
4
|
-
export type ReadyState = 'pending' | 'ready' | 'failed';
|
|
5
5
|
/**
|
|
6
|
-
* The shared context carried by the process-wide locator.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* The shared context carried by the process-wide locator. A `logger` is
|
|
7
|
+
* required for dapp actors; telemetry providers and a status reporter are
|
|
8
|
+
* available via the inherited {@link ActorContext} fields when wired.
|
|
9
9
|
*/
|
|
10
|
-
export interface DappContext {
|
|
10
|
+
export interface DappContext extends ActorContext {
|
|
11
11
|
logger: Logger;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* shares the same instance across every actor (see `bootDappActors`).
|
|
14
|
+
* The dapp locator contract: the actor-kit locator seam carrying the dapp
|
|
15
|
+
* context, with registration, ownership, and a `has` probe. The daemon builds
|
|
16
|
+
* one and shares the same instance across every actor (see `bootDappActors`).
|
|
18
17
|
*/
|
|
19
|
-
export
|
|
20
|
-
readonly context: DappContext;
|
|
21
|
-
/** Release owned resources (e.g. an S3 client constructed by the locator). */
|
|
22
|
-
destroy(): void;
|
|
23
|
-
getInstance<T>(moniker: DappMoniker): Promise<T>;
|
|
18
|
+
export type DappProviderLocator = InstanceLocator<DappContext> & OwnedLocator & RegistrableLocator & {
|
|
24
19
|
has(moniker: DappMoniker): boolean;
|
|
25
|
-
|
|
26
|
-
tryGetInstance<T>(moniker: DappMoniker): Promise<T | undefined>;
|
|
27
|
-
}
|
|
28
|
-
/** Base params every dapp actor takes: the shared, process-wide locator. */
|
|
29
|
-
export interface ActorParams extends CreatableParams {
|
|
30
|
-
locator: DappProviderLocator;
|
|
31
|
-
/**
|
|
32
|
-
* Max time to wait for in-flight timer work on stop after aborting the
|
|
33
|
-
* signal. When omitted, stop waits until in-flight work settles.
|
|
34
|
-
*/
|
|
35
|
-
shutdownTimeoutMs?: number;
|
|
36
|
-
}
|
|
20
|
+
};
|
|
37
21
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/actor/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/actor/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,kBAAkB,EACnB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE7C,6EAA6E;AAC7E,MAAM,MAAM,WAAW,GAAG,MAAM,CAAA;AAEhC;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,eAAe,CAAC,WAAW,CAAC,GAAG,YAAY,GAAG,kBAAkB,GAAG;IACnG,GAAG,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAA;CACnC,CAAA"}
|
|
@@ -17,9 +17,10 @@ export interface DappActorSpec {
|
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Creates and starts one {@link DappActor} per spec, all sharing the single
|
|
20
|
-
* process-wide locator.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* process-wide locator. A thin wrapper over actor-kit's `bootActors`: on
|
|
21
|
+
* partial failure, actors already started are stopped (with shutdown
|
|
22
|
+
* fallback) before the error is rethrown. Returns them so the caller can
|
|
23
|
+
* stop them on shutdown.
|
|
23
24
|
*/
|
|
24
25
|
export declare function bootDappActors(locator: DappProviderLocator, specs: readonly DappActorSpec[]): Promise<DappActor[]>;
|
|
25
26
|
//# sourceMappingURL=bootDappActors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootDappActors.d.ts","sourceRoot":"","sources":["../../../src/boot/bootDappActors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bootDappActors.d.ts","sourceRoot":"","sources":["../../../src/boot/bootDappActors.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAE5D,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,OAAO,EAAE,WAAW,CAAA;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,mBAAmB,EAC5B,KAAK,EAAE,SAAS,aAAa,EAAE,GAC9B,OAAO,CAAC,SAAS,EAAE,CAAC,CAkBtB"}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type { ActorParams, DappContext, DappMoniker, DappProviderLocator, ReadyState, } from './actor/types.ts';
|
|
1
|
+
export type { DappContext, DappMoniker, DappProviderLocator, } from './actor/types.ts';
|
|
3
2
|
export type { DappActorSpec } from './boot/bootDappActors.ts';
|
|
4
3
|
export { bootDappActors } from './boot/bootDappActors.ts';
|
|
5
4
|
export type { DappActorParams } from './DappActor.ts';
|
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EAAE,WAAW,EAAE,mBAAmB,GAC9C,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,YAAY,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAA;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,8BAA8B,EAC9B,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,GAChB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EACL,OAAO,EAAE,sBAAsB,EAAE,WAAW,GAC7C,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAA;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAC1E,OAAO,EACL,oBAAoB,EAAE,qBAAqB,EAAE,qBAAqB,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