@dxos/echo-pipeline 0.1.56-main.bf228a7 → 0.1.56-main.c277f68
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/lib/browser/{chunk-7RPTJNLX.mjs → chunk-GDF4DQU2.mjs} +311 -279
- package/dist/lib/browser/chunk-GDF4DQU2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +14 -18
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +318 -286
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +331 -303
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/db-host/data-service-host.d.ts.map +1 -1
- package/dist/types/src/db-host/snapshot-manager.d.ts.map +1 -1
- package/dist/types/src/pipeline/pipeline-stress.test.d.ts +2 -0
- package/dist/types/src/pipeline/pipeline-stress.test.d.ts.map +1 -0
- package/dist/types/src/pipeline/pipeline.d.ts +4 -3
- package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
- package/dist/types/src/space/control-pipeline.d.ts +4 -0
- package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/data-pipeline.d.ts +2 -0
- package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/dist/types/src/space/space-protocol.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +2 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/dist/types/src/testing/database-test-rig.d.ts +4 -1
- package/dist/types/src/testing/database-test-rig.d.ts.map +1 -1
- package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
- package/package.json +32 -31
- package/src/db-host/data-service-host.ts +9 -2
- package/src/db-host/snapshot-manager.ts +0 -2
- package/src/metadata/metadata-store.ts +1 -1
- package/src/pipeline/pipeline-stress.test.ts +226 -0
- package/src/pipeline/pipeline.test.ts +30 -206
- package/src/pipeline/pipeline.ts +49 -22
- package/src/space/control-pipeline.ts +47 -22
- package/src/space/data-pipeline.ts +20 -10
- package/src/space/space-manager.ts +1 -0
- package/src/space/space-protocol.ts +3 -1
- package/src/space/space.test.ts +10 -9
- package/src/space/space.ts +6 -1
- package/src/testing/database-test-rig.ts +27 -2
- package/src/testing/test-agent-builder.ts +2 -1
- package/src/tests/database-unit.test.ts +39 -0
- package/dist/lib/browser/chunk-7RPTJNLX.mjs.map +0 -7
|
@@ -39,6 +39,7 @@ import { Context } from "@dxos/context";
|
|
|
39
39
|
import { tagMutationsInBatch, setMetadataOnObject } from "@dxos/echo-db";
|
|
40
40
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
41
41
|
import { log } from "@dxos/log";
|
|
42
|
+
import { EchoEvent } from "@dxos/protocols/proto/dxos/echo/service";
|
|
42
43
|
import { ComplexMap } from "@dxos/util";
|
|
43
44
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
|
|
44
45
|
var DataServiceHost = class {
|
|
@@ -66,12 +67,19 @@ var DataServiceHost = class {
|
|
|
66
67
|
objects
|
|
67
68
|
}
|
|
68
69
|
});
|
|
70
|
+
this._itemDemuxer.snapshot.on(ctx, (snapshot) => {
|
|
71
|
+
next({
|
|
72
|
+
action: EchoEvent.DatabaseAction.RESET,
|
|
73
|
+
batch: {
|
|
74
|
+
objects: snapshot.items
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
69
78
|
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
70
|
-
var _a;
|
|
71
79
|
const { batch, meta } = message;
|
|
72
80
|
invariant2(!meta.clientTag, "Unexpected client tag in mutation message", {
|
|
73
81
|
F: __dxlog_file2,
|
|
74
|
-
L:
|
|
82
|
+
L: 68,
|
|
75
83
|
S: this,
|
|
76
84
|
A: [
|
|
77
85
|
"!(meta as any).clientTag",
|
|
@@ -79,11 +87,11 @@ var DataServiceHost = class {
|
|
|
79
87
|
]
|
|
80
88
|
});
|
|
81
89
|
log("message", {
|
|
82
|
-
batch,
|
|
90
|
+
batch: batch.objects?.length,
|
|
83
91
|
meta
|
|
84
92
|
}, {
|
|
85
93
|
F: __dxlog_file2,
|
|
86
|
-
L:
|
|
94
|
+
L: 69,
|
|
87
95
|
S: this,
|
|
88
96
|
C: (f, a) => f(...a)
|
|
89
97
|
});
|
|
@@ -91,7 +99,7 @@ var DataServiceHost = class {
|
|
|
91
99
|
message.meta.feedKey,
|
|
92
100
|
message.meta.seq
|
|
93
101
|
]);
|
|
94
|
-
|
|
102
|
+
batch.objects?.forEach((object) => {
|
|
95
103
|
setMetadataOnObject(object, {
|
|
96
104
|
...meta
|
|
97
105
|
});
|
|
@@ -109,10 +117,9 @@ var DataServiceHost = class {
|
|
|
109
117
|
});
|
|
110
118
|
}
|
|
111
119
|
async write(request) {
|
|
112
|
-
var _a, _b;
|
|
113
120
|
invariant2(!this._ctx.disposed, "Cannot write to closed DataServiceHost", {
|
|
114
121
|
F: __dxlog_file2,
|
|
115
|
-
L:
|
|
122
|
+
L: 95,
|
|
116
123
|
S: this,
|
|
117
124
|
A: [
|
|
118
125
|
"!this._ctx.disposed",
|
|
@@ -121,7 +128,7 @@ var DataServiceHost = class {
|
|
|
121
128
|
});
|
|
122
129
|
invariant2(this._writeStream, "Cannot write mutations in readonly mode", {
|
|
123
130
|
F: __dxlog_file2,
|
|
124
|
-
L:
|
|
131
|
+
L: 96,
|
|
125
132
|
S: this,
|
|
126
133
|
A: [
|
|
127
134
|
"this._writeStream",
|
|
@@ -130,10 +137,10 @@ var DataServiceHost = class {
|
|
|
130
137
|
});
|
|
131
138
|
log("write", {
|
|
132
139
|
clientTag: request.clientTag,
|
|
133
|
-
objectCount:
|
|
140
|
+
objectCount: request.batch.objects?.length ?? 0
|
|
134
141
|
}, {
|
|
135
142
|
F: __dxlog_file2,
|
|
136
|
-
L:
|
|
143
|
+
L: 98,
|
|
137
144
|
S: this,
|
|
138
145
|
C: (f, a) => f(...a)
|
|
139
146
|
});
|
|
@@ -147,7 +154,7 @@ var DataServiceHost = class {
|
|
|
147
154
|
seq: receipt2.seq
|
|
148
155
|
}, {
|
|
149
156
|
F: __dxlog_file2,
|
|
150
|
-
L:
|
|
157
|
+
L: 107,
|
|
151
158
|
S: this,
|
|
152
159
|
C: (f, a) => f(...a)
|
|
153
160
|
});
|
|
@@ -161,24 +168,18 @@ var DataServiceHost = class {
|
|
|
161
168
|
return receipt;
|
|
162
169
|
}
|
|
163
170
|
};
|
|
164
|
-
var createDataMessage = (batch) => {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
meta: void 0
|
|
177
|
-
};
|
|
178
|
-
})
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
};
|
|
171
|
+
var createDataMessage = (batch) => ({
|
|
172
|
+
batch: {
|
|
173
|
+
objects: batch.objects?.map((object) => ({
|
|
174
|
+
...object,
|
|
175
|
+
mutations: object.mutations?.map((mutation) => ({
|
|
176
|
+
...mutation,
|
|
177
|
+
meta: void 0
|
|
178
|
+
})),
|
|
179
|
+
meta: void 0
|
|
180
|
+
}))
|
|
181
|
+
}
|
|
182
|
+
});
|
|
182
183
|
|
|
183
184
|
// packages/core/echo/echo-pipeline/src/db-host/database-host.ts
|
|
184
185
|
import { ItemDemuxer } from "@dxos/echo-db";
|
|
@@ -207,15 +208,13 @@ var DatabaseHost = class {
|
|
|
207
208
|
return this._itemDemuxer.createSnapshot();
|
|
208
209
|
}
|
|
209
210
|
createDataServiceHost() {
|
|
210
|
-
|
|
211
|
-
return new DataServiceHost(this._itemManager, this._itemDemuxer, (_a = this._outboundStream) != null ? _a : void 0);
|
|
211
|
+
return new DataServiceHost(this._itemManager, this._itemDemuxer, this._outboundStream ?? void 0);
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
214
|
|
|
215
215
|
// packages/core/echo/echo-pipeline/src/db-host/snapshot-manager.ts
|
|
216
216
|
import { trackLeaks } from "@dxos/async";
|
|
217
217
|
import { cancelWithContext } from "@dxos/context";
|
|
218
|
-
import { timed } from "@dxos/debug";
|
|
219
218
|
import { PublicKey } from "@dxos/keys";
|
|
220
219
|
import { schema as schema2 } from "@dxos/protocols";
|
|
221
220
|
import { BlobMeta } from "@dxos/protocols/proto/dxos/echo/blob";
|
|
@@ -260,9 +259,6 @@ var SnapshotManager = class SnapshotManager2 {
|
|
|
260
259
|
return PublicKey.from(id).toHex();
|
|
261
260
|
}
|
|
262
261
|
};
|
|
263
|
-
_ts_decorate([
|
|
264
|
-
timed(1e4)
|
|
265
|
-
], SnapshotManager.prototype, "load", null);
|
|
266
262
|
SnapshotManager = _ts_decorate([
|
|
267
263
|
trackLeaks("open", "close")
|
|
268
264
|
], SnapshotManager);
|
|
@@ -358,7 +354,7 @@ var DataServiceSubscriptions = class {
|
|
|
358
354
|
C: (f, a) => f(...a)
|
|
359
355
|
});
|
|
360
356
|
const host = this._spaces.get(spaceKey);
|
|
361
|
-
await
|
|
357
|
+
await host?.close();
|
|
362
358
|
this._spaces.delete(spaceKey);
|
|
363
359
|
}
|
|
364
360
|
getDataService(spaceKey) {
|
|
@@ -370,7 +366,6 @@ var DataServiceImpl = class {
|
|
|
370
366
|
this._subscriptions = _subscriptions;
|
|
371
367
|
}
|
|
372
368
|
subscribe(request) {
|
|
373
|
-
var _a;
|
|
374
369
|
invariant3(request.spaceKey, void 0, {
|
|
375
370
|
F: __dxlog_file3,
|
|
376
371
|
L: 56,
|
|
@@ -380,11 +375,10 @@ var DataServiceImpl = class {
|
|
|
380
375
|
""
|
|
381
376
|
]
|
|
382
377
|
});
|
|
383
|
-
const host =
|
|
378
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
|
|
384
379
|
return host.subscribe();
|
|
385
380
|
}
|
|
386
381
|
write(request) {
|
|
387
|
-
var _a;
|
|
388
382
|
invariant3(request.spaceKey, void 0, {
|
|
389
383
|
F: __dxlog_file3,
|
|
390
384
|
L: 63,
|
|
@@ -403,7 +397,7 @@ var DataServiceImpl = class {
|
|
|
403
397
|
""
|
|
404
398
|
]
|
|
405
399
|
});
|
|
406
|
-
const host =
|
|
400
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
|
|
407
401
|
return host.write(request);
|
|
408
402
|
}
|
|
409
403
|
};
|
|
@@ -431,8 +425,8 @@ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipelin
|
|
|
431
425
|
var emptyEchoMetadata = () => ({
|
|
432
426
|
version: STORAGE_VERSION,
|
|
433
427
|
spaces: [],
|
|
434
|
-
created: new Date(),
|
|
435
|
-
updated: new Date()
|
|
428
|
+
created: /* @__PURE__ */ new Date(),
|
|
429
|
+
updated: /* @__PURE__ */ new Date()
|
|
436
430
|
});
|
|
437
431
|
var EchoMetadata = schema4.getCodecForType("dxos.echo.metadata.EchoMetadata");
|
|
438
432
|
var MetadataStore = class {
|
|
@@ -446,22 +440,19 @@ var MetadataStore = class {
|
|
|
446
440
|
return this._metadata;
|
|
447
441
|
}
|
|
448
442
|
get version() {
|
|
449
|
-
|
|
450
|
-
return (_a = this._metadata.version) != null ? _a : 0;
|
|
443
|
+
return this._metadata.version ?? 0;
|
|
451
444
|
}
|
|
452
445
|
/**
|
|
453
446
|
* Returns a list of currently saved spaces. The list and objects in it can be modified addSpace and
|
|
454
447
|
* addSpaceFeed functions.
|
|
455
448
|
*/
|
|
456
449
|
get spaces() {
|
|
457
|
-
|
|
458
|
-
return (_a = this._metadata.spaces) != null ? _a : [];
|
|
450
|
+
return this._metadata.spaces ?? [];
|
|
459
451
|
}
|
|
460
452
|
/**
|
|
461
453
|
* Loads metadata from persistent storage.
|
|
462
454
|
*/
|
|
463
455
|
async load() {
|
|
464
|
-
var _a;
|
|
465
456
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
466
457
|
try {
|
|
467
458
|
const { size: fileLength } = await file.stat();
|
|
@@ -480,7 +471,10 @@ var MetadataStore = class {
|
|
|
480
471
|
C: (f, a) => f(...a)
|
|
481
472
|
});
|
|
482
473
|
if (fileLength < dataSize + 8) {
|
|
483
|
-
throw new DataCorruptionError("Metadata size is smaller than expected."
|
|
474
|
+
throw new DataCorruptionError("Metadata size is smaller than expected.", {
|
|
475
|
+
fileLength,
|
|
476
|
+
dataSize
|
|
477
|
+
});
|
|
484
478
|
}
|
|
485
479
|
const data = await file.read(8, dataSize);
|
|
486
480
|
const calculatedChecksum = CRC32.buf(data);
|
|
@@ -488,9 +482,8 @@ var MetadataStore = class {
|
|
|
488
482
|
throw new DataCorruptionError("Metadata checksum is invalid.");
|
|
489
483
|
}
|
|
490
484
|
this._metadata = EchoMetadata.decode(data);
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
(_a2 = space.state) != null ? _a2 : space.state = SpaceState.ACTIVE;
|
|
485
|
+
this._metadata.spaces?.forEach((space) => {
|
|
486
|
+
space.state ??= SpaceState.ACTIVE;
|
|
494
487
|
});
|
|
495
488
|
} catch (err) {
|
|
496
489
|
log3.error("failed to load metadata", {
|
|
@@ -507,12 +500,11 @@ var MetadataStore = class {
|
|
|
507
500
|
}
|
|
508
501
|
}
|
|
509
502
|
async _save() {
|
|
510
|
-
var _a;
|
|
511
503
|
const data = {
|
|
512
504
|
...this._metadata,
|
|
513
505
|
version: STORAGE_VERSION,
|
|
514
|
-
created:
|
|
515
|
-
updated: new Date()
|
|
506
|
+
created: this._metadata.created ?? /* @__PURE__ */ new Date(),
|
|
507
|
+
updated: /* @__PURE__ */ new Date()
|
|
516
508
|
};
|
|
517
509
|
this.update.emit(data);
|
|
518
510
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
@@ -538,8 +530,7 @@ var MetadataStore = class {
|
|
|
538
530
|
}
|
|
539
531
|
}
|
|
540
532
|
_getSpace(spaceKey) {
|
|
541
|
-
|
|
542
|
-
if ((_a = this._metadata.identity) == null ? void 0 : _a.haloSpace.key.equals(spaceKey)) {
|
|
533
|
+
if (this._metadata.identity?.haloSpace.key.equals(spaceKey)) {
|
|
543
534
|
return this._metadata.identity.haloSpace;
|
|
544
535
|
}
|
|
545
536
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
@@ -584,8 +575,7 @@ var MetadataStore = class {
|
|
|
584
575
|
await this._save();
|
|
585
576
|
}
|
|
586
577
|
async addSpace(record) {
|
|
587
|
-
|
|
588
|
-
invariant4(!((_a = this._metadata.spaces) != null ? _a : []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
|
|
578
|
+
invariant4(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
|
|
589
579
|
F: __dxlog_file4,
|
|
590
580
|
L: 162,
|
|
591
581
|
S: this,
|
|
@@ -594,7 +584,7 @@ var MetadataStore = class {
|
|
|
594
584
|
"'Cannot overwrite existing space in metadata'"
|
|
595
585
|
]
|
|
596
586
|
});
|
|
597
|
-
(
|
|
587
|
+
(this._metadata.spaces ??= []).push(record);
|
|
598
588
|
await this._save();
|
|
599
589
|
}
|
|
600
590
|
async setSpaceDataLatestTimeframe(spaceKey, timeframe) {
|
|
@@ -630,7 +620,7 @@ var fromBytesInt32 = (buf) => buf.readInt32LE(0);
|
|
|
630
620
|
|
|
631
621
|
// packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts
|
|
632
622
|
import { Event as Event2 } from "@dxos/async";
|
|
633
|
-
import { timed
|
|
623
|
+
import { timed } from "@dxos/debug";
|
|
634
624
|
import { log as log4 } from "@dxos/log";
|
|
635
625
|
import { Timeframe } from "@dxos/timeframe";
|
|
636
626
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
@@ -723,7 +713,7 @@ var TimeframeClock = class {
|
|
|
723
713
|
}
|
|
724
714
|
};
|
|
725
715
|
_ts_decorate3([
|
|
726
|
-
|
|
716
|
+
timed(5e3)
|
|
727
717
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
728
718
|
|
|
729
719
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
@@ -829,7 +819,6 @@ var PipelineState = class {
|
|
|
829
819
|
* @param timeout Timeout in milliseconds to specify the maximum wait time.
|
|
830
820
|
*/
|
|
831
821
|
async waitUntilReachedTargetTimeframe({ ctx = new Context2(), timeout, breakOnStall = true } = {}) {
|
|
832
|
-
var _a;
|
|
833
822
|
log6("waitUntilReachedTargetTimeframe", {
|
|
834
823
|
timeout,
|
|
835
824
|
current: this.timeframe,
|
|
@@ -840,7 +829,7 @@ var PipelineState = class {
|
|
|
840
829
|
S: this,
|
|
841
830
|
C: (f, a) => f(...a)
|
|
842
831
|
});
|
|
843
|
-
|
|
832
|
+
this._reachedTargetPromise ??= Promise.race([
|
|
844
833
|
this._timeframeClock.update.waitForCondition(() => {
|
|
845
834
|
return Timeframe2.dependencies(this.targetTimeframe, this.timeframe).isEmpty();
|
|
846
835
|
}),
|
|
@@ -887,9 +876,11 @@ var Pipeline = class {
|
|
|
887
876
|
// Waits for the message consumer to process the message and yield control back to the pipeline.
|
|
888
877
|
this._processingTrigger = new Trigger().wake();
|
|
889
878
|
this._pauseTrigger = new Trigger().wake();
|
|
879
|
+
// Pending downloads.
|
|
880
|
+
this._downloads = new ComplexMap3((value) => PublicKey3.hash(value.key));
|
|
890
881
|
this._isStopping = false;
|
|
891
882
|
this._isStarted = false;
|
|
892
|
-
this.
|
|
883
|
+
this._isBeingConsumed = false;
|
|
893
884
|
this._isPaused = false;
|
|
894
885
|
}
|
|
895
886
|
get state() {
|
|
@@ -898,7 +889,7 @@ var Pipeline = class {
|
|
|
898
889
|
get writer() {
|
|
899
890
|
invariant6(this._writer, "Writer not set.", {
|
|
900
891
|
F: __dxlog_file7,
|
|
901
|
-
L:
|
|
892
|
+
L: 233,
|
|
902
893
|
S: this,
|
|
903
894
|
A: [
|
|
904
895
|
"this._writer",
|
|
@@ -920,12 +911,14 @@ var Pipeline = class {
|
|
|
920
911
|
if (this._feedSetIterator) {
|
|
921
912
|
await this._feedSetIterator.addFeed(feed);
|
|
922
913
|
}
|
|
923
|
-
this.
|
|
914
|
+
if (this._isStarted && !this._isPaused) {
|
|
915
|
+
this._setFeedDownloadState(feed);
|
|
916
|
+
}
|
|
924
917
|
}
|
|
925
918
|
setWriteFeed(feed) {
|
|
926
919
|
invariant6(!this._writer, "Writer already set.", {
|
|
927
920
|
F: __dxlog_file7,
|
|
928
|
-
L:
|
|
921
|
+
L: 260,
|
|
929
922
|
S: this,
|
|
930
923
|
A: [
|
|
931
924
|
"!this._writer",
|
|
@@ -934,7 +927,7 @@ var Pipeline = class {
|
|
|
934
927
|
});
|
|
935
928
|
invariant6(feed.properties.writable, "Feed must be writable.", {
|
|
936
929
|
F: __dxlog_file7,
|
|
937
|
-
L:
|
|
930
|
+
L: 261,
|
|
938
931
|
S: this,
|
|
939
932
|
A: [
|
|
940
933
|
"feed.properties.writable",
|
|
@@ -947,9 +940,18 @@ var Pipeline = class {
|
|
|
947
940
|
}), feed.createFeedWriter());
|
|
948
941
|
}
|
|
949
942
|
async start() {
|
|
943
|
+
invariant6(!this._isStarted, "Pipeline is already started.", {
|
|
944
|
+
F: __dxlog_file7,
|
|
945
|
+
L: 274,
|
|
946
|
+
S: this,
|
|
947
|
+
A: [
|
|
948
|
+
"!this._isStarted",
|
|
949
|
+
"'Pipeline is already started.'"
|
|
950
|
+
]
|
|
951
|
+
});
|
|
950
952
|
log6("starting...", void 0, {
|
|
951
953
|
F: __dxlog_file7,
|
|
952
|
-
L:
|
|
954
|
+
L: 275,
|
|
953
955
|
S: this,
|
|
954
956
|
C: (f, a) => f(...a)
|
|
955
957
|
});
|
|
@@ -958,21 +960,29 @@ var Pipeline = class {
|
|
|
958
960
|
this._isStarted = true;
|
|
959
961
|
log6("started", void 0, {
|
|
960
962
|
F: __dxlog_file7,
|
|
961
|
-
L:
|
|
963
|
+
L: 279,
|
|
962
964
|
S: this,
|
|
963
965
|
C: (f, a) => f(...a)
|
|
964
966
|
});
|
|
967
|
+
if (!this._isPaused) {
|
|
968
|
+
for (const feed of this._feeds.values()) {
|
|
969
|
+
this._setFeedDownloadState(feed);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
965
972
|
}
|
|
966
973
|
async stop() {
|
|
967
|
-
var _a;
|
|
968
974
|
log6("stopping...", void 0, {
|
|
969
975
|
F: __dxlog_file7,
|
|
970
|
-
L:
|
|
976
|
+
L: 290,
|
|
971
977
|
S: this,
|
|
972
978
|
C: (f, a) => f(...a)
|
|
973
979
|
});
|
|
974
980
|
this._isStopping = true;
|
|
975
|
-
|
|
981
|
+
for (const [feed, handle] of this._downloads.entries()) {
|
|
982
|
+
feed.undownload(handle);
|
|
983
|
+
}
|
|
984
|
+
this._downloads.clear();
|
|
985
|
+
await this._feedSetIterator?.close();
|
|
976
986
|
await this._processingTrigger.wait();
|
|
977
987
|
await this._state._ctx.dispose();
|
|
978
988
|
this._state._ctx = new Context2();
|
|
@@ -980,7 +990,7 @@ var Pipeline = class {
|
|
|
980
990
|
this._isStarted = false;
|
|
981
991
|
log6("stopped", void 0, {
|
|
982
992
|
F: __dxlog_file7,
|
|
983
|
-
L:
|
|
993
|
+
L: 302,
|
|
984
994
|
S: this,
|
|
985
995
|
C: (f, a) => f(...a)
|
|
986
996
|
});
|
|
@@ -992,7 +1002,7 @@ var Pipeline = class {
|
|
|
992
1002
|
async setCursor(timeframe) {
|
|
993
1003
|
invariant6(!this._isStarted || this._isPaused, "Invalid state.", {
|
|
994
1004
|
F: __dxlog_file7,
|
|
995
|
-
L:
|
|
1005
|
+
L: 311,
|
|
996
1006
|
S: this,
|
|
997
1007
|
A: [
|
|
998
1008
|
"!this._isStarted || this._isPaused",
|
|
@@ -1001,9 +1011,6 @@ var Pipeline = class {
|
|
|
1001
1011
|
});
|
|
1002
1012
|
this._state._startTimeframe = timeframe;
|
|
1003
1013
|
this._timeframeClock.setTimeframe(timeframe);
|
|
1004
|
-
for (const feed of this._feeds.values()) {
|
|
1005
|
-
this._setFeedDownloadState(feed);
|
|
1006
|
-
}
|
|
1007
1014
|
if (this._feedSetIterator) {
|
|
1008
1015
|
await this._feedSetIterator.close();
|
|
1009
1016
|
await this._initIterator();
|
|
@@ -1014,15 +1021,6 @@ var Pipeline = class {
|
|
|
1014
1021
|
* Calling pause while processing will cause a deadlock.
|
|
1015
1022
|
*/
|
|
1016
1023
|
async pause() {
|
|
1017
|
-
invariant6(this._isStarted, "Pipeline is not open.", {
|
|
1018
|
-
F: __dxlog_file7,
|
|
1019
|
-
L: 315,
|
|
1020
|
-
S: this,
|
|
1021
|
-
A: [
|
|
1022
|
-
"this._isStarted",
|
|
1023
|
-
"'Pipeline is not open.'"
|
|
1024
|
-
]
|
|
1025
|
-
});
|
|
1026
1024
|
if (this._isPaused) {
|
|
1027
1025
|
return;
|
|
1028
1026
|
}
|
|
@@ -1031,18 +1029,9 @@ var Pipeline = class {
|
|
|
1031
1029
|
this._isPaused = true;
|
|
1032
1030
|
}
|
|
1033
1031
|
async unpause() {
|
|
1034
|
-
invariant6(this._isStarted, "Pipeline is not open.", {
|
|
1035
|
-
F: __dxlog_file7,
|
|
1036
|
-
L: 327,
|
|
1037
|
-
S: this,
|
|
1038
|
-
A: [
|
|
1039
|
-
"this._isStarted",
|
|
1040
|
-
"'Pipeline is not open.'"
|
|
1041
|
-
]
|
|
1042
|
-
});
|
|
1043
1032
|
invariant6(this._isPaused, "Pipeline is not paused.", {
|
|
1044
1033
|
F: __dxlog_file7,
|
|
1045
|
-
L:
|
|
1034
|
+
L: 340,
|
|
1046
1035
|
S: this,
|
|
1047
1036
|
A: [
|
|
1048
1037
|
"this._isPaused",
|
|
@@ -1051,25 +1040,28 @@ var Pipeline = class {
|
|
|
1051
1040
|
});
|
|
1052
1041
|
this._pauseTrigger.wake();
|
|
1053
1042
|
this._isPaused = false;
|
|
1043
|
+
for (const feed of this._feeds.values()) {
|
|
1044
|
+
this._setFeedDownloadState(feed);
|
|
1045
|
+
}
|
|
1054
1046
|
}
|
|
1055
1047
|
/**
|
|
1056
1048
|
* Starts to iterate over the ordered messages from the added feeds.
|
|
1057
1049
|
* Updates the timeframe clock after the message has bee processed.
|
|
1058
1050
|
*/
|
|
1059
1051
|
async *consume() {
|
|
1060
|
-
invariant6(!this.
|
|
1052
|
+
invariant6(!this._isBeingConsumed, "Pipeline is already being consumed.", {
|
|
1061
1053
|
F: __dxlog_file7,
|
|
1062
|
-
L:
|
|
1054
|
+
L: 355,
|
|
1063
1055
|
S: this,
|
|
1064
1056
|
A: [
|
|
1065
|
-
"!this.
|
|
1057
|
+
"!this._isBeingConsumed",
|
|
1066
1058
|
"'Pipeline is already being consumed.'"
|
|
1067
1059
|
]
|
|
1068
1060
|
});
|
|
1069
|
-
this.
|
|
1061
|
+
this._isBeingConsumed = true;
|
|
1070
1062
|
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1071
1063
|
F: __dxlog_file7,
|
|
1072
|
-
L:
|
|
1064
|
+
L: 358,
|
|
1073
1065
|
S: this,
|
|
1074
1066
|
A: [
|
|
1075
1067
|
"this._feedSetIterator",
|
|
@@ -1083,7 +1075,7 @@ var Pipeline = class {
|
|
|
1083
1075
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
1084
1076
|
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1085
1077
|
F: __dxlog_file7,
|
|
1086
|
-
L:
|
|
1078
|
+
L: 367,
|
|
1087
1079
|
S: this,
|
|
1088
1080
|
A: [
|
|
1089
1081
|
"this._feedSetIterator",
|
|
@@ -1095,7 +1087,7 @@ var Pipeline = class {
|
|
|
1095
1087
|
}
|
|
1096
1088
|
const { done, value } = await iterable.next();
|
|
1097
1089
|
if (!done) {
|
|
1098
|
-
const block = value
|
|
1090
|
+
const block = value ?? failUndefined();
|
|
1099
1091
|
this._processingTrigger.reset();
|
|
1100
1092
|
this._timeframeClock.updatePendingTimeframe(PublicKey3.from(block.feedKey), block.seq);
|
|
1101
1093
|
yield block;
|
|
@@ -1103,33 +1095,40 @@ var Pipeline = class {
|
|
|
1103
1095
|
this._timeframeClock.updateTimeframe();
|
|
1104
1096
|
}
|
|
1105
1097
|
}
|
|
1106
|
-
this.
|
|
1098
|
+
this._isBeingConsumed = false;
|
|
1107
1099
|
}
|
|
1108
1100
|
_setFeedDownloadState(feed) {
|
|
1109
|
-
|
|
1101
|
+
let handle = this._downloads.get(feed);
|
|
1102
|
+
if (handle) {
|
|
1103
|
+
feed.undownload(handle);
|
|
1104
|
+
}
|
|
1110
1105
|
const timeframe = this._state._startTimeframe;
|
|
1111
|
-
const seq =
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1106
|
+
const seq = timeframe.get(feed.key) ?? -1;
|
|
1107
|
+
log6.info("download", {
|
|
1108
|
+
feed: feed.key.truncate(),
|
|
1109
|
+
seq,
|
|
1110
|
+
length: feed.length
|
|
1111
|
+
}, {
|
|
1112
|
+
F: __dxlog_file7,
|
|
1113
|
+
L: 396,
|
|
1114
|
+
S: this,
|
|
1115
|
+
C: (f, a) => f(...a)
|
|
1119
1116
|
});
|
|
1120
|
-
feed.download({
|
|
1117
|
+
handle = feed.download({
|
|
1121
1118
|
start: seq + 1,
|
|
1122
1119
|
linear: true
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1120
|
+
}, (err, data) => {
|
|
1121
|
+
if (err) {
|
|
1122
|
+
} else {
|
|
1123
|
+
log6.info("data", data, {
|
|
1124
|
+
F: __dxlog_file7,
|
|
1125
|
+
L: 401,
|
|
1126
|
+
S: this,
|
|
1127
|
+
C: (f, a) => f(...a)
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1132
1130
|
});
|
|
1131
|
+
this._downloads.set(feed, handle);
|
|
1133
1132
|
}
|
|
1134
1133
|
async _initIterator() {
|
|
1135
1134
|
this._feedSetIterator = new FeedSetIterator(createMessageSelector(this._timeframeClock), {
|
|
@@ -1139,7 +1138,7 @@ var Pipeline = class {
|
|
|
1139
1138
|
this._feedSetIterator.stalled.on((iterator) => {
|
|
1140
1139
|
log6.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
|
|
1141
1140
|
F: __dxlog_file7,
|
|
1142
|
-
L:
|
|
1141
|
+
L: 415,
|
|
1143
1142
|
S: this,
|
|
1144
1143
|
C: (f, a) => f(...a)
|
|
1145
1144
|
});
|
|
@@ -1231,7 +1230,7 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1231
1230
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
1232
1231
|
challenge
|
|
1233
1232
|
});
|
|
1234
|
-
invariant7(
|
|
1233
|
+
invariant7(credential?.length > 0, "invalid credential", {
|
|
1235
1234
|
F: __dxlog_file8,
|
|
1236
1235
|
L: 69,
|
|
1237
1236
|
S: this,
|
|
@@ -1273,11 +1272,12 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1273
1272
|
import { Event as Event4, scheduleTask as scheduleTask2, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
1274
1273
|
import { Context as Context4 } from "@dxos/context";
|
|
1275
1274
|
import { checkCredentialType } from "@dxos/credentials";
|
|
1276
|
-
import { getStateMachineFromItem, ItemManager } from "@dxos/echo-db";
|
|
1275
|
+
import { getStateMachineFromItem, ItemManager, TYPE_PROPERTIES } from "@dxos/echo-db";
|
|
1277
1276
|
import { CancelledError } from "@dxos/errors";
|
|
1278
1277
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
1279
|
-
import { log as log8 } from "@dxos/log";
|
|
1278
|
+
import { log as log8, omit } from "@dxos/log";
|
|
1280
1279
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
1280
|
+
import { TimeSeriesCounter, TimeUsageCounter, trace } from "@dxos/tracing";
|
|
1281
1281
|
import { tracer } from "@dxos/util";
|
|
1282
1282
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
1283
1283
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1304,6 +1304,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1304
1304
|
this._lastTimeframeSaveTime = 0;
|
|
1305
1305
|
this._lastSnapshotSaveTime = 0;
|
|
1306
1306
|
this._lastProcessedEpoch = -1;
|
|
1307
|
+
this._usage = new TimeUsageCounter();
|
|
1308
|
+
this._mutations = new TimeSeriesCounter();
|
|
1307
1309
|
this.currentEpoch = void 0;
|
|
1308
1310
|
this.appliedEpoch = void 0;
|
|
1309
1311
|
this.onNewEpoch = new Event4();
|
|
@@ -1315,13 +1317,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1315
1317
|
return this._pipeline;
|
|
1316
1318
|
}
|
|
1317
1319
|
get pipelineState() {
|
|
1318
|
-
|
|
1319
|
-
return (_a = this._pipeline) == null ? void 0 : _a.state;
|
|
1320
|
+
return this._pipeline?.state;
|
|
1320
1321
|
}
|
|
1321
1322
|
setTargetTimeframe(timeframe) {
|
|
1322
|
-
var _a;
|
|
1323
1323
|
this._targetTimeframe = timeframe;
|
|
1324
|
-
|
|
1324
|
+
this._pipeline?.state.setTargetTimeframe(timeframe);
|
|
1325
1325
|
}
|
|
1326
1326
|
async processCredential(credential) {
|
|
1327
1327
|
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
@@ -1338,8 +1338,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1338
1338
|
}
|
|
1339
1339
|
this._pipeline = new Pipeline();
|
|
1340
1340
|
await this._params.onPipelineCreated(this._pipeline);
|
|
1341
|
-
await this._pipeline.start();
|
|
1342
1341
|
await this._pipeline.pause();
|
|
1342
|
+
await this._pipeline.start();
|
|
1343
1343
|
if (this._targetTimeframe) {
|
|
1344
1344
|
this._pipeline.state.setTargetTimeframe(this._targetTimeframe);
|
|
1345
1345
|
}
|
|
@@ -1347,7 +1347,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1347
1347
|
write: (data, options) => {
|
|
1348
1348
|
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1349
1349
|
F: __dxlog_file9,
|
|
1350
|
-
L:
|
|
1350
|
+
L: 154,
|
|
1351
1351
|
S: this,
|
|
1352
1352
|
A: [
|
|
1353
1353
|
"this._pipeline",
|
|
@@ -1356,7 +1356,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1356
1356
|
});
|
|
1357
1357
|
invariant8(this.currentEpoch, "Epoch is not initialized.", {
|
|
1358
1358
|
F: __dxlog_file9,
|
|
1359
|
-
L:
|
|
1359
|
+
L: 155,
|
|
1360
1360
|
S: this,
|
|
1361
1361
|
A: [
|
|
1362
1362
|
"this.currentEpoch",
|
|
@@ -1377,19 +1377,18 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1377
1377
|
this._isOpen = true;
|
|
1378
1378
|
}
|
|
1379
1379
|
async close() {
|
|
1380
|
-
var _a, _b, _c;
|
|
1381
1380
|
if (!this._isOpen) {
|
|
1382
1381
|
return;
|
|
1383
1382
|
}
|
|
1384
1383
|
log8("close", void 0, {
|
|
1385
1384
|
F: __dxlog_file9,
|
|
1386
|
-
L:
|
|
1385
|
+
L: 179,
|
|
1387
1386
|
S: this,
|
|
1388
1387
|
C: (f, a) => f(...a)
|
|
1389
1388
|
});
|
|
1390
1389
|
this._isOpen = false;
|
|
1391
1390
|
await this._ctx.dispose();
|
|
1392
|
-
await
|
|
1391
|
+
await this._pipeline?.stop();
|
|
1393
1392
|
try {
|
|
1394
1393
|
await this._saveCache();
|
|
1395
1394
|
if (this._pipeline) {
|
|
@@ -1398,13 +1397,13 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1398
1397
|
} catch (err) {
|
|
1399
1398
|
log8.catch(err, void 0, {
|
|
1400
1399
|
F: __dxlog_file9,
|
|
1401
|
-
L:
|
|
1400
|
+
L: 192,
|
|
1402
1401
|
S: this,
|
|
1403
1402
|
C: (f, a) => f(...a)
|
|
1404
1403
|
});
|
|
1405
1404
|
}
|
|
1406
|
-
await
|
|
1407
|
-
await
|
|
1405
|
+
await this.databaseHost?.close();
|
|
1406
|
+
await this.itemManager?.destroy();
|
|
1408
1407
|
this._ctx = new Context4();
|
|
1409
1408
|
this._pipeline = void 0;
|
|
1410
1409
|
this._targetTimeframe = void 0;
|
|
@@ -1422,7 +1421,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1422
1421
|
}
|
|
1423
1422
|
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1424
1423
|
F: __dxlog_file9,
|
|
1425
|
-
L:
|
|
1424
|
+
L: 215,
|
|
1426
1425
|
S: this,
|
|
1427
1426
|
A: [
|
|
1428
1427
|
"this._pipeline",
|
|
@@ -1430,13 +1429,15 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1430
1429
|
]
|
|
1431
1430
|
});
|
|
1432
1431
|
for await (const msg of this._pipeline.consume()) {
|
|
1432
|
+
const span = this._usage.beginRecording();
|
|
1433
|
+
this._mutations.inc();
|
|
1433
1434
|
const { feedKey, seq, data } = msg;
|
|
1434
1435
|
log8("processing message", {
|
|
1435
1436
|
feedKey,
|
|
1436
1437
|
seq
|
|
1437
1438
|
}, {
|
|
1438
1439
|
F: __dxlog_file9,
|
|
1439
|
-
L:
|
|
1440
|
+
L: 221,
|
|
1440
1441
|
S: this,
|
|
1441
1442
|
C: (f, a) => f(...a)
|
|
1442
1443
|
});
|
|
@@ -1448,7 +1449,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1448
1449
|
feedKey
|
|
1449
1450
|
}, {
|
|
1450
1451
|
F: __dxlog_file9,
|
|
1451
|
-
L:
|
|
1452
|
+
L: 227,
|
|
1452
1453
|
S: this,
|
|
1453
1454
|
C: (f, a) => f(...a)
|
|
1454
1455
|
});
|
|
@@ -1471,7 +1472,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1471
1472
|
spaceKey: this._params.spaceKey.toHex()
|
|
1472
1473
|
}, {
|
|
1473
1474
|
F: __dxlog_file9,
|
|
1474
|
-
L:
|
|
1475
|
+
L: 244,
|
|
1475
1476
|
S: this,
|
|
1476
1477
|
C: (f, a) => f(...a)
|
|
1477
1478
|
});
|
|
@@ -1480,17 +1481,18 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1480
1481
|
} catch (err) {
|
|
1481
1482
|
log8.catch(err, void 0, {
|
|
1482
1483
|
F: __dxlog_file9,
|
|
1483
|
-
L:
|
|
1484
|
+
L: 254,
|
|
1484
1485
|
S: this,
|
|
1485
1486
|
C: (f, a) => f(...a)
|
|
1486
1487
|
});
|
|
1487
1488
|
}
|
|
1489
|
+
span.end();
|
|
1488
1490
|
}
|
|
1489
1491
|
}
|
|
1490
1492
|
_createSnapshot() {
|
|
1491
1493
|
invariant8(this.databaseHost, "Database backend is not initialized.", {
|
|
1492
1494
|
F: __dxlog_file9,
|
|
1493
|
-
L:
|
|
1495
|
+
L: 262,
|
|
1494
1496
|
S: this,
|
|
1495
1497
|
A: [
|
|
1496
1498
|
"this.databaseHost",
|
|
@@ -1504,26 +1506,22 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1504
1506
|
};
|
|
1505
1507
|
}
|
|
1506
1508
|
async _saveTargetTimeframe(timeframe) {
|
|
1507
|
-
|
|
1508
|
-
const newTimeframe = Timeframe3.merge((_a = this._targetTimeframe) != null ? _a : new Timeframe3(), timeframe);
|
|
1509
|
+
const newTimeframe = Timeframe3.merge(this._targetTimeframe ?? new Timeframe3(), timeframe);
|
|
1509
1510
|
await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
|
|
1510
1511
|
this._targetTimeframe = newTimeframe;
|
|
1511
1512
|
}
|
|
1512
1513
|
async _saveCache() {
|
|
1513
|
-
var _a;
|
|
1514
1514
|
const cache = {};
|
|
1515
1515
|
try {
|
|
1516
|
-
const propertiesItem = this.itemManager.items.find((item) =>
|
|
1517
|
-
|
|
1518
|
-
return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = getStateMachineFromItem(item)) == null ? void 0 : _b.snapshot()).type === "dxos.sdk.client.Properties";
|
|
1519
|
-
});
|
|
1516
|
+
const propertiesItem = this.itemManager.items.find((item) => item.modelMeta?.type === "dxos:model/document" && // TODO(burdon): Document?
|
|
1517
|
+
(getStateMachineFromItem(item)?.snapshot()).type === TYPE_PROPERTIES);
|
|
1520
1518
|
if (propertiesItem) {
|
|
1521
|
-
cache.properties =
|
|
1519
|
+
cache.properties = getStateMachineFromItem(propertiesItem)?.snapshot();
|
|
1522
1520
|
}
|
|
1523
1521
|
} catch (err) {
|
|
1524
1522
|
log8.warn("Failed to cache properties", err, {
|
|
1525
1523
|
F: __dxlog_file9,
|
|
1526
|
-
L:
|
|
1524
|
+
L: 291,
|
|
1527
1525
|
S: this,
|
|
1528
1526
|
C: (f, a) => f(...a)
|
|
1529
1527
|
});
|
|
@@ -1540,24 +1538,23 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1540
1538
|
}
|
|
1541
1539
|
}
|
|
1542
1540
|
async _processEpochInSeparateTask(epoch) {
|
|
1543
|
-
var _a;
|
|
1544
1541
|
if (epoch.subject.assertion.number <= this._lastProcessedEpoch) {
|
|
1545
1542
|
return;
|
|
1546
1543
|
}
|
|
1547
|
-
await
|
|
1544
|
+
await this._epochCtx?.dispose();
|
|
1548
1545
|
const ctx = new Context4({
|
|
1549
1546
|
onError: (err) => {
|
|
1550
1547
|
if (err instanceof CancelledError) {
|
|
1551
1548
|
log8("Epoch processing cancelled.", void 0, {
|
|
1552
1549
|
F: __dxlog_file9,
|
|
1553
|
-
L:
|
|
1550
|
+
L: 323,
|
|
1554
1551
|
S: this,
|
|
1555
1552
|
C: (f, a) => f(...a)
|
|
1556
1553
|
});
|
|
1557
1554
|
} else {
|
|
1558
1555
|
log8.catch(err, void 0, {
|
|
1559
1556
|
F: __dxlog_file9,
|
|
1560
|
-
L:
|
|
1557
|
+
L: 325,
|
|
1561
1558
|
S: this,
|
|
1562
1559
|
C: (f, a) => f(...a)
|
|
1563
1560
|
});
|
|
@@ -1569,14 +1566,6 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1569
1566
|
if (!this._isOpen) {
|
|
1570
1567
|
return;
|
|
1571
1568
|
}
|
|
1572
|
-
log8("process epoch", {
|
|
1573
|
-
epoch
|
|
1574
|
-
}, {
|
|
1575
|
-
F: __dxlog_file9,
|
|
1576
|
-
L: 321,
|
|
1577
|
-
S: this,
|
|
1578
|
-
C: (f, a) => f(...a)
|
|
1579
|
-
});
|
|
1580
1569
|
await this._processEpoch(ctx, epoch.subject.assertion);
|
|
1581
1570
|
this.appliedEpoch = epoch;
|
|
1582
1571
|
this.onNewEpoch.emit(epoch);
|
|
@@ -1585,7 +1574,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1585
1574
|
async _processEpoch(ctx, epoch) {
|
|
1586
1575
|
invariant8(this._isOpen, "Space is closed.", {
|
|
1587
1576
|
F: __dxlog_file9,
|
|
1588
|
-
L:
|
|
1577
|
+
L: 344,
|
|
1589
1578
|
S: this,
|
|
1590
1579
|
A: [
|
|
1591
1580
|
"this._isOpen",
|
|
@@ -1594,7 +1583,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1594
1583
|
});
|
|
1595
1584
|
invariant8(this._pipeline, void 0, {
|
|
1596
1585
|
F: __dxlog_file9,
|
|
1597
|
-
L:
|
|
1586
|
+
L: 345,
|
|
1598
1587
|
S: this,
|
|
1599
1588
|
A: [
|
|
1600
1589
|
"this._pipeline",
|
|
@@ -1602,11 +1591,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1602
1591
|
]
|
|
1603
1592
|
});
|
|
1604
1593
|
this._lastProcessedEpoch = epoch.number;
|
|
1605
|
-
log8("
|
|
1606
|
-
epoch
|
|
1594
|
+
log8("processing", {
|
|
1595
|
+
epoch: omit(epoch, "proof")
|
|
1607
1596
|
}, {
|
|
1608
1597
|
F: __dxlog_file9,
|
|
1609
|
-
L:
|
|
1598
|
+
L: 348,
|
|
1610
1599
|
S: this,
|
|
1611
1600
|
C: (f, a) => f(...a)
|
|
1612
1601
|
});
|
|
@@ -1614,9 +1603,9 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1614
1603
|
const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
|
|
1615
1604
|
this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
|
|
1616
1605
|
}
|
|
1617
|
-
log8("restarting pipeline
|
|
1606
|
+
log8("restarting pipeline from epoch", void 0, {
|
|
1618
1607
|
F: __dxlog_file9,
|
|
1619
|
-
L:
|
|
1608
|
+
L: 354,
|
|
1620
1609
|
S: this,
|
|
1621
1610
|
C: (f, a) => f(...a)
|
|
1622
1611
|
});
|
|
@@ -1627,7 +1616,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1627
1616
|
async waitUntilTimeframe(timeframe) {
|
|
1628
1617
|
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1629
1618
|
F: __dxlog_file9,
|
|
1630
|
-
L:
|
|
1619
|
+
L: 361,
|
|
1631
1620
|
S: this,
|
|
1632
1621
|
A: [
|
|
1633
1622
|
"this._pipeline",
|
|
@@ -1639,7 +1628,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1639
1628
|
async createEpoch() {
|
|
1640
1629
|
invariant8(this._pipeline, void 0, {
|
|
1641
1630
|
F: __dxlog_file9,
|
|
1642
|
-
L:
|
|
1631
|
+
L: 367,
|
|
1643
1632
|
S: this,
|
|
1644
1633
|
A: [
|
|
1645
1634
|
"this._pipeline",
|
|
@@ -1648,7 +1637,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1648
1637
|
});
|
|
1649
1638
|
invariant8(this.currentEpoch, void 0, {
|
|
1650
1639
|
F: __dxlog_file9,
|
|
1651
|
-
L:
|
|
1640
|
+
L: 368,
|
|
1652
1641
|
S: this,
|
|
1653
1642
|
A: [
|
|
1654
1643
|
"this.currentEpoch",
|
|
@@ -1671,6 +1660,12 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1671
1660
|
await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
|
|
1672
1661
|
}
|
|
1673
1662
|
};
|
|
1663
|
+
_ts_decorate5([
|
|
1664
|
+
trace.metricsCounter()
|
|
1665
|
+
], DataPipeline.prototype, "_usage", void 0);
|
|
1666
|
+
_ts_decorate5([
|
|
1667
|
+
trace.metricsCounter()
|
|
1668
|
+
], DataPipeline.prototype, "_mutations", void 0);
|
|
1674
1669
|
_ts_decorate5([
|
|
1675
1670
|
synchronized3
|
|
1676
1671
|
], DataPipeline.prototype, "open", null);
|
|
@@ -1684,7 +1679,8 @@ _ts_decorate5([
|
|
|
1684
1679
|
synchronized3
|
|
1685
1680
|
], DataPipeline.prototype, "createEpoch", null);
|
|
1686
1681
|
DataPipeline = _ts_decorate5([
|
|
1687
|
-
trackLeaks2("open", "close")
|
|
1682
|
+
trackLeaks2("open", "close"),
|
|
1683
|
+
trace.resource()
|
|
1688
1684
|
], DataPipeline);
|
|
1689
1685
|
|
|
1690
1686
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
@@ -1692,21 +1688,36 @@ import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeak
|
|
|
1692
1688
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
1693
1689
|
import { log as log10, logInfo } from "@dxos/log";
|
|
1694
1690
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1691
|
+
import { trace as trace3 } from "@dxos/tracing";
|
|
1695
1692
|
import { Callback as Callback2 } from "@dxos/util";
|
|
1696
1693
|
|
|
1697
1694
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
1695
|
+
import { Context as Context5 } from "@dxos/context";
|
|
1698
1696
|
import { SpaceStateMachine } from "@dxos/credentials";
|
|
1699
1697
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
1700
1698
|
import { log as log9 } from "@dxos/log";
|
|
1701
1699
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1702
1700
|
import { Timeframe as Timeframe4 } from "@dxos/timeframe";
|
|
1701
|
+
import { TimeSeriesCounter as TimeSeriesCounter2, TimeUsageCounter as TimeUsageCounter2, trace as trace2 } from "@dxos/tracing";
|
|
1703
1702
|
import { Callback, tracer as tracer2 } from "@dxos/util";
|
|
1703
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1704
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1705
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1706
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1707
|
+
else
|
|
1708
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
1709
|
+
if (d = decorators[i])
|
|
1710
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1711
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1712
|
+
}
|
|
1704
1713
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
1705
1714
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
1706
|
-
var ControlPipeline = class {
|
|
1715
|
+
var ControlPipeline = class ControlPipeline2 {
|
|
1707
1716
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1708
1717
|
this._lastTimeframeSaveTime = Date.now();
|
|
1709
1718
|
this.onFeedAdmitted = new Callback();
|
|
1719
|
+
this._usage = new TimeUsageCounter2();
|
|
1720
|
+
this._mutations = new TimeSeriesCounter2();
|
|
1710
1721
|
this._spaceKey = spaceKey;
|
|
1711
1722
|
this._metadata = metadataStore;
|
|
1712
1723
|
this._pipeline = new Pipeline();
|
|
@@ -1717,7 +1728,7 @@ var ControlPipeline = class {
|
|
|
1717
1728
|
key: info.key
|
|
1718
1729
|
}, {
|
|
1719
1730
|
F: __dxlog_file10,
|
|
1720
|
-
L:
|
|
1731
|
+
L: 61,
|
|
1721
1732
|
S: this,
|
|
1722
1733
|
C: (f, a) => f(...a)
|
|
1723
1734
|
});
|
|
@@ -1728,7 +1739,7 @@ var ControlPipeline = class {
|
|
|
1728
1739
|
} catch (err) {
|
|
1729
1740
|
log9.catch(err, void 0, {
|
|
1730
1741
|
F: __dxlog_file10,
|
|
1731
|
-
L:
|
|
1742
|
+
L: 69,
|
|
1732
1743
|
S: this,
|
|
1733
1744
|
C: (f, a) => f(...a)
|
|
1734
1745
|
});
|
|
@@ -1751,57 +1762,66 @@ var ControlPipeline = class {
|
|
|
1751
1762
|
async start() {
|
|
1752
1763
|
log9("starting...", void 0, {
|
|
1753
1764
|
F: __dxlog_file10,
|
|
1754
|
-
L:
|
|
1765
|
+
L: 93,
|
|
1755
1766
|
S: this,
|
|
1756
1767
|
C: (f, a) => f(...a)
|
|
1757
1768
|
});
|
|
1758
1769
|
setTimeout(async () => {
|
|
1759
|
-
|
|
1760
|
-
try {
|
|
1761
|
-
log9("processing", {
|
|
1762
|
-
key: msg.feedKey,
|
|
1763
|
-
seq: msg.seq
|
|
1764
|
-
}, {
|
|
1765
|
-
F: __dxlog_file10,
|
|
1766
|
-
L: 88,
|
|
1767
|
-
S: this,
|
|
1768
|
-
C: (f, a) => f(...a)
|
|
1769
|
-
});
|
|
1770
|
-
if (msg.data.payload.credential) {
|
|
1771
|
-
const timer = tracer2.mark("dxos.echo.pipeline.control");
|
|
1772
|
-
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
|
|
1773
|
-
timer.end();
|
|
1774
|
-
if (!result) {
|
|
1775
|
-
log9.warn("processing failed", {
|
|
1776
|
-
msg
|
|
1777
|
-
}, {
|
|
1778
|
-
F: __dxlog_file10,
|
|
1779
|
-
L: 98,
|
|
1780
|
-
S: this,
|
|
1781
|
-
C: (f, a) => f(...a)
|
|
1782
|
-
});
|
|
1783
|
-
} else {
|
|
1784
|
-
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1785
|
-
}
|
|
1786
|
-
}
|
|
1787
|
-
} catch (err) {
|
|
1788
|
-
log9.catch(err, void 0, {
|
|
1789
|
-
F: __dxlog_file10,
|
|
1790
|
-
L: 104,
|
|
1791
|
-
S: this,
|
|
1792
|
-
C: (f, a) => f(...a)
|
|
1793
|
-
});
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1770
|
+
void this._consumePipeline(new Context5());
|
|
1796
1771
|
});
|
|
1797
1772
|
await this._pipeline.start();
|
|
1798
1773
|
log9("started", void 0, {
|
|
1799
1774
|
F: __dxlog_file10,
|
|
1800
|
-
L:
|
|
1775
|
+
L: 99,
|
|
1801
1776
|
S: this,
|
|
1802
1777
|
C: (f, a) => f(...a)
|
|
1803
1778
|
});
|
|
1804
1779
|
}
|
|
1780
|
+
async _consumePipeline(ctx) {
|
|
1781
|
+
for await (const msg of this._pipeline.consume()) {
|
|
1782
|
+
const span = this._usage.beginRecording();
|
|
1783
|
+
this._mutations.inc();
|
|
1784
|
+
try {
|
|
1785
|
+
await this._processMessage(ctx, msg);
|
|
1786
|
+
} catch (err) {
|
|
1787
|
+
log9.catch(err, void 0, {
|
|
1788
|
+
F: __dxlog_file10,
|
|
1789
|
+
L: 111,
|
|
1790
|
+
S: this,
|
|
1791
|
+
C: (f, a) => f(...a)
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
span.end();
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
async _processMessage(ctx, msg) {
|
|
1798
|
+
log9("processing", {
|
|
1799
|
+
key: msg.feedKey,
|
|
1800
|
+
seq: msg.seq
|
|
1801
|
+
}, {
|
|
1802
|
+
F: __dxlog_file10,
|
|
1803
|
+
L: 121,
|
|
1804
|
+
S: this,
|
|
1805
|
+
C: (f, a) => f(...a)
|
|
1806
|
+
});
|
|
1807
|
+
if (msg.data.payload.credential) {
|
|
1808
|
+
const timer = tracer2.mark("dxos.echo.pipeline.control");
|
|
1809
|
+
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
|
|
1810
|
+
timer.end();
|
|
1811
|
+
if (!result) {
|
|
1812
|
+
log9.warn("processing failed", {
|
|
1813
|
+
msg
|
|
1814
|
+
}, {
|
|
1815
|
+
F: __dxlog_file10,
|
|
1816
|
+
L: 131,
|
|
1817
|
+
S: this,
|
|
1818
|
+
C: (f, a) => f(...a)
|
|
1819
|
+
});
|
|
1820
|
+
} else {
|
|
1821
|
+
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1805
1825
|
async _noteTargetStateIfNeeded(timeframe) {
|
|
1806
1826
|
if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2) {
|
|
1807
1827
|
this._lastTimeframeSaveTime = Date.now();
|
|
@@ -1811,7 +1831,7 @@ var ControlPipeline = class {
|
|
|
1811
1831
|
async stop() {
|
|
1812
1832
|
log9("stopping...", void 0, {
|
|
1813
1833
|
F: __dxlog_file10,
|
|
1814
|
-
L:
|
|
1834
|
+
L: 149,
|
|
1815
1835
|
S: this,
|
|
1816
1836
|
C: (f, a) => f(...a)
|
|
1817
1837
|
});
|
|
@@ -1819,30 +1839,44 @@ var ControlPipeline = class {
|
|
|
1819
1839
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1820
1840
|
log9("stopped", void 0, {
|
|
1821
1841
|
F: __dxlog_file10,
|
|
1822
|
-
L:
|
|
1842
|
+
L: 152,
|
|
1823
1843
|
S: this,
|
|
1824
1844
|
C: (f, a) => f(...a)
|
|
1825
1845
|
});
|
|
1826
1846
|
}
|
|
1827
1847
|
async _saveTargetTimeframe(timeframe) {
|
|
1828
|
-
var _a;
|
|
1829
1848
|
try {
|
|
1830
|
-
const newTimeframe = Timeframe4.merge(
|
|
1849
|
+
const newTimeframe = Timeframe4.merge(this._targetTimeframe ?? new Timeframe4(), timeframe);
|
|
1831
1850
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1832
1851
|
this._targetTimeframe = newTimeframe;
|
|
1833
1852
|
} catch (err) {
|
|
1834
1853
|
log9(err, void 0, {
|
|
1835
1854
|
F: __dxlog_file10,
|
|
1836
|
-
L:
|
|
1855
|
+
L: 161,
|
|
1837
1856
|
S: this,
|
|
1838
1857
|
C: (f, a) => f(...a)
|
|
1839
1858
|
});
|
|
1840
1859
|
}
|
|
1841
1860
|
}
|
|
1842
1861
|
};
|
|
1862
|
+
_ts_decorate6([
|
|
1863
|
+
trace2.metricsCounter()
|
|
1864
|
+
], ControlPipeline.prototype, "_usage", void 0);
|
|
1865
|
+
_ts_decorate6([
|
|
1866
|
+
trace2.metricsCounter()
|
|
1867
|
+
], ControlPipeline.prototype, "_mutations", void 0);
|
|
1868
|
+
_ts_decorate6([
|
|
1869
|
+
trace2.span()
|
|
1870
|
+
], ControlPipeline.prototype, "_consumePipeline", null);
|
|
1871
|
+
_ts_decorate6([
|
|
1872
|
+
trace2.span()
|
|
1873
|
+
], ControlPipeline.prototype, "_processMessage", null);
|
|
1874
|
+
ControlPipeline = _ts_decorate6([
|
|
1875
|
+
trace2.resource()
|
|
1876
|
+
], ControlPipeline);
|
|
1843
1877
|
|
|
1844
1878
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1845
|
-
function
|
|
1879
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1846
1880
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1847
1881
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1848
1882
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1861,7 +1895,7 @@ var Space = class Space2 {
|
|
|
1861
1895
|
this._isOpen = false;
|
|
1862
1896
|
invariant9(params.spaceKey && params.feedProvider, void 0, {
|
|
1863
1897
|
F: __dxlog_file11,
|
|
1864
|
-
L:
|
|
1898
|
+
L: 73,
|
|
1865
1899
|
S: this,
|
|
1866
1900
|
A: [
|
|
1867
1901
|
"params.spaceKey && params.feedProvider",
|
|
@@ -1903,7 +1937,7 @@ var Space = class Space2 {
|
|
|
1903
1937
|
credential
|
|
1904
1938
|
}, {
|
|
1905
1939
|
F: __dxlog_file11,
|
|
1906
|
-
L:
|
|
1940
|
+
L: 109,
|
|
1907
1941
|
S: this,
|
|
1908
1942
|
C: (f, a) => f(...a)
|
|
1909
1943
|
});
|
|
@@ -1945,12 +1979,10 @@ var Space = class Space2 {
|
|
|
1945
1979
|
return this._genesisFeedKey;
|
|
1946
1980
|
}
|
|
1947
1981
|
get controlFeedKey() {
|
|
1948
|
-
|
|
1949
|
-
return (_a = this._controlFeed) == null ? void 0 : _a.key;
|
|
1982
|
+
return this._controlFeed?.key;
|
|
1950
1983
|
}
|
|
1951
1984
|
get dataFeedKey() {
|
|
1952
|
-
|
|
1953
|
-
return (_a = this._dataFeed) == null ? void 0 : _a.key;
|
|
1985
|
+
return this._dataFeed?.key;
|
|
1954
1986
|
}
|
|
1955
1987
|
get spaceState() {
|
|
1956
1988
|
return this._controlPipeline.spaceState;
|
|
@@ -1970,7 +2002,7 @@ var Space = class Space2 {
|
|
|
1970
2002
|
setControlFeed(feed) {
|
|
1971
2003
|
invariant9(!this._controlFeed, "Control feed already set.", {
|
|
1972
2004
|
F: __dxlog_file11,
|
|
1973
|
-
L:
|
|
2005
|
+
L: 184,
|
|
1974
2006
|
S: this,
|
|
1975
2007
|
A: [
|
|
1976
2008
|
"!this._controlFeed",
|
|
@@ -1982,10 +2014,9 @@ var Space = class Space2 {
|
|
|
1982
2014
|
return this;
|
|
1983
2015
|
}
|
|
1984
2016
|
setDataFeed(feed) {
|
|
1985
|
-
var _a;
|
|
1986
2017
|
invariant9(!this._dataFeed, "Data feed already set.", {
|
|
1987
2018
|
F: __dxlog_file11,
|
|
1988
|
-
L:
|
|
2019
|
+
L: 191,
|
|
1989
2020
|
S: this,
|
|
1990
2021
|
A: [
|
|
1991
2022
|
"!this._dataFeed",
|
|
@@ -1993,7 +2024,7 @@ var Space = class Space2 {
|
|
|
1993
2024
|
]
|
|
1994
2025
|
});
|
|
1995
2026
|
this._dataFeed = feed;
|
|
1996
|
-
|
|
2027
|
+
this._dataPipeline.pipeline?.setWriteFeed(feed);
|
|
1997
2028
|
return this;
|
|
1998
2029
|
}
|
|
1999
2030
|
/**
|
|
@@ -2008,10 +2039,10 @@ var Space = class Space2 {
|
|
|
2008
2039
|
// getDataFeeds(): FeedInfo[] {
|
|
2009
2040
|
// return this._dataPipeline?.getFeeds();
|
|
2010
2041
|
// }
|
|
2011
|
-
async open() {
|
|
2042
|
+
async open(ctx) {
|
|
2012
2043
|
log10("opening...", void 0, {
|
|
2013
2044
|
F: __dxlog_file11,
|
|
2014
|
-
L:
|
|
2045
|
+
L: 213,
|
|
2015
2046
|
S: this,
|
|
2016
2047
|
C: (f, a) => f(...a)
|
|
2017
2048
|
});
|
|
@@ -2024,7 +2055,7 @@ var Space = class Space2 {
|
|
|
2024
2055
|
this._isOpen = true;
|
|
2025
2056
|
log10("opened", void 0, {
|
|
2026
2057
|
F: __dxlog_file11,
|
|
2027
|
-
L:
|
|
2058
|
+
L: 224,
|
|
2028
2059
|
S: this,
|
|
2029
2060
|
C: (f, a) => f(...a)
|
|
2030
2061
|
});
|
|
@@ -2034,7 +2065,7 @@ var Space = class Space2 {
|
|
|
2034
2065
|
key: this._key
|
|
2035
2066
|
}, {
|
|
2036
2067
|
F: __dxlog_file11,
|
|
2037
|
-
L:
|
|
2068
|
+
L: 229,
|
|
2038
2069
|
S: this,
|
|
2039
2070
|
C: (f, a) => f(...a)
|
|
2040
2071
|
});
|
|
@@ -2048,7 +2079,7 @@ var Space = class Space2 {
|
|
|
2048
2079
|
this._isOpen = false;
|
|
2049
2080
|
log10("closed", void 0, {
|
|
2050
2081
|
F: __dxlog_file11,
|
|
2051
|
-
L:
|
|
2082
|
+
L: 242,
|
|
2052
2083
|
S: this,
|
|
2053
2084
|
C: (f, a) => f(...a)
|
|
2054
2085
|
});
|
|
@@ -2056,13 +2087,13 @@ var Space = class Space2 {
|
|
|
2056
2087
|
async initializeDataPipeline() {
|
|
2057
2088
|
log10("initializeDataPipeline", void 0, {
|
|
2058
2089
|
F: __dxlog_file11,
|
|
2059
|
-
L:
|
|
2090
|
+
L: 247,
|
|
2060
2091
|
S: this,
|
|
2061
2092
|
C: (f, a) => f(...a)
|
|
2062
2093
|
});
|
|
2063
2094
|
invariant9(this._isOpen, "Space must be open to initialize data pipeline.", {
|
|
2064
2095
|
F: __dxlog_file11,
|
|
2065
|
-
L:
|
|
2096
|
+
L: 248,
|
|
2066
2097
|
S: this,
|
|
2067
2098
|
A: [
|
|
2068
2099
|
"this._isOpen",
|
|
@@ -2072,20 +2103,23 @@ var Space = class Space2 {
|
|
|
2072
2103
|
await this._dataPipeline.open();
|
|
2073
2104
|
}
|
|
2074
2105
|
};
|
|
2075
|
-
|
|
2076
|
-
logInfo
|
|
2106
|
+
_ts_decorate7([
|
|
2107
|
+
logInfo,
|
|
2108
|
+
trace3.info()
|
|
2077
2109
|
], Space.prototype, "key", null);
|
|
2078
|
-
|
|
2079
|
-
synchronized4
|
|
2110
|
+
_ts_decorate7([
|
|
2111
|
+
synchronized4,
|
|
2112
|
+
trace3.span()
|
|
2080
2113
|
], Space.prototype, "open", null);
|
|
2081
|
-
|
|
2114
|
+
_ts_decorate7([
|
|
2082
2115
|
synchronized4
|
|
2083
2116
|
], Space.prototype, "close", null);
|
|
2084
|
-
|
|
2117
|
+
_ts_decorate7([
|
|
2085
2118
|
synchronized4
|
|
2086
2119
|
], Space.prototype, "initializeDataPipeline", null);
|
|
2087
|
-
Space =
|
|
2088
|
-
trackLeaks3("open", "close")
|
|
2120
|
+
Space = _ts_decorate7([
|
|
2121
|
+
trackLeaks3("open", "close"),
|
|
2122
|
+
trace3.resource()
|
|
2089
2123
|
], Space);
|
|
2090
2124
|
|
|
2091
2125
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
@@ -2097,7 +2131,7 @@ import { Teleport } from "@dxos/teleport";
|
|
|
2097
2131
|
import { BlobSync } from "@dxos/teleport-extension-object-sync";
|
|
2098
2132
|
import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
|
|
2099
2133
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
2100
|
-
function
|
|
2134
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
2101
2135
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2102
2136
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2103
2137
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2138,7 +2172,7 @@ var SpaceProtocol = class {
|
|
|
2138
2172
|
key: feed.key
|
|
2139
2173
|
}, {
|
|
2140
2174
|
F: __dxlog_file12,
|
|
2141
|
-
L:
|
|
2175
|
+
L: 96,
|
|
2142
2176
|
S: this,
|
|
2143
2177
|
C: (f, a) => f(...a)
|
|
2144
2178
|
});
|
|
@@ -2147,6 +2181,7 @@ var SpaceProtocol = class {
|
|
|
2147
2181
|
session.replicator.addFeed(feed);
|
|
2148
2182
|
}
|
|
2149
2183
|
}
|
|
2184
|
+
// TODO(burdon): Rename open? Common open/close interfaces for all services?
|
|
2150
2185
|
async start() {
|
|
2151
2186
|
if (this._connection) {
|
|
2152
2187
|
return;
|
|
@@ -2160,7 +2195,7 @@ var SpaceProtocol = class {
|
|
|
2160
2195
|
await this.blobSync.open();
|
|
2161
2196
|
log11("starting...", void 0, {
|
|
2162
2197
|
F: __dxlog_file12,
|
|
2163
|
-
L:
|
|
2198
|
+
L: 122,
|
|
2164
2199
|
S: this,
|
|
2165
2200
|
C: (f, a) => f(...a)
|
|
2166
2201
|
});
|
|
@@ -2170,11 +2205,11 @@ var SpaceProtocol = class {
|
|
|
2170
2205
|
peerId: this._swarmIdentity.peerKey,
|
|
2171
2206
|
topic,
|
|
2172
2207
|
topology: new MMSTTopology(topologyConfig),
|
|
2173
|
-
label: `
|
|
2208
|
+
label: `space swarm ${topic.truncate()}`
|
|
2174
2209
|
});
|
|
2175
2210
|
log11("started", void 0, {
|
|
2176
2211
|
F: __dxlog_file12,
|
|
2177
|
-
L:
|
|
2212
|
+
L: 132,
|
|
2178
2213
|
S: this,
|
|
2179
2214
|
C: (f, a) => f(...a)
|
|
2180
2215
|
});
|
|
@@ -2184,14 +2219,14 @@ var SpaceProtocol = class {
|
|
|
2184
2219
|
if (this._connection) {
|
|
2185
2220
|
log11("stopping...", void 0, {
|
|
2186
2221
|
F: __dxlog_file12,
|
|
2187
|
-
L:
|
|
2222
|
+
L: 139,
|
|
2188
2223
|
S: this,
|
|
2189
2224
|
C: (f, a) => f(...a)
|
|
2190
2225
|
});
|
|
2191
2226
|
await this._connection.close();
|
|
2192
2227
|
log11("stopped", void 0, {
|
|
2193
2228
|
F: __dxlog_file12,
|
|
2194
|
-
L:
|
|
2229
|
+
L: 141,
|
|
2195
2230
|
S: this,
|
|
2196
2231
|
C: (f, a) => f(...a)
|
|
2197
2232
|
});
|
|
@@ -2214,10 +2249,10 @@ var SpaceProtocol = class {
|
|
|
2214
2249
|
};
|
|
2215
2250
|
}
|
|
2216
2251
|
};
|
|
2217
|
-
|
|
2252
|
+
_ts_decorate8([
|
|
2218
2253
|
logInfo2
|
|
2219
2254
|
], SpaceProtocol.prototype, "_topic", void 0);
|
|
2220
|
-
|
|
2255
|
+
_ts_decorate8([
|
|
2221
2256
|
logInfo2
|
|
2222
2257
|
], SpaceProtocol.prototype, "_ownPeerKey", null);
|
|
2223
2258
|
var AuthStatus;
|
|
@@ -2256,20 +2291,18 @@ var SpaceProtocolSession = class {
|
|
|
2256
2291
|
provider: this._swarmIdentity.credentialProvider,
|
|
2257
2292
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
2258
2293
|
onAuthSuccess: () => {
|
|
2259
|
-
var _a;
|
|
2260
2294
|
log11("Peer authenticated", void 0, {
|
|
2261
2295
|
F: __dxlog_file12,
|
|
2262
|
-
L:
|
|
2296
|
+
L: 238,
|
|
2263
2297
|
S: this,
|
|
2264
2298
|
C: (f, a) => f(...a)
|
|
2265
2299
|
});
|
|
2266
2300
|
this._authStatus = AuthStatus.SUCCESS;
|
|
2267
|
-
|
|
2301
|
+
this._onSessionAuth?.(this._teleport);
|
|
2268
2302
|
},
|
|
2269
2303
|
onAuthFailure: () => {
|
|
2270
|
-
var _a;
|
|
2271
2304
|
this._authStatus = AuthStatus.FAILURE;
|
|
2272
|
-
|
|
2305
|
+
this._onAuthFailure?.(this._teleport);
|
|
2273
2306
|
}
|
|
2274
2307
|
}));
|
|
2275
2308
|
this._teleport.addExtension("dxos.mesh.teleport.replicator", this.replicator);
|
|
@@ -2279,10 +2312,10 @@ var SpaceProtocolSession = class {
|
|
|
2279
2312
|
await this._teleport.close();
|
|
2280
2313
|
}
|
|
2281
2314
|
};
|
|
2282
|
-
|
|
2315
|
+
_ts_decorate8([
|
|
2283
2316
|
logInfo2
|
|
2284
2317
|
], SpaceProtocolSession.prototype, "_wireParams", void 0);
|
|
2285
|
-
|
|
2318
|
+
_ts_decorate8([
|
|
2286
2319
|
logInfo2
|
|
2287
2320
|
], SpaceProtocolSession.prototype, "authStatus", null);
|
|
2288
2321
|
|
|
@@ -2291,9 +2324,9 @@ import { synchronized as synchronized5, trackLeaks as trackLeaks4 } from "@dxos/
|
|
|
2291
2324
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
2292
2325
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2293
2326
|
import { log as log12 } from "@dxos/log";
|
|
2294
|
-
import { trace } from "@dxos/protocols";
|
|
2327
|
+
import { trace as trace4 } from "@dxos/protocols";
|
|
2295
2328
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
2296
|
-
function
|
|
2329
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
2297
2330
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2298
2331
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2299
2332
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2327,8 +2360,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2327
2360
|
].map((space) => space.close()));
|
|
2328
2361
|
}
|
|
2329
2362
|
async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
|
|
2330
|
-
|
|
2331
|
-
log12.trace("dxos.echo.space-manager.construct-space", trace.begin({
|
|
2363
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace4.begin({
|
|
2332
2364
|
id: this._instanceId
|
|
2333
2365
|
}), {
|
|
2334
2366
|
F: __dxlog_file13,
|
|
@@ -2344,7 +2376,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2344
2376
|
S: this,
|
|
2345
2377
|
C: (f, a) => f(...a)
|
|
2346
2378
|
});
|
|
2347
|
-
const genesisFeed = await this._feedStore.openFeed(
|
|
2379
|
+
const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? failUndefined2());
|
|
2348
2380
|
const spaceKey = metadata.key;
|
|
2349
2381
|
const protocol = new SpaceProtocol({
|
|
2350
2382
|
topic: spaceKey,
|
|
@@ -2366,24 +2398,24 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2366
2398
|
memberKey
|
|
2367
2399
|
});
|
|
2368
2400
|
this._spaces.set(space.key, space);
|
|
2369
|
-
log12.trace("dxos.echo.space-manager.construct-space",
|
|
2401
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace4.end({
|
|
2370
2402
|
id: this._instanceId
|
|
2371
2403
|
}), {
|
|
2372
2404
|
F: __dxlog_file13,
|
|
2373
|
-
L:
|
|
2405
|
+
L: 126,
|
|
2374
2406
|
S: this,
|
|
2375
2407
|
C: (f, a) => f(...a)
|
|
2376
2408
|
});
|
|
2377
2409
|
return space;
|
|
2378
2410
|
}
|
|
2379
2411
|
};
|
|
2380
|
-
|
|
2412
|
+
_ts_decorate9([
|
|
2381
2413
|
synchronized5
|
|
2382
2414
|
], SpaceManager.prototype, "open", null);
|
|
2383
|
-
|
|
2415
|
+
_ts_decorate9([
|
|
2384
2416
|
synchronized5
|
|
2385
2417
|
], SpaceManager.prototype, "close", null);
|
|
2386
|
-
SpaceManager =
|
|
2418
|
+
SpaceManager = _ts_decorate9([
|
|
2387
2419
|
trackLeaks4("open", "close")
|
|
2388
2420
|
], SpaceManager);
|
|
2389
2421
|
|
|
@@ -2413,4 +2445,4 @@ export {
|
|
|
2413
2445
|
SpaceProtocolSession,
|
|
2414
2446
|
SpaceManager
|
|
2415
2447
|
};
|
|
2416
|
-
//# sourceMappingURL=chunk-
|
|
2448
|
+
//# sourceMappingURL=chunk-GDF4DQU2.mjs.map
|