@dxos/echo-pipeline 0.1.56-main.01afb72 → 0.1.56-main.0e9f69e
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-7S5RJM3K.mjs → chunk-FCDYN74V.mjs} +279 -241
- package/dist/lib/browser/chunk-FCDYN74V.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 +12 -17
- package/dist/lib/browser/testing/index.mjs.map +1 -1
- package/dist/lib/node/index.cjs +287 -249
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +300 -267
- 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.d.ts +1 -1
- 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.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/package.json +32 -32
- package/src/db-host/data-service-host.ts +8 -1
- package/src/db-host/snapshot-manager.ts +0 -2
- package/src/metadata/metadata-store.ts +1 -1
- package/src/pipeline/pipeline.test.ts +42 -9
- package/src/pipeline/pipeline.ts +35 -12
- package/src/space/control-pipeline.ts +47 -22
- package/src/space/data-pipeline.ts +15 -2
- package/src/space/space.ts +1 -0
- package/src/testing/database-test-rig.ts +27 -2
- package/src/tests/database-unit.test.ts +39 -0
- package/dist/lib/browser/chunk-7S5RJM3K.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",
|
|
@@ -83,7 +91,7 @@ var DataServiceHost = class {
|
|
|
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
|
|
@@ -735,7 +725,7 @@ import { invariant as invariant6 } from "@dxos/invariant";
|
|
|
735
725
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
736
726
|
import { log as log6 } from "@dxos/log";
|
|
737
727
|
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
738
|
-
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
728
|
+
import { ComplexMap as ComplexMap3, getPrototypeSpecificInstanceId } from "@dxos/util";
|
|
739
729
|
|
|
740
730
|
// packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
|
|
741
731
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
@@ -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
|
}),
|
|
@@ -889,7 +878,7 @@ var Pipeline = class {
|
|
|
889
878
|
this._pauseTrigger = new Trigger().wake();
|
|
890
879
|
this._isStopping = false;
|
|
891
880
|
this._isStarted = false;
|
|
892
|
-
this.
|
|
881
|
+
this._isBeingConsumed = false;
|
|
893
882
|
this._isPaused = false;
|
|
894
883
|
}
|
|
895
884
|
get state() {
|
|
@@ -920,12 +909,14 @@ var Pipeline = class {
|
|
|
920
909
|
if (this._feedSetIterator) {
|
|
921
910
|
await this._feedSetIterator.addFeed(feed);
|
|
922
911
|
}
|
|
923
|
-
this.
|
|
912
|
+
if (this._isStarted && !this._isPaused) {
|
|
913
|
+
this._setFeedDownloadState(feed);
|
|
914
|
+
}
|
|
924
915
|
}
|
|
925
916
|
setWriteFeed(feed) {
|
|
926
917
|
invariant6(!this._writer, "Writer already set.", {
|
|
927
918
|
F: __dxlog_file7,
|
|
928
|
-
L:
|
|
919
|
+
L: 257,
|
|
929
920
|
S: this,
|
|
930
921
|
A: [
|
|
931
922
|
"!this._writer",
|
|
@@ -934,7 +925,7 @@ var Pipeline = class {
|
|
|
934
925
|
});
|
|
935
926
|
invariant6(feed.properties.writable, "Feed must be writable.", {
|
|
936
927
|
F: __dxlog_file7,
|
|
937
|
-
L:
|
|
928
|
+
L: 258,
|
|
938
929
|
S: this,
|
|
939
930
|
A: [
|
|
940
931
|
"feed.properties.writable",
|
|
@@ -947,9 +938,18 @@ var Pipeline = class {
|
|
|
947
938
|
}), feed.createFeedWriter());
|
|
948
939
|
}
|
|
949
940
|
async start() {
|
|
941
|
+
invariant6(!this._isStarted, "Pipeline is already started.", {
|
|
942
|
+
F: __dxlog_file7,
|
|
943
|
+
L: 271,
|
|
944
|
+
S: this,
|
|
945
|
+
A: [
|
|
946
|
+
"!this._isStarted",
|
|
947
|
+
"'Pipeline is already started.'"
|
|
948
|
+
]
|
|
949
|
+
});
|
|
950
950
|
log6("starting...", void 0, {
|
|
951
951
|
F: __dxlog_file7,
|
|
952
|
-
L:
|
|
952
|
+
L: 272,
|
|
953
953
|
S: this,
|
|
954
954
|
C: (f, a) => f(...a)
|
|
955
955
|
});
|
|
@@ -958,21 +958,25 @@ var Pipeline = class {
|
|
|
958
958
|
this._isStarted = true;
|
|
959
959
|
log6("started", void 0, {
|
|
960
960
|
F: __dxlog_file7,
|
|
961
|
-
L:
|
|
961
|
+
L: 276,
|
|
962
962
|
S: this,
|
|
963
963
|
C: (f, a) => f(...a)
|
|
964
964
|
});
|
|
965
|
+
if (!this._isPaused) {
|
|
966
|
+
for (const feed of this._feeds.values()) {
|
|
967
|
+
this._setFeedDownloadState(feed);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
965
970
|
}
|
|
966
971
|
async stop() {
|
|
967
|
-
var _a;
|
|
968
972
|
log6("stopping...", void 0, {
|
|
969
973
|
F: __dxlog_file7,
|
|
970
|
-
L:
|
|
974
|
+
L: 287,
|
|
971
975
|
S: this,
|
|
972
976
|
C: (f, a) => f(...a)
|
|
973
977
|
});
|
|
974
978
|
this._isStopping = true;
|
|
975
|
-
await
|
|
979
|
+
await this._feedSetIterator?.close();
|
|
976
980
|
await this._processingTrigger.wait();
|
|
977
981
|
await this._state._ctx.dispose();
|
|
978
982
|
this._state._ctx = new Context2();
|
|
@@ -980,7 +984,7 @@ var Pipeline = class {
|
|
|
980
984
|
this._isStarted = false;
|
|
981
985
|
log6("stopped", void 0, {
|
|
982
986
|
F: __dxlog_file7,
|
|
983
|
-
L:
|
|
987
|
+
L: 295,
|
|
984
988
|
S: this,
|
|
985
989
|
C: (f, a) => f(...a)
|
|
986
990
|
});
|
|
@@ -992,7 +996,7 @@ var Pipeline = class {
|
|
|
992
996
|
async setCursor(timeframe) {
|
|
993
997
|
invariant6(!this._isStarted || this._isPaused, "Invalid state.", {
|
|
994
998
|
F: __dxlog_file7,
|
|
995
|
-
L:
|
|
999
|
+
L: 304,
|
|
996
1000
|
S: this,
|
|
997
1001
|
A: [
|
|
998
1002
|
"!this._isStarted || this._isPaused",
|
|
@@ -1001,9 +1005,6 @@ var Pipeline = class {
|
|
|
1001
1005
|
});
|
|
1002
1006
|
this._state._startTimeframe = timeframe;
|
|
1003
1007
|
this._timeframeClock.setTimeframe(timeframe);
|
|
1004
|
-
for (const feed of this._feeds.values()) {
|
|
1005
|
-
this._setFeedDownloadState(feed);
|
|
1006
|
-
}
|
|
1007
1008
|
if (this._feedSetIterator) {
|
|
1008
1009
|
await this._feedSetIterator.close();
|
|
1009
1010
|
await this._initIterator();
|
|
@@ -1014,15 +1015,6 @@ var Pipeline = class {
|
|
|
1014
1015
|
* Calling pause while processing will cause a deadlock.
|
|
1015
1016
|
*/
|
|
1016
1017
|
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
1018
|
if (this._isPaused) {
|
|
1027
1019
|
return;
|
|
1028
1020
|
}
|
|
@@ -1031,18 +1023,9 @@ var Pipeline = class {
|
|
|
1031
1023
|
this._isPaused = true;
|
|
1032
1024
|
}
|
|
1033
1025
|
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
1026
|
invariant6(this._isPaused, "Pipeline is not paused.", {
|
|
1044
1027
|
F: __dxlog_file7,
|
|
1045
|
-
L:
|
|
1028
|
+
L: 334,
|
|
1046
1029
|
S: this,
|
|
1047
1030
|
A: [
|
|
1048
1031
|
"this._isPaused",
|
|
@@ -1051,25 +1034,28 @@ var Pipeline = class {
|
|
|
1051
1034
|
});
|
|
1052
1035
|
this._pauseTrigger.wake();
|
|
1053
1036
|
this._isPaused = false;
|
|
1037
|
+
for (const feed of this._feeds.values()) {
|
|
1038
|
+
this._setFeedDownloadState(feed);
|
|
1039
|
+
}
|
|
1054
1040
|
}
|
|
1055
1041
|
/**
|
|
1056
1042
|
* Starts to iterate over the ordered messages from the added feeds.
|
|
1057
1043
|
* Updates the timeframe clock after the message has bee processed.
|
|
1058
1044
|
*/
|
|
1059
1045
|
async *consume() {
|
|
1060
|
-
invariant6(!this.
|
|
1046
|
+
invariant6(!this._isBeingConsumed, "Pipeline is already being consumed.", {
|
|
1061
1047
|
F: __dxlog_file7,
|
|
1062
|
-
L:
|
|
1048
|
+
L: 349,
|
|
1063
1049
|
S: this,
|
|
1064
1050
|
A: [
|
|
1065
|
-
"!this.
|
|
1051
|
+
"!this._isBeingConsumed",
|
|
1066
1052
|
"'Pipeline is already being consumed.'"
|
|
1067
1053
|
]
|
|
1068
1054
|
});
|
|
1069
|
-
this.
|
|
1055
|
+
this._isBeingConsumed = true;
|
|
1070
1056
|
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1071
1057
|
F: __dxlog_file7,
|
|
1072
|
-
L:
|
|
1058
|
+
L: 352,
|
|
1073
1059
|
S: this,
|
|
1074
1060
|
A: [
|
|
1075
1061
|
"this._feedSetIterator",
|
|
@@ -1083,7 +1069,7 @@ var Pipeline = class {
|
|
|
1083
1069
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
1084
1070
|
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1085
1071
|
F: __dxlog_file7,
|
|
1086
|
-
L:
|
|
1072
|
+
L: 361,
|
|
1087
1073
|
S: this,
|
|
1088
1074
|
A: [
|
|
1089
1075
|
"this._feedSetIterator",
|
|
@@ -1095,7 +1081,7 @@ var Pipeline = class {
|
|
|
1095
1081
|
}
|
|
1096
1082
|
const { done, value } = await iterable.next();
|
|
1097
1083
|
if (!done) {
|
|
1098
|
-
const block = value
|
|
1084
|
+
const block = value ?? failUndefined();
|
|
1099
1085
|
this._processingTrigger.reset();
|
|
1100
1086
|
this._timeframeClock.updatePendingTimeframe(PublicKey3.from(block.feedKey), block.seq);
|
|
1101
1087
|
yield block;
|
|
@@ -1103,16 +1089,31 @@ var Pipeline = class {
|
|
|
1103
1089
|
this._timeframeClock.updateTimeframe();
|
|
1104
1090
|
}
|
|
1105
1091
|
}
|
|
1106
|
-
this.
|
|
1092
|
+
this._isBeingConsumed = false;
|
|
1107
1093
|
}
|
|
1108
1094
|
_setFeedDownloadState(feed) {
|
|
1109
|
-
var _a;
|
|
1110
1095
|
const timeframe = this._state._startTimeframe;
|
|
1111
|
-
const seq =
|
|
1096
|
+
const seq = timeframe.get(feed.key) ?? -1;
|
|
1097
|
+
log6("setFeedDownloadState", {
|
|
1098
|
+
feed: feed.key,
|
|
1099
|
+
feedInstance: getPrototypeSpecificInstanceId(feed),
|
|
1100
|
+
seq,
|
|
1101
|
+
isBeingConsumed: this._isBeingConsumed,
|
|
1102
|
+
isStarted: this._isStarted,
|
|
1103
|
+
isPaused: this._isPaused
|
|
1104
|
+
}, {
|
|
1105
|
+
F: __dxlog_file7,
|
|
1106
|
+
L: 386,
|
|
1107
|
+
S: this,
|
|
1108
|
+
C: (f, a) => f(...a)
|
|
1109
|
+
});
|
|
1110
|
+
if (!this._isStarted || this._isPaused) {
|
|
1111
|
+
console.log(new Error().stack);
|
|
1112
|
+
}
|
|
1112
1113
|
feed.undownload({
|
|
1113
1114
|
callback: () => log6("undownload", void 0, {
|
|
1114
1115
|
F: __dxlog_file7,
|
|
1115
|
-
L:
|
|
1116
|
+
L: 398,
|
|
1116
1117
|
S: this,
|
|
1117
1118
|
C: (f, a) => f(...a)
|
|
1118
1119
|
})
|
|
@@ -1125,7 +1126,7 @@ var Pipeline = class {
|
|
|
1125
1126
|
err
|
|
1126
1127
|
}, {
|
|
1127
1128
|
F: __dxlog_file7,
|
|
1128
|
-
L:
|
|
1129
|
+
L: 400,
|
|
1129
1130
|
S: this,
|
|
1130
1131
|
C: (f, a) => f(...a)
|
|
1131
1132
|
});
|
|
@@ -1139,7 +1140,7 @@ var Pipeline = class {
|
|
|
1139
1140
|
this._feedSetIterator.stalled.on((iterator) => {
|
|
1140
1141
|
log6.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
|
|
1141
1142
|
F: __dxlog_file7,
|
|
1142
|
-
L:
|
|
1143
|
+
L: 411,
|
|
1143
1144
|
S: this,
|
|
1144
1145
|
C: (f, a) => f(...a)
|
|
1145
1146
|
});
|
|
@@ -1231,7 +1232,7 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1231
1232
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
1232
1233
|
challenge
|
|
1233
1234
|
});
|
|
1234
|
-
invariant7(
|
|
1235
|
+
invariant7(credential?.length > 0, "invalid credential", {
|
|
1235
1236
|
F: __dxlog_file8,
|
|
1236
1237
|
L: 69,
|
|
1237
1238
|
S: this,
|
|
@@ -1278,6 +1279,7 @@ import { CancelledError } from "@dxos/errors";
|
|
|
1278
1279
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
1279
1280
|
import { log as log8 } from "@dxos/log";
|
|
1280
1281
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
1282
|
+
import { TimeSeriesCounter, TimeUsageCounter, trace } from "@dxos/tracing";
|
|
1281
1283
|
import { tracer } from "@dxos/util";
|
|
1282
1284
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
1283
1285
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1304,6 +1306,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1304
1306
|
this._lastTimeframeSaveTime = 0;
|
|
1305
1307
|
this._lastSnapshotSaveTime = 0;
|
|
1306
1308
|
this._lastProcessedEpoch = -1;
|
|
1309
|
+
this._usage = new TimeUsageCounter();
|
|
1310
|
+
this._mutations = new TimeSeriesCounter();
|
|
1307
1311
|
this.currentEpoch = void 0;
|
|
1308
1312
|
this.appliedEpoch = void 0;
|
|
1309
1313
|
this.onNewEpoch = new Event4();
|
|
@@ -1315,13 +1319,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1315
1319
|
return this._pipeline;
|
|
1316
1320
|
}
|
|
1317
1321
|
get pipelineState() {
|
|
1318
|
-
|
|
1319
|
-
return (_a = this._pipeline) == null ? void 0 : _a.state;
|
|
1322
|
+
return this._pipeline?.state;
|
|
1320
1323
|
}
|
|
1321
1324
|
setTargetTimeframe(timeframe) {
|
|
1322
|
-
var _a;
|
|
1323
1325
|
this._targetTimeframe = timeframe;
|
|
1324
|
-
|
|
1326
|
+
this._pipeline?.state.setTargetTimeframe(timeframe);
|
|
1325
1327
|
}
|
|
1326
1328
|
async processCredential(credential) {
|
|
1327
1329
|
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
@@ -1338,8 +1340,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1338
1340
|
}
|
|
1339
1341
|
this._pipeline = new Pipeline();
|
|
1340
1342
|
await this._params.onPipelineCreated(this._pipeline);
|
|
1341
|
-
await this._pipeline.start();
|
|
1342
1343
|
await this._pipeline.pause();
|
|
1344
|
+
await this._pipeline.start();
|
|
1343
1345
|
if (this._targetTimeframe) {
|
|
1344
1346
|
this._pipeline.state.setTargetTimeframe(this._targetTimeframe);
|
|
1345
1347
|
}
|
|
@@ -1347,7 +1349,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1347
1349
|
write: (data, options) => {
|
|
1348
1350
|
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1349
1351
|
F: __dxlog_file9,
|
|
1350
|
-
L:
|
|
1352
|
+
L: 154,
|
|
1351
1353
|
S: this,
|
|
1352
1354
|
A: [
|
|
1353
1355
|
"this._pipeline",
|
|
@@ -1356,7 +1358,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1356
1358
|
});
|
|
1357
1359
|
invariant8(this.currentEpoch, "Epoch is not initialized.", {
|
|
1358
1360
|
F: __dxlog_file9,
|
|
1359
|
-
L:
|
|
1361
|
+
L: 155,
|
|
1360
1362
|
S: this,
|
|
1361
1363
|
A: [
|
|
1362
1364
|
"this.currentEpoch",
|
|
@@ -1377,19 +1379,18 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1377
1379
|
this._isOpen = true;
|
|
1378
1380
|
}
|
|
1379
1381
|
async close() {
|
|
1380
|
-
var _a, _b, _c;
|
|
1381
1382
|
if (!this._isOpen) {
|
|
1382
1383
|
return;
|
|
1383
1384
|
}
|
|
1384
1385
|
log8("close", void 0, {
|
|
1385
1386
|
F: __dxlog_file9,
|
|
1386
|
-
L:
|
|
1387
|
+
L: 179,
|
|
1387
1388
|
S: this,
|
|
1388
1389
|
C: (f, a) => f(...a)
|
|
1389
1390
|
});
|
|
1390
1391
|
this._isOpen = false;
|
|
1391
1392
|
await this._ctx.dispose();
|
|
1392
|
-
await
|
|
1393
|
+
await this._pipeline?.stop();
|
|
1393
1394
|
try {
|
|
1394
1395
|
await this._saveCache();
|
|
1395
1396
|
if (this._pipeline) {
|
|
@@ -1398,13 +1399,13 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1398
1399
|
} catch (err) {
|
|
1399
1400
|
log8.catch(err, void 0, {
|
|
1400
1401
|
F: __dxlog_file9,
|
|
1401
|
-
L:
|
|
1402
|
+
L: 192,
|
|
1402
1403
|
S: this,
|
|
1403
1404
|
C: (f, a) => f(...a)
|
|
1404
1405
|
});
|
|
1405
1406
|
}
|
|
1406
|
-
await
|
|
1407
|
-
await
|
|
1407
|
+
await this.databaseHost?.close();
|
|
1408
|
+
await this.itemManager?.destroy();
|
|
1408
1409
|
this._ctx = new Context4();
|
|
1409
1410
|
this._pipeline = void 0;
|
|
1410
1411
|
this._targetTimeframe = void 0;
|
|
@@ -1422,7 +1423,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1422
1423
|
}
|
|
1423
1424
|
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1424
1425
|
F: __dxlog_file9,
|
|
1425
|
-
L:
|
|
1426
|
+
L: 215,
|
|
1426
1427
|
S: this,
|
|
1427
1428
|
A: [
|
|
1428
1429
|
"this._pipeline",
|
|
@@ -1430,13 +1431,15 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1430
1431
|
]
|
|
1431
1432
|
});
|
|
1432
1433
|
for await (const msg of this._pipeline.consume()) {
|
|
1434
|
+
const span = this._usage.beginRecording();
|
|
1435
|
+
this._mutations.inc();
|
|
1433
1436
|
const { feedKey, seq, data } = msg;
|
|
1434
1437
|
log8("processing message", {
|
|
1435
1438
|
feedKey,
|
|
1436
1439
|
seq
|
|
1437
1440
|
}, {
|
|
1438
1441
|
F: __dxlog_file9,
|
|
1439
|
-
L:
|
|
1442
|
+
L: 221,
|
|
1440
1443
|
S: this,
|
|
1441
1444
|
C: (f, a) => f(...a)
|
|
1442
1445
|
});
|
|
@@ -1448,7 +1451,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1448
1451
|
feedKey
|
|
1449
1452
|
}, {
|
|
1450
1453
|
F: __dxlog_file9,
|
|
1451
|
-
L:
|
|
1454
|
+
L: 227,
|
|
1452
1455
|
S: this,
|
|
1453
1456
|
C: (f, a) => f(...a)
|
|
1454
1457
|
});
|
|
@@ -1471,7 +1474,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1471
1474
|
spaceKey: this._params.spaceKey.toHex()
|
|
1472
1475
|
}, {
|
|
1473
1476
|
F: __dxlog_file9,
|
|
1474
|
-
L:
|
|
1477
|
+
L: 244,
|
|
1475
1478
|
S: this,
|
|
1476
1479
|
C: (f, a) => f(...a)
|
|
1477
1480
|
});
|
|
@@ -1480,17 +1483,18 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1480
1483
|
} catch (err) {
|
|
1481
1484
|
log8.catch(err, void 0, {
|
|
1482
1485
|
F: __dxlog_file9,
|
|
1483
|
-
L:
|
|
1486
|
+
L: 254,
|
|
1484
1487
|
S: this,
|
|
1485
1488
|
C: (f, a) => f(...a)
|
|
1486
1489
|
});
|
|
1487
1490
|
}
|
|
1491
|
+
span.end();
|
|
1488
1492
|
}
|
|
1489
1493
|
}
|
|
1490
1494
|
_createSnapshot() {
|
|
1491
1495
|
invariant8(this.databaseHost, "Database backend is not initialized.", {
|
|
1492
1496
|
F: __dxlog_file9,
|
|
1493
|
-
L:
|
|
1497
|
+
L: 262,
|
|
1494
1498
|
S: this,
|
|
1495
1499
|
A: [
|
|
1496
1500
|
"this.databaseHost",
|
|
@@ -1504,26 +1508,22 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1504
1508
|
};
|
|
1505
1509
|
}
|
|
1506
1510
|
async _saveTargetTimeframe(timeframe) {
|
|
1507
|
-
|
|
1508
|
-
const newTimeframe = Timeframe3.merge((_a = this._targetTimeframe) != null ? _a : new Timeframe3(), timeframe);
|
|
1511
|
+
const newTimeframe = Timeframe3.merge(this._targetTimeframe ?? new Timeframe3(), timeframe);
|
|
1509
1512
|
await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
|
|
1510
1513
|
this._targetTimeframe = newTimeframe;
|
|
1511
1514
|
}
|
|
1512
1515
|
async _saveCache() {
|
|
1513
|
-
var _a;
|
|
1514
1516
|
const cache = {};
|
|
1515
1517
|
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
|
-
});
|
|
1518
|
+
const propertiesItem = this.itemManager.items.find((item) => item.modelMeta?.type === "dxos:model/document" && // TODO(burdon): Document?
|
|
1519
|
+
(getStateMachineFromItem(item)?.snapshot()).type === "dxos.sdk.client.Properties");
|
|
1520
1520
|
if (propertiesItem) {
|
|
1521
|
-
cache.properties =
|
|
1521
|
+
cache.properties = getStateMachineFromItem(propertiesItem)?.snapshot();
|
|
1522
1522
|
}
|
|
1523
1523
|
} catch (err) {
|
|
1524
1524
|
log8.warn("Failed to cache properties", err, {
|
|
1525
1525
|
F: __dxlog_file9,
|
|
1526
|
-
L:
|
|
1526
|
+
L: 291,
|
|
1527
1527
|
S: this,
|
|
1528
1528
|
C: (f, a) => f(...a)
|
|
1529
1529
|
});
|
|
@@ -1540,24 +1540,23 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1540
1540
|
}
|
|
1541
1541
|
}
|
|
1542
1542
|
async _processEpochInSeparateTask(epoch) {
|
|
1543
|
-
var _a;
|
|
1544
1543
|
if (epoch.subject.assertion.number <= this._lastProcessedEpoch) {
|
|
1545
1544
|
return;
|
|
1546
1545
|
}
|
|
1547
|
-
await
|
|
1546
|
+
await this._epochCtx?.dispose();
|
|
1548
1547
|
const ctx = new Context4({
|
|
1549
1548
|
onError: (err) => {
|
|
1550
1549
|
if (err instanceof CancelledError) {
|
|
1551
1550
|
log8("Epoch processing cancelled.", void 0, {
|
|
1552
1551
|
F: __dxlog_file9,
|
|
1553
|
-
L:
|
|
1552
|
+
L: 323,
|
|
1554
1553
|
S: this,
|
|
1555
1554
|
C: (f, a) => f(...a)
|
|
1556
1555
|
});
|
|
1557
1556
|
} else {
|
|
1558
1557
|
log8.catch(err, void 0, {
|
|
1559
1558
|
F: __dxlog_file9,
|
|
1560
|
-
L:
|
|
1559
|
+
L: 325,
|
|
1561
1560
|
S: this,
|
|
1562
1561
|
C: (f, a) => f(...a)
|
|
1563
1562
|
});
|
|
@@ -1573,7 +1572,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1573
1572
|
epoch
|
|
1574
1573
|
}, {
|
|
1575
1574
|
F: __dxlog_file9,
|
|
1576
|
-
L:
|
|
1575
|
+
L: 335,
|
|
1577
1576
|
S: this,
|
|
1578
1577
|
C: (f, a) => f(...a)
|
|
1579
1578
|
});
|
|
@@ -1585,7 +1584,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1585
1584
|
async _processEpoch(ctx, epoch) {
|
|
1586
1585
|
invariant8(this._isOpen, "Space is closed.", {
|
|
1587
1586
|
F: __dxlog_file9,
|
|
1588
|
-
L:
|
|
1587
|
+
L: 345,
|
|
1589
1588
|
S: this,
|
|
1590
1589
|
A: [
|
|
1591
1590
|
"this._isOpen",
|
|
@@ -1594,7 +1593,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1594
1593
|
});
|
|
1595
1594
|
invariant8(this._pipeline, void 0, {
|
|
1596
1595
|
F: __dxlog_file9,
|
|
1597
|
-
L:
|
|
1596
|
+
L: 346,
|
|
1598
1597
|
S: this,
|
|
1599
1598
|
A: [
|
|
1600
1599
|
"this._pipeline",
|
|
@@ -1606,7 +1605,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1606
1605
|
epoch
|
|
1607
1606
|
}, {
|
|
1608
1607
|
F: __dxlog_file9,
|
|
1609
|
-
L:
|
|
1608
|
+
L: 349,
|
|
1610
1609
|
S: this,
|
|
1611
1610
|
C: (f, a) => f(...a)
|
|
1612
1611
|
});
|
|
@@ -1616,7 +1615,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1616
1615
|
}
|
|
1617
1616
|
log8("restarting pipeline for epoch", void 0, {
|
|
1618
1617
|
F: __dxlog_file9,
|
|
1619
|
-
L:
|
|
1618
|
+
L: 356,
|
|
1620
1619
|
S: this,
|
|
1621
1620
|
C: (f, a) => f(...a)
|
|
1622
1621
|
});
|
|
@@ -1627,7 +1626,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1627
1626
|
async waitUntilTimeframe(timeframe) {
|
|
1628
1627
|
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1629
1628
|
F: __dxlog_file9,
|
|
1630
|
-
L:
|
|
1629
|
+
L: 364,
|
|
1631
1630
|
S: this,
|
|
1632
1631
|
A: [
|
|
1633
1632
|
"this._pipeline",
|
|
@@ -1639,7 +1638,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1639
1638
|
async createEpoch() {
|
|
1640
1639
|
invariant8(this._pipeline, void 0, {
|
|
1641
1640
|
F: __dxlog_file9,
|
|
1642
|
-
L:
|
|
1641
|
+
L: 370,
|
|
1643
1642
|
S: this,
|
|
1644
1643
|
A: [
|
|
1645
1644
|
"this._pipeline",
|
|
@@ -1648,7 +1647,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1648
1647
|
});
|
|
1649
1648
|
invariant8(this.currentEpoch, void 0, {
|
|
1650
1649
|
F: __dxlog_file9,
|
|
1651
|
-
L:
|
|
1650
|
+
L: 371,
|
|
1652
1651
|
S: this,
|
|
1653
1652
|
A: [
|
|
1654
1653
|
"this.currentEpoch",
|
|
@@ -1671,6 +1670,12 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1671
1670
|
await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
|
|
1672
1671
|
}
|
|
1673
1672
|
};
|
|
1673
|
+
_ts_decorate5([
|
|
1674
|
+
trace.metricsCounter()
|
|
1675
|
+
], DataPipeline.prototype, "_usage", void 0);
|
|
1676
|
+
_ts_decorate5([
|
|
1677
|
+
trace.metricsCounter()
|
|
1678
|
+
], DataPipeline.prototype, "_mutations", void 0);
|
|
1674
1679
|
_ts_decorate5([
|
|
1675
1680
|
synchronized3
|
|
1676
1681
|
], DataPipeline.prototype, "open", null);
|
|
@@ -1684,7 +1689,8 @@ _ts_decorate5([
|
|
|
1684
1689
|
synchronized3
|
|
1685
1690
|
], DataPipeline.prototype, "createEpoch", null);
|
|
1686
1691
|
DataPipeline = _ts_decorate5([
|
|
1687
|
-
trackLeaks2("open", "close")
|
|
1692
|
+
trackLeaks2("open", "close"),
|
|
1693
|
+
trace.resource()
|
|
1688
1694
|
], DataPipeline);
|
|
1689
1695
|
|
|
1690
1696
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
@@ -1692,22 +1698,36 @@ import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeak
|
|
|
1692
1698
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
1693
1699
|
import { log as log10, logInfo } from "@dxos/log";
|
|
1694
1700
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1695
|
-
import { trace } from "@dxos/tracing";
|
|
1701
|
+
import { trace as trace3 } from "@dxos/tracing";
|
|
1696
1702
|
import { Callback as Callback2 } from "@dxos/util";
|
|
1697
1703
|
|
|
1698
1704
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
1705
|
+
import { Context as Context5 } from "@dxos/context";
|
|
1699
1706
|
import { SpaceStateMachine } from "@dxos/credentials";
|
|
1700
1707
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
1701
1708
|
import { log as log9 } from "@dxos/log";
|
|
1702
1709
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1703
1710
|
import { Timeframe as Timeframe4 } from "@dxos/timeframe";
|
|
1711
|
+
import { TimeSeriesCounter as TimeSeriesCounter2, TimeUsageCounter as TimeUsageCounter2, trace as trace2 } from "@dxos/tracing";
|
|
1704
1712
|
import { Callback, tracer as tracer2 } from "@dxos/util";
|
|
1713
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1714
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1715
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1716
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1717
|
+
else
|
|
1718
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
1719
|
+
if (d = decorators[i])
|
|
1720
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1721
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1722
|
+
}
|
|
1705
1723
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
1706
1724
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
1707
|
-
var ControlPipeline = class {
|
|
1725
|
+
var ControlPipeline = class ControlPipeline2 {
|
|
1708
1726
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1709
1727
|
this._lastTimeframeSaveTime = Date.now();
|
|
1710
1728
|
this.onFeedAdmitted = new Callback();
|
|
1729
|
+
this._usage = new TimeUsageCounter2();
|
|
1730
|
+
this._mutations = new TimeSeriesCounter2();
|
|
1711
1731
|
this._spaceKey = spaceKey;
|
|
1712
1732
|
this._metadata = metadataStore;
|
|
1713
1733
|
this._pipeline = new Pipeline();
|
|
@@ -1718,7 +1738,7 @@ var ControlPipeline = class {
|
|
|
1718
1738
|
key: info.key
|
|
1719
1739
|
}, {
|
|
1720
1740
|
F: __dxlog_file10,
|
|
1721
|
-
L:
|
|
1741
|
+
L: 61,
|
|
1722
1742
|
S: this,
|
|
1723
1743
|
C: (f, a) => f(...a)
|
|
1724
1744
|
});
|
|
@@ -1729,7 +1749,7 @@ var ControlPipeline = class {
|
|
|
1729
1749
|
} catch (err) {
|
|
1730
1750
|
log9.catch(err, void 0, {
|
|
1731
1751
|
F: __dxlog_file10,
|
|
1732
|
-
L:
|
|
1752
|
+
L: 69,
|
|
1733
1753
|
S: this,
|
|
1734
1754
|
C: (f, a) => f(...a)
|
|
1735
1755
|
});
|
|
@@ -1752,57 +1772,66 @@ var ControlPipeline = class {
|
|
|
1752
1772
|
async start() {
|
|
1753
1773
|
log9("starting...", void 0, {
|
|
1754
1774
|
F: __dxlog_file10,
|
|
1755
|
-
L:
|
|
1775
|
+
L: 93,
|
|
1756
1776
|
S: this,
|
|
1757
1777
|
C: (f, a) => f(...a)
|
|
1758
1778
|
});
|
|
1759
1779
|
setTimeout(async () => {
|
|
1760
|
-
|
|
1761
|
-
try {
|
|
1762
|
-
log9("processing", {
|
|
1763
|
-
key: msg.feedKey,
|
|
1764
|
-
seq: msg.seq
|
|
1765
|
-
}, {
|
|
1766
|
-
F: __dxlog_file10,
|
|
1767
|
-
L: 88,
|
|
1768
|
-
S: this,
|
|
1769
|
-
C: (f, a) => f(...a)
|
|
1770
|
-
});
|
|
1771
|
-
if (msg.data.payload.credential) {
|
|
1772
|
-
const timer = tracer2.mark("dxos.echo.pipeline.control");
|
|
1773
|
-
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
|
|
1774
|
-
timer.end();
|
|
1775
|
-
if (!result) {
|
|
1776
|
-
log9.warn("processing failed", {
|
|
1777
|
-
msg
|
|
1778
|
-
}, {
|
|
1779
|
-
F: __dxlog_file10,
|
|
1780
|
-
L: 98,
|
|
1781
|
-
S: this,
|
|
1782
|
-
C: (f, a) => f(...a)
|
|
1783
|
-
});
|
|
1784
|
-
} else {
|
|
1785
|
-
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1786
|
-
}
|
|
1787
|
-
}
|
|
1788
|
-
} catch (err) {
|
|
1789
|
-
log9.catch(err, void 0, {
|
|
1790
|
-
F: __dxlog_file10,
|
|
1791
|
-
L: 104,
|
|
1792
|
-
S: this,
|
|
1793
|
-
C: (f, a) => f(...a)
|
|
1794
|
-
});
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1780
|
+
void this._consumePipeline(new Context5());
|
|
1797
1781
|
});
|
|
1798
1782
|
await this._pipeline.start();
|
|
1799
1783
|
log9("started", void 0, {
|
|
1800
1784
|
F: __dxlog_file10,
|
|
1801
|
-
L:
|
|
1785
|
+
L: 99,
|
|
1802
1786
|
S: this,
|
|
1803
1787
|
C: (f, a) => f(...a)
|
|
1804
1788
|
});
|
|
1805
1789
|
}
|
|
1790
|
+
async _consumePipeline(ctx) {
|
|
1791
|
+
for await (const msg of this._pipeline.consume()) {
|
|
1792
|
+
const span = this._usage.beginRecording();
|
|
1793
|
+
this._mutations.inc();
|
|
1794
|
+
try {
|
|
1795
|
+
await this._processMessage(ctx, msg);
|
|
1796
|
+
} catch (err) {
|
|
1797
|
+
log9.catch(err, void 0, {
|
|
1798
|
+
F: __dxlog_file10,
|
|
1799
|
+
L: 111,
|
|
1800
|
+
S: this,
|
|
1801
|
+
C: (f, a) => f(...a)
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
span.end();
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
async _processMessage(ctx, msg) {
|
|
1808
|
+
log9("processing", {
|
|
1809
|
+
key: msg.feedKey,
|
|
1810
|
+
seq: msg.seq
|
|
1811
|
+
}, {
|
|
1812
|
+
F: __dxlog_file10,
|
|
1813
|
+
L: 121,
|
|
1814
|
+
S: this,
|
|
1815
|
+
C: (f, a) => f(...a)
|
|
1816
|
+
});
|
|
1817
|
+
if (msg.data.payload.credential) {
|
|
1818
|
+
const timer = tracer2.mark("dxos.echo.pipeline.control");
|
|
1819
|
+
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
|
|
1820
|
+
timer.end();
|
|
1821
|
+
if (!result) {
|
|
1822
|
+
log9.warn("processing failed", {
|
|
1823
|
+
msg
|
|
1824
|
+
}, {
|
|
1825
|
+
F: __dxlog_file10,
|
|
1826
|
+
L: 131,
|
|
1827
|
+
S: this,
|
|
1828
|
+
C: (f, a) => f(...a)
|
|
1829
|
+
});
|
|
1830
|
+
} else {
|
|
1831
|
+
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1806
1835
|
async _noteTargetStateIfNeeded(timeframe) {
|
|
1807
1836
|
if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2) {
|
|
1808
1837
|
this._lastTimeframeSaveTime = Date.now();
|
|
@@ -1812,7 +1841,7 @@ var ControlPipeline = class {
|
|
|
1812
1841
|
async stop() {
|
|
1813
1842
|
log9("stopping...", void 0, {
|
|
1814
1843
|
F: __dxlog_file10,
|
|
1815
|
-
L:
|
|
1844
|
+
L: 149,
|
|
1816
1845
|
S: this,
|
|
1817
1846
|
C: (f, a) => f(...a)
|
|
1818
1847
|
});
|
|
@@ -1820,30 +1849,44 @@ var ControlPipeline = class {
|
|
|
1820
1849
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1821
1850
|
log9("stopped", void 0, {
|
|
1822
1851
|
F: __dxlog_file10,
|
|
1823
|
-
L:
|
|
1852
|
+
L: 152,
|
|
1824
1853
|
S: this,
|
|
1825
1854
|
C: (f, a) => f(...a)
|
|
1826
1855
|
});
|
|
1827
1856
|
}
|
|
1828
1857
|
async _saveTargetTimeframe(timeframe) {
|
|
1829
|
-
var _a;
|
|
1830
1858
|
try {
|
|
1831
|
-
const newTimeframe = Timeframe4.merge(
|
|
1859
|
+
const newTimeframe = Timeframe4.merge(this._targetTimeframe ?? new Timeframe4(), timeframe);
|
|
1832
1860
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1833
1861
|
this._targetTimeframe = newTimeframe;
|
|
1834
1862
|
} catch (err) {
|
|
1835
1863
|
log9(err, void 0, {
|
|
1836
1864
|
F: __dxlog_file10,
|
|
1837
|
-
L:
|
|
1865
|
+
L: 161,
|
|
1838
1866
|
S: this,
|
|
1839
1867
|
C: (f, a) => f(...a)
|
|
1840
1868
|
});
|
|
1841
1869
|
}
|
|
1842
1870
|
}
|
|
1843
1871
|
};
|
|
1872
|
+
_ts_decorate6([
|
|
1873
|
+
trace2.metricsCounter()
|
|
1874
|
+
], ControlPipeline.prototype, "_usage", void 0);
|
|
1875
|
+
_ts_decorate6([
|
|
1876
|
+
trace2.metricsCounter()
|
|
1877
|
+
], ControlPipeline.prototype, "_mutations", void 0);
|
|
1878
|
+
_ts_decorate6([
|
|
1879
|
+
trace2.span()
|
|
1880
|
+
], ControlPipeline.prototype, "_consumePipeline", null);
|
|
1881
|
+
_ts_decorate6([
|
|
1882
|
+
trace2.span()
|
|
1883
|
+
], ControlPipeline.prototype, "_processMessage", null);
|
|
1884
|
+
ControlPipeline = _ts_decorate6([
|
|
1885
|
+
trace2.resource()
|
|
1886
|
+
], ControlPipeline);
|
|
1844
1887
|
|
|
1845
1888
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1846
|
-
function
|
|
1889
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1847
1890
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1848
1891
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1849
1892
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1946,12 +1989,10 @@ var Space = class Space2 {
|
|
|
1946
1989
|
return this._genesisFeedKey;
|
|
1947
1990
|
}
|
|
1948
1991
|
get controlFeedKey() {
|
|
1949
|
-
|
|
1950
|
-
return (_a = this._controlFeed) == null ? void 0 : _a.key;
|
|
1992
|
+
return this._controlFeed?.key;
|
|
1951
1993
|
}
|
|
1952
1994
|
get dataFeedKey() {
|
|
1953
|
-
|
|
1954
|
-
return (_a = this._dataFeed) == null ? void 0 : _a.key;
|
|
1995
|
+
return this._dataFeed?.key;
|
|
1955
1996
|
}
|
|
1956
1997
|
get spaceState() {
|
|
1957
1998
|
return this._controlPipeline.spaceState;
|
|
@@ -1971,7 +2012,7 @@ var Space = class Space2 {
|
|
|
1971
2012
|
setControlFeed(feed) {
|
|
1972
2013
|
invariant9(!this._controlFeed, "Control feed already set.", {
|
|
1973
2014
|
F: __dxlog_file11,
|
|
1974
|
-
L:
|
|
2015
|
+
L: 184,
|
|
1975
2016
|
S: this,
|
|
1976
2017
|
A: [
|
|
1977
2018
|
"!this._controlFeed",
|
|
@@ -1983,10 +2024,9 @@ var Space = class Space2 {
|
|
|
1983
2024
|
return this;
|
|
1984
2025
|
}
|
|
1985
2026
|
setDataFeed(feed) {
|
|
1986
|
-
var _a;
|
|
1987
2027
|
invariant9(!this._dataFeed, "Data feed already set.", {
|
|
1988
2028
|
F: __dxlog_file11,
|
|
1989
|
-
L:
|
|
2029
|
+
L: 191,
|
|
1990
2030
|
S: this,
|
|
1991
2031
|
A: [
|
|
1992
2032
|
"!this._dataFeed",
|
|
@@ -1994,7 +2034,7 @@ var Space = class Space2 {
|
|
|
1994
2034
|
]
|
|
1995
2035
|
});
|
|
1996
2036
|
this._dataFeed = feed;
|
|
1997
|
-
|
|
2037
|
+
this._dataPipeline.pipeline?.setWriteFeed(feed);
|
|
1998
2038
|
return this;
|
|
1999
2039
|
}
|
|
2000
2040
|
/**
|
|
@@ -2012,7 +2052,7 @@ var Space = class Space2 {
|
|
|
2012
2052
|
async open(ctx) {
|
|
2013
2053
|
log10("opening...", void 0, {
|
|
2014
2054
|
F: __dxlog_file11,
|
|
2015
|
-
L:
|
|
2055
|
+
L: 213,
|
|
2016
2056
|
S: this,
|
|
2017
2057
|
C: (f, a) => f(...a)
|
|
2018
2058
|
});
|
|
@@ -2025,7 +2065,7 @@ var Space = class Space2 {
|
|
|
2025
2065
|
this._isOpen = true;
|
|
2026
2066
|
log10("opened", void 0, {
|
|
2027
2067
|
F: __dxlog_file11,
|
|
2028
|
-
L:
|
|
2068
|
+
L: 224,
|
|
2029
2069
|
S: this,
|
|
2030
2070
|
C: (f, a) => f(...a)
|
|
2031
2071
|
});
|
|
@@ -2035,7 +2075,7 @@ var Space = class Space2 {
|
|
|
2035
2075
|
key: this._key
|
|
2036
2076
|
}, {
|
|
2037
2077
|
F: __dxlog_file11,
|
|
2038
|
-
L:
|
|
2078
|
+
L: 229,
|
|
2039
2079
|
S: this,
|
|
2040
2080
|
C: (f, a) => f(...a)
|
|
2041
2081
|
});
|
|
@@ -2049,7 +2089,7 @@ var Space = class Space2 {
|
|
|
2049
2089
|
this._isOpen = false;
|
|
2050
2090
|
log10("closed", void 0, {
|
|
2051
2091
|
F: __dxlog_file11,
|
|
2052
|
-
L:
|
|
2092
|
+
L: 242,
|
|
2053
2093
|
S: this,
|
|
2054
2094
|
C: (f, a) => f(...a)
|
|
2055
2095
|
});
|
|
@@ -2057,13 +2097,13 @@ var Space = class Space2 {
|
|
|
2057
2097
|
async initializeDataPipeline() {
|
|
2058
2098
|
log10("initializeDataPipeline", void 0, {
|
|
2059
2099
|
F: __dxlog_file11,
|
|
2060
|
-
L:
|
|
2100
|
+
L: 247,
|
|
2061
2101
|
S: this,
|
|
2062
2102
|
C: (f, a) => f(...a)
|
|
2063
2103
|
});
|
|
2064
2104
|
invariant9(this._isOpen, "Space must be open to initialize data pipeline.", {
|
|
2065
2105
|
F: __dxlog_file11,
|
|
2066
|
-
L:
|
|
2106
|
+
L: 248,
|
|
2067
2107
|
S: this,
|
|
2068
2108
|
A: [
|
|
2069
2109
|
"this._isOpen",
|
|
@@ -2073,22 +2113,23 @@ var Space = class Space2 {
|
|
|
2073
2113
|
await this._dataPipeline.open();
|
|
2074
2114
|
}
|
|
2075
2115
|
};
|
|
2076
|
-
|
|
2077
|
-
logInfo
|
|
2116
|
+
_ts_decorate7([
|
|
2117
|
+
logInfo,
|
|
2118
|
+
trace3.info()
|
|
2078
2119
|
], Space.prototype, "key", null);
|
|
2079
|
-
|
|
2120
|
+
_ts_decorate7([
|
|
2080
2121
|
synchronized4,
|
|
2081
|
-
|
|
2122
|
+
trace3.span()
|
|
2082
2123
|
], Space.prototype, "open", null);
|
|
2083
|
-
|
|
2124
|
+
_ts_decorate7([
|
|
2084
2125
|
synchronized4
|
|
2085
2126
|
], Space.prototype, "close", null);
|
|
2086
|
-
|
|
2127
|
+
_ts_decorate7([
|
|
2087
2128
|
synchronized4
|
|
2088
2129
|
], Space.prototype, "initializeDataPipeline", null);
|
|
2089
|
-
Space =
|
|
2130
|
+
Space = _ts_decorate7([
|
|
2090
2131
|
trackLeaks3("open", "close"),
|
|
2091
|
-
|
|
2132
|
+
trace3.resource()
|
|
2092
2133
|
], Space);
|
|
2093
2134
|
|
|
2094
2135
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
@@ -2100,7 +2141,7 @@ import { Teleport } from "@dxos/teleport";
|
|
|
2100
2141
|
import { BlobSync } from "@dxos/teleport-extension-object-sync";
|
|
2101
2142
|
import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
|
|
2102
2143
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
2103
|
-
function
|
|
2144
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
2104
2145
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2105
2146
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2106
2147
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2217,10 +2258,10 @@ var SpaceProtocol = class {
|
|
|
2217
2258
|
};
|
|
2218
2259
|
}
|
|
2219
2260
|
};
|
|
2220
|
-
|
|
2261
|
+
_ts_decorate8([
|
|
2221
2262
|
logInfo2
|
|
2222
2263
|
], SpaceProtocol.prototype, "_topic", void 0);
|
|
2223
|
-
|
|
2264
|
+
_ts_decorate8([
|
|
2224
2265
|
logInfo2
|
|
2225
2266
|
], SpaceProtocol.prototype, "_ownPeerKey", null);
|
|
2226
2267
|
var AuthStatus;
|
|
@@ -2259,7 +2300,6 @@ var SpaceProtocolSession = class {
|
|
|
2259
2300
|
provider: this._swarmIdentity.credentialProvider,
|
|
2260
2301
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
2261
2302
|
onAuthSuccess: () => {
|
|
2262
|
-
var _a;
|
|
2263
2303
|
log11("Peer authenticated", void 0, {
|
|
2264
2304
|
F: __dxlog_file12,
|
|
2265
2305
|
L: 236,
|
|
@@ -2267,12 +2307,11 @@ var SpaceProtocolSession = class {
|
|
|
2267
2307
|
C: (f, a) => f(...a)
|
|
2268
2308
|
});
|
|
2269
2309
|
this._authStatus = AuthStatus.SUCCESS;
|
|
2270
|
-
|
|
2310
|
+
this._onSessionAuth?.(this._teleport);
|
|
2271
2311
|
},
|
|
2272
2312
|
onAuthFailure: () => {
|
|
2273
|
-
var _a;
|
|
2274
2313
|
this._authStatus = AuthStatus.FAILURE;
|
|
2275
|
-
|
|
2314
|
+
this._onAuthFailure?.(this._teleport);
|
|
2276
2315
|
}
|
|
2277
2316
|
}));
|
|
2278
2317
|
this._teleport.addExtension("dxos.mesh.teleport.replicator", this.replicator);
|
|
@@ -2282,10 +2321,10 @@ var SpaceProtocolSession = class {
|
|
|
2282
2321
|
await this._teleport.close();
|
|
2283
2322
|
}
|
|
2284
2323
|
};
|
|
2285
|
-
|
|
2324
|
+
_ts_decorate8([
|
|
2286
2325
|
logInfo2
|
|
2287
2326
|
], SpaceProtocolSession.prototype, "_wireParams", void 0);
|
|
2288
|
-
|
|
2327
|
+
_ts_decorate8([
|
|
2289
2328
|
logInfo2
|
|
2290
2329
|
], SpaceProtocolSession.prototype, "authStatus", null);
|
|
2291
2330
|
|
|
@@ -2294,9 +2333,9 @@ import { synchronized as synchronized5, trackLeaks as trackLeaks4 } from "@dxos/
|
|
|
2294
2333
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
2295
2334
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2296
2335
|
import { log as log12 } from "@dxos/log";
|
|
2297
|
-
import { trace as
|
|
2336
|
+
import { trace as trace4 } from "@dxos/protocols";
|
|
2298
2337
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
2299
|
-
function
|
|
2338
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
2300
2339
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2301
2340
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2302
2341
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2330,8 +2369,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2330
2369
|
].map((space) => space.close()));
|
|
2331
2370
|
}
|
|
2332
2371
|
async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
|
|
2333
|
-
|
|
2334
|
-
log12.trace("dxos.echo.space-manager.construct-space", trace2.begin({
|
|
2372
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace4.begin({
|
|
2335
2373
|
id: this._instanceId
|
|
2336
2374
|
}), {
|
|
2337
2375
|
F: __dxlog_file13,
|
|
@@ -2347,7 +2385,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2347
2385
|
S: this,
|
|
2348
2386
|
C: (f, a) => f(...a)
|
|
2349
2387
|
});
|
|
2350
|
-
const genesisFeed = await this._feedStore.openFeed(
|
|
2388
|
+
const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? failUndefined2());
|
|
2351
2389
|
const spaceKey = metadata.key;
|
|
2352
2390
|
const protocol = new SpaceProtocol({
|
|
2353
2391
|
topic: spaceKey,
|
|
@@ -2369,7 +2407,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2369
2407
|
memberKey
|
|
2370
2408
|
});
|
|
2371
2409
|
this._spaces.set(space.key, space);
|
|
2372
|
-
log12.trace("dxos.echo.space-manager.construct-space",
|
|
2410
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace4.end({
|
|
2373
2411
|
id: this._instanceId
|
|
2374
2412
|
}), {
|
|
2375
2413
|
F: __dxlog_file13,
|
|
@@ -2380,13 +2418,13 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2380
2418
|
return space;
|
|
2381
2419
|
}
|
|
2382
2420
|
};
|
|
2383
|
-
|
|
2421
|
+
_ts_decorate9([
|
|
2384
2422
|
synchronized5
|
|
2385
2423
|
], SpaceManager.prototype, "open", null);
|
|
2386
|
-
|
|
2424
|
+
_ts_decorate9([
|
|
2387
2425
|
synchronized5
|
|
2388
2426
|
], SpaceManager.prototype, "close", null);
|
|
2389
|
-
SpaceManager =
|
|
2427
|
+
SpaceManager = _ts_decorate9([
|
|
2390
2428
|
trackLeaks4("open", "close")
|
|
2391
2429
|
], SpaceManager);
|
|
2392
2430
|
|
|
@@ -2416,4 +2454,4 @@ export {
|
|
|
2416
2454
|
SpaceProtocolSession,
|
|
2417
2455
|
SpaceManager
|
|
2418
2456
|
};
|
|
2419
|
-
//# sourceMappingURL=chunk-
|
|
2457
|
+
//# sourceMappingURL=chunk-FCDYN74V.mjs.map
|