@dxos/echo-pipeline 0.1.56-main.e47dfd1 → 0.1.56-main.e79d64a
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-7U2NXI2P.mjs → chunk-GDF4DQU2.mjs} +692 -355
- 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 +699 -362
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +696 -363
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/common/feeds.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service-host.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service.d.ts.map +1 -1
- package/dist/types/src/db-host/snapshot-manager.d.ts.map +1 -1
- package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
- package/dist/types/src/pipeline/message-selector.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/auth.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/common/feeds.ts +1 -2
- package/src/db-host/data-service-host.ts +10 -4
- package/src/db-host/data-service.ts +1 -2
- package/src/db-host/snapshot-manager.ts +0 -2
- package/src/metadata/metadata-store.ts +2 -2
- package/src/pipeline/message-selector.ts +1 -2
- package/src/pipeline/pipeline-stress.test.ts +226 -0
- package/src/pipeline/pipeline.test.ts +30 -206
- package/src/pipeline/pipeline.ts +50 -24
- package/src/space/auth.ts +1 -2
- package/src/space/control-pipeline.ts +47 -22
- package/src/space/data-pipeline.ts +21 -12
- package/src/space/space-manager.ts +1 -0
- package/src/space/space-protocol.ts +3 -1
- package/src/space/space.test.ts +18 -17
- package/src/space/space.ts +7 -3
- 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-7U2NXI2P.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -71,23 +71,41 @@ var codec = import_protocols.schema.getCodecForType("dxos.echo.feed.FeedMessage"
|
|
|
71
71
|
var valueEncoding = (0, import_hypercore.createCodecEncoding)(codec);
|
|
72
72
|
|
|
73
73
|
// packages/core/echo/echo-pipeline/src/common/feeds.ts
|
|
74
|
-
var
|
|
74
|
+
var import_invariant = require("@dxos/invariant");
|
|
75
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/common/feeds.ts";
|
|
75
76
|
var createMappedFeedWriter = (mapper, writer) => {
|
|
76
|
-
(0,
|
|
77
|
-
|
|
77
|
+
(0, import_invariant.invariant)(mapper, void 0, {
|
|
78
|
+
F: __dxlog_file,
|
|
79
|
+
L: 16,
|
|
80
|
+
S: void 0,
|
|
81
|
+
A: [
|
|
82
|
+
"mapper",
|
|
83
|
+
""
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
(0, import_invariant.invariant)(writer, void 0, {
|
|
87
|
+
F: __dxlog_file,
|
|
88
|
+
L: 17,
|
|
89
|
+
S: void 0,
|
|
90
|
+
A: [
|
|
91
|
+
"writer",
|
|
92
|
+
""
|
|
93
|
+
]
|
|
94
|
+
});
|
|
78
95
|
return {
|
|
79
96
|
write: async (data, options) => await writer.write(await mapper(data), options)
|
|
80
97
|
};
|
|
81
98
|
};
|
|
82
99
|
|
|
83
100
|
// packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts
|
|
84
|
-
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
85
101
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
86
102
|
var import_context = require("@dxos/context");
|
|
87
103
|
var import_echo_db = require("@dxos/echo-db");
|
|
104
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
88
105
|
var import_log = require("@dxos/log");
|
|
106
|
+
var import_service = require("@dxos/protocols/proto/dxos/echo/service");
|
|
89
107
|
var import_util = require("@dxos/util");
|
|
90
|
-
var
|
|
108
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
|
|
91
109
|
var DataServiceHost = class {
|
|
92
110
|
constructor(_itemManager, _itemDemuxer, _writeStream) {
|
|
93
111
|
this._itemManager = _itemManager;
|
|
@@ -113,16 +131,31 @@ var DataServiceHost = class {
|
|
|
113
131
|
objects
|
|
114
132
|
}
|
|
115
133
|
});
|
|
134
|
+
this._itemDemuxer.snapshot.on(ctx, (snapshot) => {
|
|
135
|
+
next({
|
|
136
|
+
action: import_service.EchoEvent.DatabaseAction.RESET,
|
|
137
|
+
batch: {
|
|
138
|
+
objects: snapshot.items
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
116
142
|
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
117
|
-
var _a;
|
|
118
143
|
const { batch, meta } = message;
|
|
119
|
-
(0,
|
|
144
|
+
(0, import_invariant2.invariant)(!meta.clientTag, "Unexpected client tag in mutation message", {
|
|
145
|
+
F: __dxlog_file2,
|
|
146
|
+
L: 68,
|
|
147
|
+
S: this,
|
|
148
|
+
A: [
|
|
149
|
+
"!(meta as any).clientTag",
|
|
150
|
+
"'Unexpected client tag in mutation message'"
|
|
151
|
+
]
|
|
152
|
+
});
|
|
120
153
|
(0, import_log.log)("message", {
|
|
121
|
-
batch,
|
|
154
|
+
batch: batch.objects?.length,
|
|
122
155
|
meta
|
|
123
156
|
}, {
|
|
124
|
-
F:
|
|
125
|
-
L:
|
|
157
|
+
F: __dxlog_file2,
|
|
158
|
+
L: 69,
|
|
126
159
|
S: this,
|
|
127
160
|
C: (f, a) => f(...a)
|
|
128
161
|
});
|
|
@@ -130,7 +163,7 @@ var DataServiceHost = class {
|
|
|
130
163
|
message.meta.feedKey,
|
|
131
164
|
message.meta.seq
|
|
132
165
|
]);
|
|
133
|
-
|
|
166
|
+
batch.objects?.forEach((object) => {
|
|
134
167
|
(0, import_echo_db.setMetadataOnObject)(object, {
|
|
135
168
|
...meta
|
|
136
169
|
});
|
|
@@ -148,15 +181,30 @@ var DataServiceHost = class {
|
|
|
148
181
|
});
|
|
149
182
|
}
|
|
150
183
|
async write(request) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
184
|
+
(0, import_invariant2.invariant)(!this._ctx.disposed, "Cannot write to closed DataServiceHost", {
|
|
185
|
+
F: __dxlog_file2,
|
|
186
|
+
L: 95,
|
|
187
|
+
S: this,
|
|
188
|
+
A: [
|
|
189
|
+
"!this._ctx.disposed",
|
|
190
|
+
"'Cannot write to closed DataServiceHost'"
|
|
191
|
+
]
|
|
192
|
+
});
|
|
193
|
+
(0, import_invariant2.invariant)(this._writeStream, "Cannot write mutations in readonly mode", {
|
|
194
|
+
F: __dxlog_file2,
|
|
195
|
+
L: 96,
|
|
196
|
+
S: this,
|
|
197
|
+
A: [
|
|
198
|
+
"this._writeStream",
|
|
199
|
+
"'Cannot write mutations in readonly mode'"
|
|
200
|
+
]
|
|
201
|
+
});
|
|
154
202
|
(0, import_log.log)("write", {
|
|
155
203
|
clientTag: request.clientTag,
|
|
156
|
-
objectCount:
|
|
204
|
+
objectCount: request.batch.objects?.length ?? 0
|
|
157
205
|
}, {
|
|
158
|
-
F:
|
|
159
|
-
L:
|
|
206
|
+
F: __dxlog_file2,
|
|
207
|
+
L: 98,
|
|
160
208
|
S: this,
|
|
161
209
|
C: (f, a) => f(...a)
|
|
162
210
|
});
|
|
@@ -169,8 +217,8 @@ var DataServiceHost = class {
|
|
|
169
217
|
feedKey: receipt2.feedKey,
|
|
170
218
|
seq: receipt2.seq
|
|
171
219
|
}, {
|
|
172
|
-
F:
|
|
173
|
-
L:
|
|
220
|
+
F: __dxlog_file2,
|
|
221
|
+
L: 107,
|
|
174
222
|
S: this,
|
|
175
223
|
C: (f, a) => f(...a)
|
|
176
224
|
});
|
|
@@ -184,24 +232,18 @@ var DataServiceHost = class {
|
|
|
184
232
|
return receipt;
|
|
185
233
|
}
|
|
186
234
|
};
|
|
187
|
-
var createDataMessage = (batch) => {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
meta: void 0
|
|
200
|
-
};
|
|
201
|
-
})
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
};
|
|
235
|
+
var createDataMessage = (batch) => ({
|
|
236
|
+
batch: {
|
|
237
|
+
objects: batch.objects?.map((object) => ({
|
|
238
|
+
...object,
|
|
239
|
+
mutations: object.mutations?.map((mutation) => ({
|
|
240
|
+
...mutation,
|
|
241
|
+
meta: void 0
|
|
242
|
+
})),
|
|
243
|
+
meta: void 0
|
|
244
|
+
}))
|
|
245
|
+
}
|
|
246
|
+
});
|
|
205
247
|
|
|
206
248
|
// packages/core/echo/echo-pipeline/src/db-host/database-host.ts
|
|
207
249
|
var import_echo_db2 = require("@dxos/echo-db");
|
|
@@ -230,15 +272,13 @@ var DatabaseHost = class {
|
|
|
230
272
|
return this._itemDemuxer.createSnapshot();
|
|
231
273
|
}
|
|
232
274
|
createDataServiceHost() {
|
|
233
|
-
|
|
234
|
-
return new DataServiceHost(this._itemManager, this._itemDemuxer, (_a = this._outboundStream) != null ? _a : void 0);
|
|
275
|
+
return new DataServiceHost(this._itemManager, this._itemDemuxer, this._outboundStream ?? void 0);
|
|
235
276
|
}
|
|
236
277
|
};
|
|
237
278
|
|
|
238
279
|
// packages/core/echo/echo-pipeline/src/db-host/snapshot-manager.ts
|
|
239
280
|
var import_async = require("@dxos/async");
|
|
240
281
|
var import_context2 = require("@dxos/context");
|
|
241
|
-
var import_debug = require("@dxos/debug");
|
|
242
282
|
var import_keys = require("@dxos/keys");
|
|
243
283
|
var import_protocols2 = require("@dxos/protocols");
|
|
244
284
|
var import_blob = require("@dxos/protocols/proto/dxos/echo/blob");
|
|
@@ -283,9 +323,6 @@ var SnapshotManager = class SnapshotManager2 {
|
|
|
283
323
|
return import_keys.PublicKey.from(id).toHex();
|
|
284
324
|
}
|
|
285
325
|
};
|
|
286
|
-
_ts_decorate([
|
|
287
|
-
(0, import_debug.timed)(1e4)
|
|
288
|
-
], SnapshotManager.prototype, "load", null);
|
|
289
326
|
SnapshotManager = _ts_decorate([
|
|
290
327
|
(0, import_async.trackLeaks)("open", "close")
|
|
291
328
|
], SnapshotManager);
|
|
@@ -337,12 +374,12 @@ var SnapshotStore = class {
|
|
|
337
374
|
};
|
|
338
375
|
|
|
339
376
|
// packages/core/echo/echo-pipeline/src/db-host/data-service.ts
|
|
340
|
-
var
|
|
341
|
-
var
|
|
377
|
+
var import_debug = require("@dxos/debug");
|
|
378
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
342
379
|
var import_keys2 = require("@dxos/keys");
|
|
343
380
|
var import_log2 = require("@dxos/log");
|
|
344
381
|
var import_util2 = require("@dxos/util");
|
|
345
|
-
var
|
|
382
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service.ts";
|
|
346
383
|
var DataServiceSubscriptions = class {
|
|
347
384
|
constructor() {
|
|
348
385
|
this._spaces = new import_util2.ComplexMap(import_keys2.PublicKey.hash);
|
|
@@ -354,12 +391,20 @@ var DataServiceSubscriptions = class {
|
|
|
354
391
|
(0, import_log2.log)("Registering space", {
|
|
355
392
|
spaceKey
|
|
356
393
|
}, {
|
|
357
|
-
F:
|
|
358
|
-
L:
|
|
394
|
+
F: __dxlog_file3,
|
|
395
|
+
L: 30,
|
|
359
396
|
S: this,
|
|
360
397
|
C: (f, a) => f(...a)
|
|
361
398
|
});
|
|
362
|
-
(0,
|
|
399
|
+
(0, import_invariant3.invariant)(!this._spaces.has(spaceKey), void 0, {
|
|
400
|
+
F: __dxlog_file3,
|
|
401
|
+
L: 31,
|
|
402
|
+
S: this,
|
|
403
|
+
A: [
|
|
404
|
+
"!this._spaces.has(spaceKey)",
|
|
405
|
+
""
|
|
406
|
+
]
|
|
407
|
+
});
|
|
363
408
|
await host.open();
|
|
364
409
|
this._spaces.set(spaceKey, host);
|
|
365
410
|
}
|
|
@@ -367,13 +412,13 @@ var DataServiceSubscriptions = class {
|
|
|
367
412
|
(0, import_log2.log)("Unregistering space", {
|
|
368
413
|
spaceKey
|
|
369
414
|
}, {
|
|
370
|
-
F:
|
|
371
|
-
L:
|
|
415
|
+
F: __dxlog_file3,
|
|
416
|
+
L: 37,
|
|
372
417
|
S: this,
|
|
373
418
|
C: (f, a) => f(...a)
|
|
374
419
|
});
|
|
375
420
|
const host = this._spaces.get(spaceKey);
|
|
376
|
-
await
|
|
421
|
+
await host?.close();
|
|
377
422
|
this._spaces.delete(spaceKey);
|
|
378
423
|
}
|
|
379
424
|
getDataService(spaceKey) {
|
|
@@ -385,16 +430,38 @@ var DataServiceImpl = class {
|
|
|
385
430
|
this._subscriptions = _subscriptions;
|
|
386
431
|
}
|
|
387
432
|
subscribe(request) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
433
|
+
(0, import_invariant3.invariant)(request.spaceKey, void 0, {
|
|
434
|
+
F: __dxlog_file3,
|
|
435
|
+
L: 56,
|
|
436
|
+
S: this,
|
|
437
|
+
A: [
|
|
438
|
+
"request.spaceKey",
|
|
439
|
+
""
|
|
440
|
+
]
|
|
441
|
+
});
|
|
442
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? (0, import_debug.raise)(new Error(`space not found: ${request.spaceKey}`));
|
|
391
443
|
return host.subscribe();
|
|
392
444
|
}
|
|
393
445
|
write(request) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
446
|
+
(0, import_invariant3.invariant)(request.spaceKey, void 0, {
|
|
447
|
+
F: __dxlog_file3,
|
|
448
|
+
L: 63,
|
|
449
|
+
S: this,
|
|
450
|
+
A: [
|
|
451
|
+
"request.spaceKey",
|
|
452
|
+
""
|
|
453
|
+
]
|
|
454
|
+
});
|
|
455
|
+
(0, import_invariant3.invariant)(request.batch, void 0, {
|
|
456
|
+
F: __dxlog_file3,
|
|
457
|
+
L: 64,
|
|
458
|
+
S: this,
|
|
459
|
+
A: [
|
|
460
|
+
"request.batch",
|
|
461
|
+
""
|
|
462
|
+
]
|
|
463
|
+
});
|
|
464
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? (0, import_debug.raise)(new Error(`space not found: ${request.spaceKey}`));
|
|
398
465
|
return host.write(request);
|
|
399
466
|
}
|
|
400
467
|
};
|
|
@@ -450,9 +517,9 @@ var UnknownModelError = class extends DBError {
|
|
|
450
517
|
|
|
451
518
|
// packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
|
|
452
519
|
var import_crc_32 = __toESM(require("crc-32"));
|
|
453
|
-
var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
|
|
454
520
|
var import_async2 = require("@dxos/async");
|
|
455
521
|
var import_errors = require("@dxos/errors");
|
|
522
|
+
var import_invariant4 = require("@dxos/invariant");
|
|
456
523
|
var import_log3 = require("@dxos/log");
|
|
457
524
|
var import_protocols4 = require("@dxos/protocols");
|
|
458
525
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
@@ -467,12 +534,12 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
467
534
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
468
535
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
469
536
|
}
|
|
470
|
-
var
|
|
537
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
|
|
471
538
|
var emptyEchoMetadata = () => ({
|
|
472
539
|
version: import_protocols4.STORAGE_VERSION,
|
|
473
540
|
spaces: [],
|
|
474
|
-
created: new Date(),
|
|
475
|
-
updated: new Date()
|
|
541
|
+
created: /* @__PURE__ */ new Date(),
|
|
542
|
+
updated: /* @__PURE__ */ new Date()
|
|
476
543
|
});
|
|
477
544
|
var EchoMetadata = import_protocols4.schema.getCodecForType("dxos.echo.metadata.EchoMetadata");
|
|
478
545
|
var MetadataStore = class {
|
|
@@ -486,22 +553,19 @@ var MetadataStore = class {
|
|
|
486
553
|
return this._metadata;
|
|
487
554
|
}
|
|
488
555
|
get version() {
|
|
489
|
-
|
|
490
|
-
return (_a = this._metadata.version) != null ? _a : 0;
|
|
556
|
+
return this._metadata.version ?? 0;
|
|
491
557
|
}
|
|
492
558
|
/**
|
|
493
559
|
* Returns a list of currently saved spaces. The list and objects in it can be modified addSpace and
|
|
494
560
|
* addSpaceFeed functions.
|
|
495
561
|
*/
|
|
496
562
|
get spaces() {
|
|
497
|
-
|
|
498
|
-
return (_a = this._metadata.spaces) != null ? _a : [];
|
|
563
|
+
return this._metadata.spaces ?? [];
|
|
499
564
|
}
|
|
500
565
|
/**
|
|
501
566
|
* Loads metadata from persistent storage.
|
|
502
567
|
*/
|
|
503
568
|
async load() {
|
|
504
|
-
var _a;
|
|
505
569
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
506
570
|
try {
|
|
507
571
|
const { size: fileLength } = await file.stat();
|
|
@@ -514,13 +578,16 @@ var MetadataStore = class {
|
|
|
514
578
|
size: dataSize,
|
|
515
579
|
checksum
|
|
516
580
|
}, {
|
|
517
|
-
F:
|
|
581
|
+
F: __dxlog_file4,
|
|
518
582
|
L: 72,
|
|
519
583
|
S: this,
|
|
520
584
|
C: (f, a) => f(...a)
|
|
521
585
|
});
|
|
522
586
|
if (fileLength < dataSize + 8) {
|
|
523
|
-
throw new import_errors.DataCorruptionError("Metadata size is smaller than expected."
|
|
587
|
+
throw new import_errors.DataCorruptionError("Metadata size is smaller than expected.", {
|
|
588
|
+
fileLength,
|
|
589
|
+
dataSize
|
|
590
|
+
});
|
|
524
591
|
}
|
|
525
592
|
const data = await file.read(8, dataSize);
|
|
526
593
|
const calculatedChecksum = import_crc_32.default.buf(data);
|
|
@@ -528,15 +595,14 @@ var MetadataStore = class {
|
|
|
528
595
|
throw new import_errors.DataCorruptionError("Metadata checksum is invalid.");
|
|
529
596
|
}
|
|
530
597
|
this._metadata = EchoMetadata.decode(data);
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
(_a2 = space.state) != null ? _a2 : space.state = import_services.SpaceState.ACTIVE;
|
|
598
|
+
this._metadata.spaces?.forEach((space) => {
|
|
599
|
+
space.state ??= import_services.SpaceState.ACTIVE;
|
|
534
600
|
});
|
|
535
601
|
} catch (err) {
|
|
536
602
|
import_log3.log.error("failed to load metadata", {
|
|
537
603
|
err
|
|
538
604
|
}, {
|
|
539
|
-
F:
|
|
605
|
+
F: __dxlog_file4,
|
|
540
606
|
L: 92,
|
|
541
607
|
S: this,
|
|
542
608
|
C: (f, a) => f(...a)
|
|
@@ -547,12 +613,11 @@ var MetadataStore = class {
|
|
|
547
613
|
}
|
|
548
614
|
}
|
|
549
615
|
async _save() {
|
|
550
|
-
var _a;
|
|
551
616
|
const data = {
|
|
552
617
|
...this._metadata,
|
|
553
618
|
version: import_protocols4.STORAGE_VERSION,
|
|
554
|
-
created:
|
|
555
|
-
updated: new Date()
|
|
619
|
+
created: this._metadata.created ?? /* @__PURE__ */ new Date(),
|
|
620
|
+
updated: /* @__PURE__ */ new Date()
|
|
556
621
|
};
|
|
557
622
|
this.update.emit(data);
|
|
558
623
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
@@ -568,7 +633,7 @@ var MetadataStore = class {
|
|
|
568
633
|
size: encoded.length,
|
|
569
634
|
checksum
|
|
570
635
|
}, {
|
|
571
|
-
F:
|
|
636
|
+
F: __dxlog_file4,
|
|
572
637
|
L: 124,
|
|
573
638
|
S: this,
|
|
574
639
|
C: (f, a) => f(...a)
|
|
@@ -578,12 +643,19 @@ var MetadataStore = class {
|
|
|
578
643
|
}
|
|
579
644
|
}
|
|
580
645
|
_getSpace(spaceKey) {
|
|
581
|
-
|
|
582
|
-
if ((_a = this._metadata.identity) == null ? void 0 : _a.haloSpace.key.equals(spaceKey)) {
|
|
646
|
+
if (this._metadata.identity?.haloSpace.key.equals(spaceKey)) {
|
|
583
647
|
return this._metadata.identity.haloSpace;
|
|
584
648
|
}
|
|
585
649
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
586
|
-
(0,
|
|
650
|
+
(0, import_invariant4.invariant)(space, "Space not found", {
|
|
651
|
+
F: __dxlog_file4,
|
|
652
|
+
L: 137,
|
|
653
|
+
S: this,
|
|
654
|
+
A: [
|
|
655
|
+
"space",
|
|
656
|
+
"'Space not found'"
|
|
657
|
+
]
|
|
658
|
+
});
|
|
587
659
|
return space;
|
|
588
660
|
}
|
|
589
661
|
/**
|
|
@@ -591,7 +663,7 @@ var MetadataStore = class {
|
|
|
591
663
|
*/
|
|
592
664
|
async clear() {
|
|
593
665
|
(0, import_log3.log)("clearing all metadata", void 0, {
|
|
594
|
-
F:
|
|
666
|
+
F: __dxlog_file4,
|
|
595
667
|
L: 145,
|
|
596
668
|
S: this,
|
|
597
669
|
C: (f, a) => f(...a)
|
|
@@ -603,14 +675,29 @@ var MetadataStore = class {
|
|
|
603
675
|
return this._metadata.identity;
|
|
604
676
|
}
|
|
605
677
|
async setIdentityRecord(record) {
|
|
606
|
-
(0,
|
|
678
|
+
(0, import_invariant4.invariant)(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
|
|
679
|
+
F: __dxlog_file4,
|
|
680
|
+
L: 155,
|
|
681
|
+
S: this,
|
|
682
|
+
A: [
|
|
683
|
+
"!this._metadata.identity",
|
|
684
|
+
"'Cannot overwrite existing identity in metadata'"
|
|
685
|
+
]
|
|
686
|
+
});
|
|
607
687
|
this._metadata.identity = record;
|
|
608
688
|
await this._save();
|
|
609
689
|
}
|
|
610
690
|
async addSpace(record) {
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
691
|
+
(0, import_invariant4.invariant)(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
|
|
692
|
+
F: __dxlog_file4,
|
|
693
|
+
L: 162,
|
|
694
|
+
S: this,
|
|
695
|
+
A: [
|
|
696
|
+
"!(this._metadata.spaces ?? []).find((space) => space.key === record.key)",
|
|
697
|
+
"'Cannot overwrite existing space in metadata'"
|
|
698
|
+
]
|
|
699
|
+
});
|
|
700
|
+
(this._metadata.spaces ??= []).push(record);
|
|
614
701
|
await this._save();
|
|
615
702
|
}
|
|
616
703
|
async setSpaceDataLatestTimeframe(spaceKey, timeframe) {
|
|
@@ -645,32 +732,40 @@ _ts_decorate2([
|
|
|
645
732
|
var fromBytesInt32 = (buf) => buf.readInt32LE(0);
|
|
646
733
|
|
|
647
734
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
648
|
-
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
649
735
|
var import_async4 = require("@dxos/async");
|
|
650
736
|
var import_context3 = require("@dxos/context");
|
|
651
|
-
var
|
|
737
|
+
var import_debug3 = require("@dxos/debug");
|
|
652
738
|
var import_feed_store = require("@dxos/feed-store");
|
|
739
|
+
var import_invariant6 = require("@dxos/invariant");
|
|
653
740
|
var import_keys3 = require("@dxos/keys");
|
|
654
741
|
var import_log6 = require("@dxos/log");
|
|
655
742
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
656
743
|
var import_util4 = require("@dxos/util");
|
|
657
744
|
|
|
658
745
|
// packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
|
|
659
|
-
var
|
|
746
|
+
var import_invariant5 = require("@dxos/invariant");
|
|
660
747
|
var import_log4 = require("@dxos/log");
|
|
661
|
-
var
|
|
748
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
|
|
662
749
|
var createMessageSelector = (timeframeClock) => {
|
|
663
750
|
return (messages) => {
|
|
664
751
|
for (let i = 0; i < messages.length; i++) {
|
|
665
752
|
const { data: { timeframe } } = messages[i];
|
|
666
|
-
(0,
|
|
753
|
+
(0, import_invariant5.invariant)(timeframe, void 0, {
|
|
754
|
+
F: __dxlog_file5,
|
|
755
|
+
L: 25,
|
|
756
|
+
S: void 0,
|
|
757
|
+
A: [
|
|
758
|
+
"timeframe",
|
|
759
|
+
""
|
|
760
|
+
]
|
|
761
|
+
});
|
|
667
762
|
if (!timeframeClock.hasGaps(timeframe)) {
|
|
668
763
|
return i;
|
|
669
764
|
}
|
|
670
765
|
}
|
|
671
766
|
(0, import_log4.log)("Skipping...", void 0, {
|
|
672
|
-
F:
|
|
673
|
-
L:
|
|
767
|
+
F: __dxlog_file5,
|
|
768
|
+
L: 33,
|
|
674
769
|
S: void 0,
|
|
675
770
|
C: (f, a) => f(...a)
|
|
676
771
|
});
|
|
@@ -679,7 +774,7 @@ var createMessageSelector = (timeframeClock) => {
|
|
|
679
774
|
|
|
680
775
|
// packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts
|
|
681
776
|
var import_async3 = require("@dxos/async");
|
|
682
|
-
var
|
|
777
|
+
var import_debug2 = require("@dxos/debug");
|
|
683
778
|
var import_log5 = require("@dxos/log");
|
|
684
779
|
var import_timeframe = require("@dxos/timeframe");
|
|
685
780
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
@@ -692,7 +787,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
692
787
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
693
788
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
694
789
|
}
|
|
695
|
-
var
|
|
790
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
|
|
696
791
|
var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
|
|
697
792
|
feedKey,
|
|
698
793
|
index
|
|
@@ -751,7 +846,7 @@ var TimeframeClock = class {
|
|
|
751
846
|
target,
|
|
752
847
|
current: this._timeframe
|
|
753
848
|
}, {
|
|
754
|
-
F:
|
|
849
|
+
F: __dxlog_file6,
|
|
755
850
|
L: 73,
|
|
756
851
|
S: this,
|
|
757
852
|
C: (f, a) => f(...a)
|
|
@@ -762,7 +857,7 @@ var TimeframeClock = class {
|
|
|
762
857
|
current: this._timeframe,
|
|
763
858
|
deps: import_timeframe.Timeframe.dependencies(target, this._timeframe)
|
|
764
859
|
}, {
|
|
765
|
-
F:
|
|
860
|
+
F: __dxlog_file6,
|
|
766
861
|
L: 75,
|
|
767
862
|
S: this,
|
|
768
863
|
C: (f, a) => f(...a)
|
|
@@ -772,7 +867,7 @@ var TimeframeClock = class {
|
|
|
772
867
|
}
|
|
773
868
|
};
|
|
774
869
|
_ts_decorate3([
|
|
775
|
-
(0,
|
|
870
|
+
(0, import_debug2.timed)(5e3)
|
|
776
871
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
777
872
|
|
|
778
873
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
@@ -786,7 +881,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
786
881
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
787
882
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
788
883
|
}
|
|
789
|
-
var
|
|
884
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
|
|
790
885
|
var PipelineState = class {
|
|
791
886
|
// prettier-ignore
|
|
792
887
|
constructor(_feeds, _timeframeClock) {
|
|
@@ -837,18 +932,17 @@ var PipelineState = class {
|
|
|
837
932
|
* @param timeout Timeout in milliseconds to specify the maximum wait time.
|
|
838
933
|
*/
|
|
839
934
|
async waitUntilReachedTargetTimeframe({ ctx = new import_context3.Context(), timeout, breakOnStall = true } = {}) {
|
|
840
|
-
var _a;
|
|
841
935
|
(0, import_log6.log)("waitUntilReachedTargetTimeframe", {
|
|
842
936
|
timeout,
|
|
843
937
|
current: this.timeframe,
|
|
844
938
|
target: this.targetTimeframe
|
|
845
939
|
}, {
|
|
846
|
-
F:
|
|
847
|
-
L:
|
|
940
|
+
F: __dxlog_file7,
|
|
941
|
+
L: 125,
|
|
848
942
|
S: this,
|
|
849
943
|
C: (f, a) => f(...a)
|
|
850
944
|
});
|
|
851
|
-
|
|
945
|
+
this._reachedTargetPromise ??= Promise.race([
|
|
852
946
|
this._timeframeClock.update.waitForCondition(() => {
|
|
853
947
|
return import_timeframe2.Timeframe.dependencies(this.targetTimeframe, this.timeframe).isEmpty();
|
|
854
948
|
}),
|
|
@@ -874,8 +968,8 @@ var PipelineState = class {
|
|
|
874
968
|
target: this.targetTimeframe,
|
|
875
969
|
dependencies: import_timeframe2.Timeframe.dependencies(this.targetTimeframe, this.timeframe)
|
|
876
970
|
}, {
|
|
877
|
-
F:
|
|
878
|
-
L:
|
|
971
|
+
F: __dxlog_file7,
|
|
972
|
+
L: 152,
|
|
879
973
|
S: this,
|
|
880
974
|
C: (f, a) => f(...a)
|
|
881
975
|
});
|
|
@@ -895,16 +989,26 @@ var Pipeline = class {
|
|
|
895
989
|
// Waits for the message consumer to process the message and yield control back to the pipeline.
|
|
896
990
|
this._processingTrigger = new import_async4.Trigger().wake();
|
|
897
991
|
this._pauseTrigger = new import_async4.Trigger().wake();
|
|
992
|
+
// Pending downloads.
|
|
993
|
+
this._downloads = new import_util4.ComplexMap((value) => import_keys3.PublicKey.hash(value.key));
|
|
898
994
|
this._isStopping = false;
|
|
899
995
|
this._isStarted = false;
|
|
900
|
-
this.
|
|
996
|
+
this._isBeingConsumed = false;
|
|
901
997
|
this._isPaused = false;
|
|
902
998
|
}
|
|
903
999
|
get state() {
|
|
904
1000
|
return this._state;
|
|
905
1001
|
}
|
|
906
1002
|
get writer() {
|
|
907
|
-
(0,
|
|
1003
|
+
(0, import_invariant6.invariant)(this._writer, "Writer not set.", {
|
|
1004
|
+
F: __dxlog_file7,
|
|
1005
|
+
L: 233,
|
|
1006
|
+
S: this,
|
|
1007
|
+
A: [
|
|
1008
|
+
"this._writer",
|
|
1009
|
+
"'Writer not set.'"
|
|
1010
|
+
]
|
|
1011
|
+
});
|
|
908
1012
|
return this._writer;
|
|
909
1013
|
}
|
|
910
1014
|
hasFeed(feedKey) {
|
|
@@ -920,20 +1024,47 @@ var Pipeline = class {
|
|
|
920
1024
|
if (this._feedSetIterator) {
|
|
921
1025
|
await this._feedSetIterator.addFeed(feed);
|
|
922
1026
|
}
|
|
923
|
-
this.
|
|
1027
|
+
if (this._isStarted && !this._isPaused) {
|
|
1028
|
+
this._setFeedDownloadState(feed);
|
|
1029
|
+
}
|
|
924
1030
|
}
|
|
925
1031
|
setWriteFeed(feed) {
|
|
926
|
-
(0,
|
|
927
|
-
|
|
1032
|
+
(0, import_invariant6.invariant)(!this._writer, "Writer already set.", {
|
|
1033
|
+
F: __dxlog_file7,
|
|
1034
|
+
L: 260,
|
|
1035
|
+
S: this,
|
|
1036
|
+
A: [
|
|
1037
|
+
"!this._writer",
|
|
1038
|
+
"'Writer already set.'"
|
|
1039
|
+
]
|
|
1040
|
+
});
|
|
1041
|
+
(0, import_invariant6.invariant)(feed.properties.writable, "Feed must be writable.", {
|
|
1042
|
+
F: __dxlog_file7,
|
|
1043
|
+
L: 261,
|
|
1044
|
+
S: this,
|
|
1045
|
+
A: [
|
|
1046
|
+
"feed.properties.writable",
|
|
1047
|
+
"'Feed must be writable.'"
|
|
1048
|
+
]
|
|
1049
|
+
});
|
|
928
1050
|
this._writer = createMappedFeedWriter((payload) => ({
|
|
929
1051
|
timeframe: this._timeframeClock.timeframe,
|
|
930
1052
|
payload
|
|
931
1053
|
}), feed.createFeedWriter());
|
|
932
1054
|
}
|
|
933
1055
|
async start() {
|
|
1056
|
+
(0, import_invariant6.invariant)(!this._isStarted, "Pipeline is already started.", {
|
|
1057
|
+
F: __dxlog_file7,
|
|
1058
|
+
L: 274,
|
|
1059
|
+
S: this,
|
|
1060
|
+
A: [
|
|
1061
|
+
"!this._isStarted",
|
|
1062
|
+
"'Pipeline is already started.'"
|
|
1063
|
+
]
|
|
1064
|
+
});
|
|
934
1065
|
(0, import_log6.log)("starting...", void 0, {
|
|
935
|
-
F:
|
|
936
|
-
L:
|
|
1066
|
+
F: __dxlog_file7,
|
|
1067
|
+
L: 275,
|
|
937
1068
|
S: this,
|
|
938
1069
|
C: (f, a) => f(...a)
|
|
939
1070
|
});
|
|
@@ -941,30 +1072,38 @@ var Pipeline = class {
|
|
|
941
1072
|
await this._feedSetIterator.open();
|
|
942
1073
|
this._isStarted = true;
|
|
943
1074
|
(0, import_log6.log)("started", void 0, {
|
|
944
|
-
F:
|
|
945
|
-
L:
|
|
1075
|
+
F: __dxlog_file7,
|
|
1076
|
+
L: 279,
|
|
946
1077
|
S: this,
|
|
947
1078
|
C: (f, a) => f(...a)
|
|
948
1079
|
});
|
|
1080
|
+
if (!this._isPaused) {
|
|
1081
|
+
for (const feed of this._feeds.values()) {
|
|
1082
|
+
this._setFeedDownloadState(feed);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
949
1085
|
}
|
|
950
1086
|
async stop() {
|
|
951
|
-
var _a;
|
|
952
1087
|
(0, import_log6.log)("stopping...", void 0, {
|
|
953
|
-
F:
|
|
954
|
-
L:
|
|
1088
|
+
F: __dxlog_file7,
|
|
1089
|
+
L: 290,
|
|
955
1090
|
S: this,
|
|
956
1091
|
C: (f, a) => f(...a)
|
|
957
1092
|
});
|
|
958
1093
|
this._isStopping = true;
|
|
959
|
-
|
|
1094
|
+
for (const [feed, handle] of this._downloads.entries()) {
|
|
1095
|
+
feed.undownload(handle);
|
|
1096
|
+
}
|
|
1097
|
+
this._downloads.clear();
|
|
1098
|
+
await this._feedSetIterator?.close();
|
|
960
1099
|
await this._processingTrigger.wait();
|
|
961
1100
|
await this._state._ctx.dispose();
|
|
962
1101
|
this._state._ctx = new import_context3.Context();
|
|
963
1102
|
this._state._reachedTargetPromise = void 0;
|
|
964
1103
|
this._isStarted = false;
|
|
965
1104
|
(0, import_log6.log)("stopped", void 0, {
|
|
966
|
-
F:
|
|
967
|
-
L:
|
|
1105
|
+
F: __dxlog_file7,
|
|
1106
|
+
L: 302,
|
|
968
1107
|
S: this,
|
|
969
1108
|
C: (f, a) => f(...a)
|
|
970
1109
|
});
|
|
@@ -974,12 +1113,17 @@ var Pipeline = class {
|
|
|
974
1113
|
* The pipeline will start processing messages AFTER this timeframe.
|
|
975
1114
|
*/
|
|
976
1115
|
async setCursor(timeframe) {
|
|
977
|
-
(0,
|
|
1116
|
+
(0, import_invariant6.invariant)(!this._isStarted || this._isPaused, "Invalid state.", {
|
|
1117
|
+
F: __dxlog_file7,
|
|
1118
|
+
L: 311,
|
|
1119
|
+
S: this,
|
|
1120
|
+
A: [
|
|
1121
|
+
"!this._isStarted || this._isPaused",
|
|
1122
|
+
"'Invalid state.'"
|
|
1123
|
+
]
|
|
1124
|
+
});
|
|
978
1125
|
this._state._startTimeframe = timeframe;
|
|
979
1126
|
this._timeframeClock.setTimeframe(timeframe);
|
|
980
|
-
for (const feed of this._feeds.values()) {
|
|
981
|
-
this._setFeedDownloadState(feed);
|
|
982
|
-
}
|
|
983
1127
|
if (this._feedSetIterator) {
|
|
984
1128
|
await this._feedSetIterator.close();
|
|
985
1129
|
await this._initIterator();
|
|
@@ -990,7 +1134,6 @@ var Pipeline = class {
|
|
|
990
1134
|
* Calling pause while processing will cause a deadlock.
|
|
991
1135
|
*/
|
|
992
1136
|
async pause() {
|
|
993
|
-
(0, import_tiny_invariant6.default)(this._isStarted, "Pipeline is not open.");
|
|
994
1137
|
if (this._isPaused) {
|
|
995
1138
|
return;
|
|
996
1139
|
}
|
|
@@ -999,31 +1142,65 @@ var Pipeline = class {
|
|
|
999
1142
|
this._isPaused = true;
|
|
1000
1143
|
}
|
|
1001
1144
|
async unpause() {
|
|
1002
|
-
(0,
|
|
1003
|
-
|
|
1145
|
+
(0, import_invariant6.invariant)(this._isPaused, "Pipeline is not paused.", {
|
|
1146
|
+
F: __dxlog_file7,
|
|
1147
|
+
L: 340,
|
|
1148
|
+
S: this,
|
|
1149
|
+
A: [
|
|
1150
|
+
"this._isPaused",
|
|
1151
|
+
"'Pipeline is not paused.'"
|
|
1152
|
+
]
|
|
1153
|
+
});
|
|
1004
1154
|
this._pauseTrigger.wake();
|
|
1005
1155
|
this._isPaused = false;
|
|
1156
|
+
for (const feed of this._feeds.values()) {
|
|
1157
|
+
this._setFeedDownloadState(feed);
|
|
1158
|
+
}
|
|
1006
1159
|
}
|
|
1007
1160
|
/**
|
|
1008
1161
|
* Starts to iterate over the ordered messages from the added feeds.
|
|
1009
1162
|
* Updates the timeframe clock after the message has bee processed.
|
|
1010
1163
|
*/
|
|
1011
1164
|
async *consume() {
|
|
1012
|
-
(0,
|
|
1013
|
-
|
|
1014
|
-
|
|
1165
|
+
(0, import_invariant6.invariant)(!this._isBeingConsumed, "Pipeline is already being consumed.", {
|
|
1166
|
+
F: __dxlog_file7,
|
|
1167
|
+
L: 355,
|
|
1168
|
+
S: this,
|
|
1169
|
+
A: [
|
|
1170
|
+
"!this._isBeingConsumed",
|
|
1171
|
+
"'Pipeline is already being consumed.'"
|
|
1172
|
+
]
|
|
1173
|
+
});
|
|
1174
|
+
this._isBeingConsumed = true;
|
|
1175
|
+
(0, import_invariant6.invariant)(this._feedSetIterator, "Iterator not initialized.", {
|
|
1176
|
+
F: __dxlog_file7,
|
|
1177
|
+
L: 358,
|
|
1178
|
+
S: this,
|
|
1179
|
+
A: [
|
|
1180
|
+
"this._feedSetIterator",
|
|
1181
|
+
"'Iterator not initialized.'"
|
|
1182
|
+
]
|
|
1183
|
+
});
|
|
1015
1184
|
let lastFeedSetIterator = this._feedSetIterator;
|
|
1016
1185
|
let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
1017
1186
|
while (!this._isStopping) {
|
|
1018
1187
|
await this._pauseTrigger.wait();
|
|
1019
1188
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
1020
|
-
(0,
|
|
1189
|
+
(0, import_invariant6.invariant)(this._feedSetIterator, "Iterator not initialized.", {
|
|
1190
|
+
F: __dxlog_file7,
|
|
1191
|
+
L: 367,
|
|
1192
|
+
S: this,
|
|
1193
|
+
A: [
|
|
1194
|
+
"this._feedSetIterator",
|
|
1195
|
+
"'Iterator not initialized.'"
|
|
1196
|
+
]
|
|
1197
|
+
});
|
|
1021
1198
|
lastFeedSetIterator = this._feedSetIterator;
|
|
1022
1199
|
iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
1023
1200
|
}
|
|
1024
1201
|
const { done, value } = await iterable.next();
|
|
1025
1202
|
if (!done) {
|
|
1026
|
-
const block = value
|
|
1203
|
+
const block = value ?? (0, import_debug3.failUndefined)();
|
|
1027
1204
|
this._processingTrigger.reset();
|
|
1028
1205
|
this._timeframeClock.updatePendingTimeframe(import_keys3.PublicKey.from(block.feedKey), block.seq);
|
|
1029
1206
|
yield block;
|
|
@@ -1031,33 +1208,40 @@ var Pipeline = class {
|
|
|
1031
1208
|
this._timeframeClock.updateTimeframe();
|
|
1032
1209
|
}
|
|
1033
1210
|
}
|
|
1034
|
-
this.
|
|
1211
|
+
this._isBeingConsumed = false;
|
|
1035
1212
|
}
|
|
1036
1213
|
_setFeedDownloadState(feed) {
|
|
1037
|
-
|
|
1214
|
+
let handle = this._downloads.get(feed);
|
|
1215
|
+
if (handle) {
|
|
1216
|
+
feed.undownload(handle);
|
|
1217
|
+
}
|
|
1038
1218
|
const timeframe = this._state._startTimeframe;
|
|
1039
|
-
const seq =
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1219
|
+
const seq = timeframe.get(feed.key) ?? -1;
|
|
1220
|
+
import_log6.log.info("download", {
|
|
1221
|
+
feed: feed.key.truncate(),
|
|
1222
|
+
seq,
|
|
1223
|
+
length: feed.length
|
|
1224
|
+
}, {
|
|
1225
|
+
F: __dxlog_file7,
|
|
1226
|
+
L: 396,
|
|
1227
|
+
S: this,
|
|
1228
|
+
C: (f, a) => f(...a)
|
|
1047
1229
|
});
|
|
1048
|
-
feed.download({
|
|
1230
|
+
handle = feed.download({
|
|
1049
1231
|
start: seq + 1,
|
|
1050
1232
|
linear: true
|
|
1051
|
-
}
|
|
1052
|
-
(
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1233
|
+
}, (err, data) => {
|
|
1234
|
+
if (err) {
|
|
1235
|
+
} else {
|
|
1236
|
+
import_log6.log.info("data", data, {
|
|
1237
|
+
F: __dxlog_file7,
|
|
1238
|
+
L: 401,
|
|
1239
|
+
S: this,
|
|
1240
|
+
C: (f, a) => f(...a)
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1060
1243
|
});
|
|
1244
|
+
this._downloads.set(feed, handle);
|
|
1061
1245
|
}
|
|
1062
1246
|
async _initIterator() {
|
|
1063
1247
|
this._feedSetIterator = new import_feed_store.FeedSetIterator(createMessageSelector(this._timeframeClock), {
|
|
@@ -1066,8 +1250,8 @@ var Pipeline = class {
|
|
|
1066
1250
|
});
|
|
1067
1251
|
this._feedSetIterator.stalled.on((iterator) => {
|
|
1068
1252
|
import_log6.log.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
|
|
1069
|
-
F:
|
|
1070
|
-
L:
|
|
1253
|
+
F: __dxlog_file7,
|
|
1254
|
+
L: 415,
|
|
1071
1255
|
S: this,
|
|
1072
1256
|
C: (f, a) => f(...a)
|
|
1073
1257
|
});
|
|
@@ -1095,14 +1279,14 @@ _ts_decorate4([
|
|
|
1095
1279
|
], Pipeline.prototype, "unpause", null);
|
|
1096
1280
|
|
|
1097
1281
|
// packages/core/echo/echo-pipeline/src/space/auth.ts
|
|
1098
|
-
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
1099
1282
|
var import_async5 = require("@dxos/async");
|
|
1100
1283
|
var import_context4 = require("@dxos/context");
|
|
1101
1284
|
var import_crypto2 = require("@dxos/crypto");
|
|
1285
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
1102
1286
|
var import_log7 = require("@dxos/log");
|
|
1103
1287
|
var import_protocols5 = require("@dxos/protocols");
|
|
1104
1288
|
var import_teleport = require("@dxos/teleport");
|
|
1105
|
-
var
|
|
1289
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
|
|
1106
1290
|
var AuthExtension = class extends import_teleport.RpcExtension {
|
|
1107
1291
|
constructor(_authParams) {
|
|
1108
1292
|
super({
|
|
@@ -1118,8 +1302,8 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
1118
1302
|
this._ctx = new import_context4.Context({
|
|
1119
1303
|
onError: (err) => {
|
|
1120
1304
|
import_log7.log.catch(err, void 0, {
|
|
1121
|
-
F:
|
|
1122
|
-
L:
|
|
1305
|
+
F: __dxlog_file8,
|
|
1306
|
+
L: 28,
|
|
1123
1307
|
S: this,
|
|
1124
1308
|
C: (f, a) => f(...a)
|
|
1125
1309
|
});
|
|
@@ -1140,8 +1324,8 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
1140
1324
|
};
|
|
1141
1325
|
} catch (err) {
|
|
1142
1326
|
import_log7.log.error("failed to generate auth credentials", err, {
|
|
1143
|
-
F:
|
|
1144
|
-
L:
|
|
1327
|
+
F: __dxlog_file8,
|
|
1328
|
+
L: 55,
|
|
1145
1329
|
S: this,
|
|
1146
1330
|
C: (f, a) => f(...a)
|
|
1147
1331
|
});
|
|
@@ -1159,14 +1343,30 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
1159
1343
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
1160
1344
|
challenge
|
|
1161
1345
|
});
|
|
1162
|
-
(0,
|
|
1346
|
+
(0, import_invariant7.invariant)(credential?.length > 0, "invalid credential", {
|
|
1347
|
+
F: __dxlog_file8,
|
|
1348
|
+
L: 69,
|
|
1349
|
+
S: this,
|
|
1350
|
+
A: [
|
|
1351
|
+
"credential?.length > 0",
|
|
1352
|
+
"'invalid credential'"
|
|
1353
|
+
]
|
|
1354
|
+
});
|
|
1163
1355
|
const success = await this._authParams.verifier(challenge, credential);
|
|
1164
|
-
(0,
|
|
1356
|
+
(0, import_invariant7.invariant)(success, "credential not verified", {
|
|
1357
|
+
F: __dxlog_file8,
|
|
1358
|
+
L: 71,
|
|
1359
|
+
S: this,
|
|
1360
|
+
A: [
|
|
1361
|
+
"success",
|
|
1362
|
+
"'credential not verified'"
|
|
1363
|
+
]
|
|
1364
|
+
});
|
|
1165
1365
|
(0, import_async5.runInContext)(this._ctx, () => this._authParams.onAuthSuccess());
|
|
1166
1366
|
} catch (err) {
|
|
1167
1367
|
(0, import_log7.log)("auth failed", err, {
|
|
1168
|
-
F:
|
|
1169
|
-
L:
|
|
1368
|
+
F: __dxlog_file8,
|
|
1369
|
+
L: 74,
|
|
1170
1370
|
S: this,
|
|
1171
1371
|
C: (f, a) => f(...a)
|
|
1172
1372
|
});
|
|
@@ -1182,25 +1382,40 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
1182
1382
|
};
|
|
1183
1383
|
|
|
1184
1384
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1185
|
-
var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
|
|
1186
1385
|
var import_async7 = require("@dxos/async");
|
|
1386
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
1187
1387
|
var import_log10 = require("@dxos/log");
|
|
1188
1388
|
var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
1389
|
+
var import_tracing3 = require("@dxos/tracing");
|
|
1189
1390
|
var import_util7 = require("@dxos/util");
|
|
1190
1391
|
|
|
1191
1392
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
1393
|
+
var import_context5 = require("@dxos/context");
|
|
1192
1394
|
var import_credentials = require("@dxos/credentials");
|
|
1193
1395
|
var import_keys4 = require("@dxos/keys");
|
|
1194
1396
|
var import_log8 = require("@dxos/log");
|
|
1195
1397
|
var import_credentials2 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
1196
1398
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
1399
|
+
var import_tracing = require("@dxos/tracing");
|
|
1197
1400
|
var import_util5 = require("@dxos/util");
|
|
1198
|
-
|
|
1401
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
1402
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1403
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1404
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1405
|
+
else
|
|
1406
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
1407
|
+
if (d = decorators[i])
|
|
1408
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1409
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1410
|
+
}
|
|
1411
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
1199
1412
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
|
|
1200
|
-
var ControlPipeline = class {
|
|
1413
|
+
var ControlPipeline = class ControlPipeline2 {
|
|
1201
1414
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1202
1415
|
this._lastTimeframeSaveTime = Date.now();
|
|
1203
1416
|
this.onFeedAdmitted = new import_util5.Callback();
|
|
1417
|
+
this._usage = new import_tracing.TimeUsageCounter();
|
|
1418
|
+
this._mutations = new import_tracing.TimeSeriesCounter();
|
|
1204
1419
|
this._spaceKey = spaceKey;
|
|
1205
1420
|
this._metadata = metadataStore;
|
|
1206
1421
|
this._pipeline = new Pipeline();
|
|
@@ -1210,8 +1425,8 @@ var ControlPipeline = class {
|
|
|
1210
1425
|
(0, import_log8.log)("feed admitted", {
|
|
1211
1426
|
key: info.key
|
|
1212
1427
|
}, {
|
|
1213
|
-
F:
|
|
1214
|
-
L:
|
|
1428
|
+
F: __dxlog_file9,
|
|
1429
|
+
L: 61,
|
|
1215
1430
|
S: this,
|
|
1216
1431
|
C: (f, a) => f(...a)
|
|
1217
1432
|
});
|
|
@@ -1221,8 +1436,8 @@ var ControlPipeline = class {
|
|
|
1221
1436
|
await this._pipeline.addFeed(feed);
|
|
1222
1437
|
} catch (err) {
|
|
1223
1438
|
import_log8.log.catch(err, void 0, {
|
|
1224
|
-
F:
|
|
1225
|
-
L:
|
|
1439
|
+
F: __dxlog_file9,
|
|
1440
|
+
L: 69,
|
|
1226
1441
|
S: this,
|
|
1227
1442
|
C: (f, a) => f(...a)
|
|
1228
1443
|
});
|
|
@@ -1244,57 +1459,66 @@ var ControlPipeline = class {
|
|
|
1244
1459
|
}
|
|
1245
1460
|
async start() {
|
|
1246
1461
|
(0, import_log8.log)("starting...", void 0, {
|
|
1247
|
-
F:
|
|
1248
|
-
L:
|
|
1462
|
+
F: __dxlog_file9,
|
|
1463
|
+
L: 93,
|
|
1249
1464
|
S: this,
|
|
1250
1465
|
C: (f, a) => f(...a)
|
|
1251
1466
|
});
|
|
1252
1467
|
setTimeout(async () => {
|
|
1253
|
-
|
|
1254
|
-
try {
|
|
1255
|
-
(0, import_log8.log)("processing", {
|
|
1256
|
-
key: msg.feedKey,
|
|
1257
|
-
seq: msg.seq
|
|
1258
|
-
}, {
|
|
1259
|
-
F: __dxlog_file8,
|
|
1260
|
-
L: 88,
|
|
1261
|
-
S: this,
|
|
1262
|
-
C: (f, a) => f(...a)
|
|
1263
|
-
});
|
|
1264
|
-
if (msg.data.payload.credential) {
|
|
1265
|
-
const timer = import_util5.tracer.mark("dxos.echo.pipeline.control");
|
|
1266
|
-
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, import_keys4.PublicKey.from(msg.feedKey));
|
|
1267
|
-
timer.end();
|
|
1268
|
-
if (!result) {
|
|
1269
|
-
import_log8.log.warn("processing failed", {
|
|
1270
|
-
msg
|
|
1271
|
-
}, {
|
|
1272
|
-
F: __dxlog_file8,
|
|
1273
|
-
L: 98,
|
|
1274
|
-
S: this,
|
|
1275
|
-
C: (f, a) => f(...a)
|
|
1276
|
-
});
|
|
1277
|
-
} else {
|
|
1278
|
-
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
} catch (err) {
|
|
1282
|
-
import_log8.log.catch(err, void 0, {
|
|
1283
|
-
F: __dxlog_file8,
|
|
1284
|
-
L: 104,
|
|
1285
|
-
S: this,
|
|
1286
|
-
C: (f, a) => f(...a)
|
|
1287
|
-
});
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1468
|
+
void this._consumePipeline(new import_context5.Context());
|
|
1290
1469
|
});
|
|
1291
1470
|
await this._pipeline.start();
|
|
1292
1471
|
(0, import_log8.log)("started", void 0, {
|
|
1293
|
-
F:
|
|
1294
|
-
L:
|
|
1472
|
+
F: __dxlog_file9,
|
|
1473
|
+
L: 99,
|
|
1474
|
+
S: this,
|
|
1475
|
+
C: (f, a) => f(...a)
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
async _consumePipeline(ctx) {
|
|
1479
|
+
for await (const msg of this._pipeline.consume()) {
|
|
1480
|
+
const span = this._usage.beginRecording();
|
|
1481
|
+
this._mutations.inc();
|
|
1482
|
+
try {
|
|
1483
|
+
await this._processMessage(ctx, msg);
|
|
1484
|
+
} catch (err) {
|
|
1485
|
+
import_log8.log.catch(err, void 0, {
|
|
1486
|
+
F: __dxlog_file9,
|
|
1487
|
+
L: 111,
|
|
1488
|
+
S: this,
|
|
1489
|
+
C: (f, a) => f(...a)
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
span.end();
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
async _processMessage(ctx, msg) {
|
|
1496
|
+
(0, import_log8.log)("processing", {
|
|
1497
|
+
key: msg.feedKey,
|
|
1498
|
+
seq: msg.seq
|
|
1499
|
+
}, {
|
|
1500
|
+
F: __dxlog_file9,
|
|
1501
|
+
L: 121,
|
|
1295
1502
|
S: this,
|
|
1296
1503
|
C: (f, a) => f(...a)
|
|
1297
1504
|
});
|
|
1505
|
+
if (msg.data.payload.credential) {
|
|
1506
|
+
const timer = import_util5.tracer.mark("dxos.echo.pipeline.control");
|
|
1507
|
+
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, import_keys4.PublicKey.from(msg.feedKey));
|
|
1508
|
+
timer.end();
|
|
1509
|
+
if (!result) {
|
|
1510
|
+
import_log8.log.warn("processing failed", {
|
|
1511
|
+
msg
|
|
1512
|
+
}, {
|
|
1513
|
+
F: __dxlog_file9,
|
|
1514
|
+
L: 131,
|
|
1515
|
+
S: this,
|
|
1516
|
+
C: (f, a) => f(...a)
|
|
1517
|
+
});
|
|
1518
|
+
} else {
|
|
1519
|
+
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1298
1522
|
}
|
|
1299
1523
|
async _noteTargetStateIfNeeded(timeframe) {
|
|
1300
1524
|
if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL) {
|
|
@@ -1304,48 +1528,63 @@ var ControlPipeline = class {
|
|
|
1304
1528
|
}
|
|
1305
1529
|
async stop() {
|
|
1306
1530
|
(0, import_log8.log)("stopping...", void 0, {
|
|
1307
|
-
F:
|
|
1308
|
-
L:
|
|
1531
|
+
F: __dxlog_file9,
|
|
1532
|
+
L: 149,
|
|
1309
1533
|
S: this,
|
|
1310
1534
|
C: (f, a) => f(...a)
|
|
1311
1535
|
});
|
|
1312
1536
|
await this._pipeline.stop();
|
|
1313
1537
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1314
1538
|
(0, import_log8.log)("stopped", void 0, {
|
|
1315
|
-
F:
|
|
1316
|
-
L:
|
|
1539
|
+
F: __dxlog_file9,
|
|
1540
|
+
L: 152,
|
|
1317
1541
|
S: this,
|
|
1318
1542
|
C: (f, a) => f(...a)
|
|
1319
1543
|
});
|
|
1320
1544
|
}
|
|
1321
1545
|
async _saveTargetTimeframe(timeframe) {
|
|
1322
|
-
var _a;
|
|
1323
1546
|
try {
|
|
1324
|
-
const newTimeframe = import_timeframe3.Timeframe.merge(
|
|
1547
|
+
const newTimeframe = import_timeframe3.Timeframe.merge(this._targetTimeframe ?? new import_timeframe3.Timeframe(), timeframe);
|
|
1325
1548
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1326
1549
|
this._targetTimeframe = newTimeframe;
|
|
1327
1550
|
} catch (err) {
|
|
1328
1551
|
(0, import_log8.log)(err, void 0, {
|
|
1329
|
-
F:
|
|
1330
|
-
L:
|
|
1552
|
+
F: __dxlog_file9,
|
|
1553
|
+
L: 161,
|
|
1331
1554
|
S: this,
|
|
1332
1555
|
C: (f, a) => f(...a)
|
|
1333
1556
|
});
|
|
1334
1557
|
}
|
|
1335
1558
|
}
|
|
1336
1559
|
};
|
|
1560
|
+
_ts_decorate5([
|
|
1561
|
+
import_tracing.trace.metricsCounter()
|
|
1562
|
+
], ControlPipeline.prototype, "_usage", void 0);
|
|
1563
|
+
_ts_decorate5([
|
|
1564
|
+
import_tracing.trace.metricsCounter()
|
|
1565
|
+
], ControlPipeline.prototype, "_mutations", void 0);
|
|
1566
|
+
_ts_decorate5([
|
|
1567
|
+
import_tracing.trace.span()
|
|
1568
|
+
], ControlPipeline.prototype, "_consumePipeline", null);
|
|
1569
|
+
_ts_decorate5([
|
|
1570
|
+
import_tracing.trace.span()
|
|
1571
|
+
], ControlPipeline.prototype, "_processMessage", null);
|
|
1572
|
+
ControlPipeline = _ts_decorate5([
|
|
1573
|
+
import_tracing.trace.resource()
|
|
1574
|
+
], ControlPipeline);
|
|
1337
1575
|
|
|
1338
1576
|
// packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
|
|
1339
|
-
var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
|
|
1340
1577
|
var import_async6 = require("@dxos/async");
|
|
1341
|
-
var
|
|
1578
|
+
var import_context6 = require("@dxos/context");
|
|
1342
1579
|
var import_credentials3 = require("@dxos/credentials");
|
|
1343
1580
|
var import_echo_db3 = require("@dxos/echo-db");
|
|
1344
1581
|
var import_errors2 = require("@dxos/errors");
|
|
1582
|
+
var import_invariant8 = require("@dxos/invariant");
|
|
1345
1583
|
var import_log9 = require("@dxos/log");
|
|
1346
1584
|
var import_timeframe4 = require("@dxos/timeframe");
|
|
1585
|
+
var import_tracing2 = require("@dxos/tracing");
|
|
1347
1586
|
var import_util6 = require("@dxos/util");
|
|
1348
|
-
function
|
|
1587
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1349
1588
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1350
1589
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1351
1590
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1355,14 +1594,14 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
1355
1594
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1356
1595
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1357
1596
|
}
|
|
1358
|
-
var
|
|
1597
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
|
|
1359
1598
|
var MESSAGES_PER_SNAPSHOT = 10;
|
|
1360
1599
|
var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
|
|
1361
1600
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
1362
1601
|
var DataPipeline = class DataPipeline2 {
|
|
1363
1602
|
constructor(_params) {
|
|
1364
1603
|
this._params = _params;
|
|
1365
|
-
this._ctx = new
|
|
1604
|
+
this._ctx = new import_context6.Context();
|
|
1366
1605
|
this._pipeline = void 0;
|
|
1367
1606
|
this._targetTimeframe = void 0;
|
|
1368
1607
|
this._lastAutomaticSnapshotTimeframe = new import_timeframe4.Timeframe();
|
|
@@ -1370,6 +1609,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1370
1609
|
this._lastTimeframeSaveTime = 0;
|
|
1371
1610
|
this._lastSnapshotSaveTime = 0;
|
|
1372
1611
|
this._lastProcessedEpoch = -1;
|
|
1612
|
+
this._usage = new import_tracing2.TimeUsageCounter();
|
|
1613
|
+
this._mutations = new import_tracing2.TimeSeriesCounter();
|
|
1373
1614
|
this.currentEpoch = void 0;
|
|
1374
1615
|
this.appliedEpoch = void 0;
|
|
1375
1616
|
this.onNewEpoch = new import_async6.Event();
|
|
@@ -1381,13 +1622,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1381
1622
|
return this._pipeline;
|
|
1382
1623
|
}
|
|
1383
1624
|
get pipelineState() {
|
|
1384
|
-
|
|
1385
|
-
return (_a = this._pipeline) == null ? void 0 : _a.state;
|
|
1625
|
+
return this._pipeline?.state;
|
|
1386
1626
|
}
|
|
1387
1627
|
setTargetTimeframe(timeframe) {
|
|
1388
|
-
var _a;
|
|
1389
1628
|
this._targetTimeframe = timeframe;
|
|
1390
|
-
|
|
1629
|
+
this._pipeline?.state.setTargetTimeframe(timeframe);
|
|
1391
1630
|
}
|
|
1392
1631
|
async processCredential(credential) {
|
|
1393
1632
|
if (!(0, import_credentials3.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
@@ -1404,15 +1643,31 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1404
1643
|
}
|
|
1405
1644
|
this._pipeline = new Pipeline();
|
|
1406
1645
|
await this._params.onPipelineCreated(this._pipeline);
|
|
1407
|
-
await this._pipeline.start();
|
|
1408
1646
|
await this._pipeline.pause();
|
|
1647
|
+
await this._pipeline.start();
|
|
1409
1648
|
if (this._targetTimeframe) {
|
|
1410
1649
|
this._pipeline.state.setTargetTimeframe(this._targetTimeframe);
|
|
1411
1650
|
}
|
|
1412
1651
|
const feedWriter = {
|
|
1413
1652
|
write: (data, options) => {
|
|
1414
|
-
(0,
|
|
1415
|
-
|
|
1653
|
+
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1654
|
+
F: __dxlog_file10,
|
|
1655
|
+
L: 154,
|
|
1656
|
+
S: this,
|
|
1657
|
+
A: [
|
|
1658
|
+
"this._pipeline",
|
|
1659
|
+
"'Pipeline is not initialized.'"
|
|
1660
|
+
]
|
|
1661
|
+
});
|
|
1662
|
+
(0, import_invariant8.invariant)(this.currentEpoch, "Epoch is not initialized.", {
|
|
1663
|
+
F: __dxlog_file10,
|
|
1664
|
+
L: 155,
|
|
1665
|
+
S: this,
|
|
1666
|
+
A: [
|
|
1667
|
+
"this.currentEpoch",
|
|
1668
|
+
"'Epoch is not initialized.'"
|
|
1669
|
+
]
|
|
1670
|
+
});
|
|
1416
1671
|
return this._pipeline.writer.write({
|
|
1417
1672
|
data
|
|
1418
1673
|
}, options);
|
|
@@ -1427,19 +1682,18 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1427
1682
|
this._isOpen = true;
|
|
1428
1683
|
}
|
|
1429
1684
|
async close() {
|
|
1430
|
-
var _a, _b, _c;
|
|
1431
1685
|
if (!this._isOpen) {
|
|
1432
1686
|
return;
|
|
1433
1687
|
}
|
|
1434
1688
|
(0, import_log9.log)("close", void 0, {
|
|
1435
|
-
F:
|
|
1436
|
-
L:
|
|
1689
|
+
F: __dxlog_file10,
|
|
1690
|
+
L: 179,
|
|
1437
1691
|
S: this,
|
|
1438
1692
|
C: (f, a) => f(...a)
|
|
1439
1693
|
});
|
|
1440
1694
|
this._isOpen = false;
|
|
1441
1695
|
await this._ctx.dispose();
|
|
1442
|
-
await
|
|
1696
|
+
await this._pipeline?.stop();
|
|
1443
1697
|
try {
|
|
1444
1698
|
await this._saveCache();
|
|
1445
1699
|
if (this._pipeline) {
|
|
@@ -1447,15 +1701,15 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1447
1701
|
}
|
|
1448
1702
|
} catch (err) {
|
|
1449
1703
|
import_log9.log.catch(err, void 0, {
|
|
1450
|
-
F:
|
|
1451
|
-
L:
|
|
1704
|
+
F: __dxlog_file10,
|
|
1705
|
+
L: 192,
|
|
1452
1706
|
S: this,
|
|
1453
1707
|
C: (f, a) => f(...a)
|
|
1454
1708
|
});
|
|
1455
1709
|
}
|
|
1456
|
-
await
|
|
1457
|
-
await
|
|
1458
|
-
this._ctx = new
|
|
1710
|
+
await this.databaseHost?.close();
|
|
1711
|
+
await this.itemManager?.destroy();
|
|
1712
|
+
this._ctx = new import_context6.Context();
|
|
1459
1713
|
this._pipeline = void 0;
|
|
1460
1714
|
this._targetTimeframe = void 0;
|
|
1461
1715
|
this._lastAutomaticSnapshotTimeframe = new import_timeframe4.Timeframe();
|
|
@@ -1470,15 +1724,25 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1470
1724
|
await this._processEpochInSeparateTask(this.currentEpoch);
|
|
1471
1725
|
await waitForOneEpoch;
|
|
1472
1726
|
}
|
|
1473
|
-
(0,
|
|
1727
|
+
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1728
|
+
F: __dxlog_file10,
|
|
1729
|
+
L: 215,
|
|
1730
|
+
S: this,
|
|
1731
|
+
A: [
|
|
1732
|
+
"this._pipeline",
|
|
1733
|
+
"'Pipeline is not initialized.'"
|
|
1734
|
+
]
|
|
1735
|
+
});
|
|
1474
1736
|
for await (const msg of this._pipeline.consume()) {
|
|
1737
|
+
const span = this._usage.beginRecording();
|
|
1738
|
+
this._mutations.inc();
|
|
1475
1739
|
const { feedKey, seq, data } = msg;
|
|
1476
1740
|
(0, import_log9.log)("processing message", {
|
|
1477
1741
|
feedKey,
|
|
1478
1742
|
seq
|
|
1479
1743
|
}, {
|
|
1480
|
-
F:
|
|
1481
|
-
L:
|
|
1744
|
+
F: __dxlog_file10,
|
|
1745
|
+
L: 221,
|
|
1482
1746
|
S: this,
|
|
1483
1747
|
C: (f, a) => f(...a)
|
|
1484
1748
|
});
|
|
@@ -1489,8 +1753,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1489
1753
|
import_log9.log.warn("Could not find feed", {
|
|
1490
1754
|
feedKey
|
|
1491
1755
|
}, {
|
|
1492
|
-
F:
|
|
1493
|
-
L:
|
|
1756
|
+
F: __dxlog_file10,
|
|
1757
|
+
L: 227,
|
|
1494
1758
|
S: this,
|
|
1495
1759
|
C: (f, a) => f(...a)
|
|
1496
1760
|
});
|
|
@@ -1512,8 +1776,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1512
1776
|
seq,
|
|
1513
1777
|
spaceKey: this._params.spaceKey.toHex()
|
|
1514
1778
|
}, {
|
|
1515
|
-
F:
|
|
1516
|
-
L:
|
|
1779
|
+
F: __dxlog_file10,
|
|
1780
|
+
L: 244,
|
|
1517
1781
|
S: this,
|
|
1518
1782
|
C: (f, a) => f(...a)
|
|
1519
1783
|
});
|
|
@@ -1521,16 +1785,25 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1521
1785
|
}
|
|
1522
1786
|
} catch (err) {
|
|
1523
1787
|
import_log9.log.catch(err, void 0, {
|
|
1524
|
-
F:
|
|
1525
|
-
L:
|
|
1788
|
+
F: __dxlog_file10,
|
|
1789
|
+
L: 254,
|
|
1526
1790
|
S: this,
|
|
1527
1791
|
C: (f, a) => f(...a)
|
|
1528
1792
|
});
|
|
1529
1793
|
}
|
|
1794
|
+
span.end();
|
|
1530
1795
|
}
|
|
1531
1796
|
}
|
|
1532
1797
|
_createSnapshot() {
|
|
1533
|
-
(0,
|
|
1798
|
+
(0, import_invariant8.invariant)(this.databaseHost, "Database backend is not initialized.", {
|
|
1799
|
+
F: __dxlog_file10,
|
|
1800
|
+
L: 262,
|
|
1801
|
+
S: this,
|
|
1802
|
+
A: [
|
|
1803
|
+
"this.databaseHost",
|
|
1804
|
+
"'Database backend is not initialized.'"
|
|
1805
|
+
]
|
|
1806
|
+
});
|
|
1534
1807
|
return {
|
|
1535
1808
|
spaceKey: this._params.spaceKey.asUint8Array(),
|
|
1536
1809
|
timeframe: this._pipeline.state.timeframe,
|
|
@@ -1538,26 +1811,22 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1538
1811
|
};
|
|
1539
1812
|
}
|
|
1540
1813
|
async _saveTargetTimeframe(timeframe) {
|
|
1541
|
-
|
|
1542
|
-
const newTimeframe = import_timeframe4.Timeframe.merge((_a = this._targetTimeframe) != null ? _a : new import_timeframe4.Timeframe(), timeframe);
|
|
1814
|
+
const newTimeframe = import_timeframe4.Timeframe.merge(this._targetTimeframe ?? new import_timeframe4.Timeframe(), timeframe);
|
|
1543
1815
|
await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
|
|
1544
1816
|
this._targetTimeframe = newTimeframe;
|
|
1545
1817
|
}
|
|
1546
1818
|
async _saveCache() {
|
|
1547
|
-
var _a;
|
|
1548
1819
|
const cache = {};
|
|
1549
1820
|
try {
|
|
1550
|
-
const propertiesItem = this.itemManager.items.find((item) =>
|
|
1551
|
-
|
|
1552
|
-
return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = (0, import_echo_db3.getStateMachineFromItem)(item)) == null ? void 0 : _b.snapshot()).type === "dxos.sdk.client.Properties";
|
|
1553
|
-
});
|
|
1821
|
+
const propertiesItem = this.itemManager.items.find((item) => item.modelMeta?.type === "dxos:model/document" && // TODO(burdon): Document?
|
|
1822
|
+
((0, import_echo_db3.getStateMachineFromItem)(item)?.snapshot()).type === import_echo_db3.TYPE_PROPERTIES);
|
|
1554
1823
|
if (propertiesItem) {
|
|
1555
|
-
cache.properties = (
|
|
1824
|
+
cache.properties = (0, import_echo_db3.getStateMachineFromItem)(propertiesItem)?.snapshot();
|
|
1556
1825
|
}
|
|
1557
1826
|
} catch (err) {
|
|
1558
1827
|
import_log9.log.warn("Failed to cache properties", err, {
|
|
1559
|
-
F:
|
|
1560
|
-
L:
|
|
1828
|
+
F: __dxlog_file10,
|
|
1829
|
+
L: 291,
|
|
1561
1830
|
S: this,
|
|
1562
1831
|
C: (f, a) => f(...a)
|
|
1563
1832
|
});
|
|
@@ -1574,24 +1843,23 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1574
1843
|
}
|
|
1575
1844
|
}
|
|
1576
1845
|
async _processEpochInSeparateTask(epoch) {
|
|
1577
|
-
var _a;
|
|
1578
1846
|
if (epoch.subject.assertion.number <= this._lastProcessedEpoch) {
|
|
1579
1847
|
return;
|
|
1580
1848
|
}
|
|
1581
|
-
await
|
|
1582
|
-
const ctx = new
|
|
1849
|
+
await this._epochCtx?.dispose();
|
|
1850
|
+
const ctx = new import_context6.Context({
|
|
1583
1851
|
onError: (err) => {
|
|
1584
1852
|
if (err instanceof import_errors2.CancelledError) {
|
|
1585
1853
|
(0, import_log9.log)("Epoch processing cancelled.", void 0, {
|
|
1586
|
-
F:
|
|
1587
|
-
L:
|
|
1854
|
+
F: __dxlog_file10,
|
|
1855
|
+
L: 323,
|
|
1588
1856
|
S: this,
|
|
1589
1857
|
C: (f, a) => f(...a)
|
|
1590
1858
|
});
|
|
1591
1859
|
} else {
|
|
1592
1860
|
import_log9.log.catch(err, void 0, {
|
|
1593
|
-
F:
|
|
1594
|
-
L:
|
|
1861
|
+
F: __dxlog_file10,
|
|
1862
|
+
L: 325,
|
|
1595
1863
|
S: this,
|
|
1596
1864
|
C: (f, a) => f(...a)
|
|
1597
1865
|
});
|
|
@@ -1603,28 +1871,36 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1603
1871
|
if (!this._isOpen) {
|
|
1604
1872
|
return;
|
|
1605
1873
|
}
|
|
1606
|
-
(0, import_log9.log)("process epoch", {
|
|
1607
|
-
epoch
|
|
1608
|
-
}, {
|
|
1609
|
-
F: __dxlog_file9,
|
|
1610
|
-
L: 322,
|
|
1611
|
-
S: this,
|
|
1612
|
-
C: (f, a) => f(...a)
|
|
1613
|
-
});
|
|
1614
1874
|
await this._processEpoch(ctx, epoch.subject.assertion);
|
|
1615
1875
|
this.appliedEpoch = epoch;
|
|
1616
1876
|
this.onNewEpoch.emit(epoch);
|
|
1617
1877
|
});
|
|
1618
1878
|
}
|
|
1619
1879
|
async _processEpoch(ctx, epoch) {
|
|
1620
|
-
(0,
|
|
1621
|
-
|
|
1880
|
+
(0, import_invariant8.invariant)(this._isOpen, "Space is closed.", {
|
|
1881
|
+
F: __dxlog_file10,
|
|
1882
|
+
L: 344,
|
|
1883
|
+
S: this,
|
|
1884
|
+
A: [
|
|
1885
|
+
"this._isOpen",
|
|
1886
|
+
"'Space is closed.'"
|
|
1887
|
+
]
|
|
1888
|
+
});
|
|
1889
|
+
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1890
|
+
F: __dxlog_file10,
|
|
1891
|
+
L: 345,
|
|
1892
|
+
S: this,
|
|
1893
|
+
A: [
|
|
1894
|
+
"this._pipeline",
|
|
1895
|
+
""
|
|
1896
|
+
]
|
|
1897
|
+
});
|
|
1622
1898
|
this._lastProcessedEpoch = epoch.number;
|
|
1623
|
-
(0, import_log9.log)("
|
|
1624
|
-
epoch
|
|
1899
|
+
(0, import_log9.log)("processing", {
|
|
1900
|
+
epoch: (0, import_log9.omit)(epoch, "proof")
|
|
1625
1901
|
}, {
|
|
1626
|
-
F:
|
|
1627
|
-
L:
|
|
1902
|
+
F: __dxlog_file10,
|
|
1903
|
+
L: 348,
|
|
1628
1904
|
S: this,
|
|
1629
1905
|
C: (f, a) => f(...a)
|
|
1630
1906
|
});
|
|
@@ -1632,9 +1908,9 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1632
1908
|
const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
|
|
1633
1909
|
this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
|
|
1634
1910
|
}
|
|
1635
|
-
(0, import_log9.log)("restarting pipeline
|
|
1636
|
-
F:
|
|
1637
|
-
L:
|
|
1911
|
+
(0, import_log9.log)("restarting pipeline from epoch", void 0, {
|
|
1912
|
+
F: __dxlog_file10,
|
|
1913
|
+
L: 354,
|
|
1638
1914
|
S: this,
|
|
1639
1915
|
C: (f, a) => f(...a)
|
|
1640
1916
|
});
|
|
@@ -1643,12 +1919,36 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1643
1919
|
await this._pipeline.unpause();
|
|
1644
1920
|
}
|
|
1645
1921
|
async waitUntilTimeframe(timeframe) {
|
|
1646
|
-
(0,
|
|
1922
|
+
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1923
|
+
F: __dxlog_file10,
|
|
1924
|
+
L: 361,
|
|
1925
|
+
S: this,
|
|
1926
|
+
A: [
|
|
1927
|
+
"this._pipeline",
|
|
1928
|
+
"'Pipeline is not initialized.'"
|
|
1929
|
+
]
|
|
1930
|
+
});
|
|
1647
1931
|
await this._pipeline.state.waitUntilTimeframe(timeframe);
|
|
1648
1932
|
}
|
|
1649
1933
|
async createEpoch() {
|
|
1650
|
-
(0,
|
|
1651
|
-
|
|
1934
|
+
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1935
|
+
F: __dxlog_file10,
|
|
1936
|
+
L: 367,
|
|
1937
|
+
S: this,
|
|
1938
|
+
A: [
|
|
1939
|
+
"this._pipeline",
|
|
1940
|
+
""
|
|
1941
|
+
]
|
|
1942
|
+
});
|
|
1943
|
+
(0, import_invariant8.invariant)(this.currentEpoch, void 0, {
|
|
1944
|
+
F: __dxlog_file10,
|
|
1945
|
+
L: 368,
|
|
1946
|
+
S: this,
|
|
1947
|
+
A: [
|
|
1948
|
+
"this.currentEpoch",
|
|
1949
|
+
""
|
|
1950
|
+
]
|
|
1951
|
+
});
|
|
1652
1952
|
await this._pipeline.pause();
|
|
1653
1953
|
const snapshot = await this._createSnapshot();
|
|
1654
1954
|
const snapshotCid = await this._params.snapshotManager.store(snapshot);
|
|
@@ -1665,24 +1965,31 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1665
1965
|
await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
|
|
1666
1966
|
}
|
|
1667
1967
|
};
|
|
1668
|
-
|
|
1968
|
+
_ts_decorate6([
|
|
1969
|
+
import_tracing2.trace.metricsCounter()
|
|
1970
|
+
], DataPipeline.prototype, "_usage", void 0);
|
|
1971
|
+
_ts_decorate6([
|
|
1972
|
+
import_tracing2.trace.metricsCounter()
|
|
1973
|
+
], DataPipeline.prototype, "_mutations", void 0);
|
|
1974
|
+
_ts_decorate6([
|
|
1669
1975
|
import_async6.synchronized
|
|
1670
1976
|
], DataPipeline.prototype, "open", null);
|
|
1671
|
-
|
|
1977
|
+
_ts_decorate6([
|
|
1672
1978
|
import_async6.synchronized
|
|
1673
1979
|
], DataPipeline.prototype, "close", null);
|
|
1674
|
-
|
|
1980
|
+
_ts_decorate6([
|
|
1675
1981
|
import_async6.synchronized
|
|
1676
1982
|
], DataPipeline.prototype, "_processEpoch", null);
|
|
1677
|
-
|
|
1983
|
+
_ts_decorate6([
|
|
1678
1984
|
import_async6.synchronized
|
|
1679
1985
|
], DataPipeline.prototype, "createEpoch", null);
|
|
1680
|
-
DataPipeline =
|
|
1681
|
-
(0, import_async6.trackLeaks)("open", "close")
|
|
1986
|
+
DataPipeline = _ts_decorate6([
|
|
1987
|
+
(0, import_async6.trackLeaks)("open", "close"),
|
|
1988
|
+
import_tracing2.trace.resource()
|
|
1682
1989
|
], DataPipeline);
|
|
1683
1990
|
|
|
1684
1991
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1685
|
-
function
|
|
1992
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1686
1993
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1687
1994
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1688
1995
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1692,14 +1999,22 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
1692
1999
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1693
2000
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1694
2001
|
}
|
|
1695
|
-
var
|
|
2002
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
1696
2003
|
var Space = class Space2 {
|
|
1697
2004
|
constructor(params) {
|
|
1698
2005
|
this._addFeedLock = new import_async7.Lock();
|
|
1699
2006
|
this.onCredentialProcessed = new import_util7.Callback();
|
|
1700
2007
|
this.stateUpdate = new import_async7.Event();
|
|
1701
2008
|
this._isOpen = false;
|
|
1702
|
-
(0,
|
|
2009
|
+
(0, import_invariant9.invariant)(params.spaceKey && params.feedProvider, void 0, {
|
|
2010
|
+
F: __dxlog_file11,
|
|
2011
|
+
L: 73,
|
|
2012
|
+
S: this,
|
|
2013
|
+
A: [
|
|
2014
|
+
"params.spaceKey && params.feedProvider",
|
|
2015
|
+
""
|
|
2016
|
+
]
|
|
2017
|
+
});
|
|
1703
2018
|
this._key = params.spaceKey;
|
|
1704
2019
|
this._genesisFeedKey = params.genesisFeed.key;
|
|
1705
2020
|
this._feedProvider = params.feedProvider;
|
|
@@ -1734,8 +2049,8 @@ var Space = class Space2 {
|
|
|
1734
2049
|
(0, import_log10.log)("onCredentialProcessed", {
|
|
1735
2050
|
credential
|
|
1736
2051
|
}, {
|
|
1737
|
-
F:
|
|
1738
|
-
L:
|
|
2052
|
+
F: __dxlog_file11,
|
|
2053
|
+
L: 109,
|
|
1739
2054
|
S: this,
|
|
1740
2055
|
C: (f, a) => f(...a)
|
|
1741
2056
|
});
|
|
@@ -1777,12 +2092,10 @@ var Space = class Space2 {
|
|
|
1777
2092
|
return this._genesisFeedKey;
|
|
1778
2093
|
}
|
|
1779
2094
|
get controlFeedKey() {
|
|
1780
|
-
|
|
1781
|
-
return (_a = this._controlFeed) == null ? void 0 : _a.key;
|
|
2095
|
+
return this._controlFeed?.key;
|
|
1782
2096
|
}
|
|
1783
2097
|
get dataFeedKey() {
|
|
1784
|
-
|
|
1785
|
-
return (_a = this._dataFeed) == null ? void 0 : _a.key;
|
|
2098
|
+
return this._dataFeed?.key;
|
|
1786
2099
|
}
|
|
1787
2100
|
get spaceState() {
|
|
1788
2101
|
return this._controlPipeline.spaceState;
|
|
@@ -1800,16 +2113,31 @@ var Space = class Space2 {
|
|
|
1800
2113
|
return this._snapshotManager;
|
|
1801
2114
|
}
|
|
1802
2115
|
setControlFeed(feed) {
|
|
1803
|
-
(0,
|
|
2116
|
+
(0, import_invariant9.invariant)(!this._controlFeed, "Control feed already set.", {
|
|
2117
|
+
F: __dxlog_file11,
|
|
2118
|
+
L: 184,
|
|
2119
|
+
S: this,
|
|
2120
|
+
A: [
|
|
2121
|
+
"!this._controlFeed",
|
|
2122
|
+
"'Control feed already set.'"
|
|
2123
|
+
]
|
|
2124
|
+
});
|
|
1804
2125
|
this._controlFeed = feed;
|
|
1805
2126
|
this._controlPipeline.setWriteFeed(feed);
|
|
1806
2127
|
return this;
|
|
1807
2128
|
}
|
|
1808
2129
|
setDataFeed(feed) {
|
|
1809
|
-
|
|
1810
|
-
|
|
2130
|
+
(0, import_invariant9.invariant)(!this._dataFeed, "Data feed already set.", {
|
|
2131
|
+
F: __dxlog_file11,
|
|
2132
|
+
L: 191,
|
|
2133
|
+
S: this,
|
|
2134
|
+
A: [
|
|
2135
|
+
"!this._dataFeed",
|
|
2136
|
+
"'Data feed already set.'"
|
|
2137
|
+
]
|
|
2138
|
+
});
|
|
1811
2139
|
this._dataFeed = feed;
|
|
1812
|
-
|
|
2140
|
+
this._dataPipeline.pipeline?.setWriteFeed(feed);
|
|
1813
2141
|
return this;
|
|
1814
2142
|
}
|
|
1815
2143
|
/**
|
|
@@ -1824,10 +2152,10 @@ var Space = class Space2 {
|
|
|
1824
2152
|
// getDataFeeds(): FeedInfo[] {
|
|
1825
2153
|
// return this._dataPipeline?.getFeeds();
|
|
1826
2154
|
// }
|
|
1827
|
-
async open() {
|
|
2155
|
+
async open(ctx) {
|
|
1828
2156
|
(0, import_log10.log)("opening...", void 0, {
|
|
1829
|
-
F:
|
|
1830
|
-
L:
|
|
2157
|
+
F: __dxlog_file11,
|
|
2158
|
+
L: 213,
|
|
1831
2159
|
S: this,
|
|
1832
2160
|
C: (f, a) => f(...a)
|
|
1833
2161
|
});
|
|
@@ -1839,8 +2167,8 @@ var Space = class Space2 {
|
|
|
1839
2167
|
await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
|
|
1840
2168
|
this._isOpen = true;
|
|
1841
2169
|
(0, import_log10.log)("opened", void 0, {
|
|
1842
|
-
F:
|
|
1843
|
-
L:
|
|
2170
|
+
F: __dxlog_file11,
|
|
2171
|
+
L: 224,
|
|
1844
2172
|
S: this,
|
|
1845
2173
|
C: (f, a) => f(...a)
|
|
1846
2174
|
});
|
|
@@ -1849,8 +2177,8 @@ var Space = class Space2 {
|
|
|
1849
2177
|
(0, import_log10.log)("closing...", {
|
|
1850
2178
|
key: this._key
|
|
1851
2179
|
}, {
|
|
1852
|
-
F:
|
|
1853
|
-
L:
|
|
2180
|
+
F: __dxlog_file11,
|
|
2181
|
+
L: 229,
|
|
1854
2182
|
S: this,
|
|
1855
2183
|
C: (f, a) => f(...a)
|
|
1856
2184
|
});
|
|
@@ -1863,42 +2191,53 @@ var Space = class Space2 {
|
|
|
1863
2191
|
await this._controlPipeline.stop();
|
|
1864
2192
|
this._isOpen = false;
|
|
1865
2193
|
(0, import_log10.log)("closed", void 0, {
|
|
1866
|
-
F:
|
|
1867
|
-
L:
|
|
2194
|
+
F: __dxlog_file11,
|
|
2195
|
+
L: 242,
|
|
1868
2196
|
S: this,
|
|
1869
2197
|
C: (f, a) => f(...a)
|
|
1870
2198
|
});
|
|
1871
2199
|
}
|
|
1872
2200
|
async initializeDataPipeline() {
|
|
1873
2201
|
(0, import_log10.log)("initializeDataPipeline", void 0, {
|
|
1874
|
-
F:
|
|
1875
|
-
L:
|
|
2202
|
+
F: __dxlog_file11,
|
|
2203
|
+
L: 247,
|
|
1876
2204
|
S: this,
|
|
1877
2205
|
C: (f, a) => f(...a)
|
|
1878
2206
|
});
|
|
1879
|
-
(0,
|
|
2207
|
+
(0, import_invariant9.invariant)(this._isOpen, "Space must be open to initialize data pipeline.", {
|
|
2208
|
+
F: __dxlog_file11,
|
|
2209
|
+
L: 248,
|
|
2210
|
+
S: this,
|
|
2211
|
+
A: [
|
|
2212
|
+
"this._isOpen",
|
|
2213
|
+
"'Space must be open to initialize data pipeline.'"
|
|
2214
|
+
]
|
|
2215
|
+
});
|
|
1880
2216
|
await this._dataPipeline.open();
|
|
1881
2217
|
}
|
|
1882
2218
|
};
|
|
1883
|
-
|
|
1884
|
-
import_log10.logInfo
|
|
2219
|
+
_ts_decorate7([
|
|
2220
|
+
import_log10.logInfo,
|
|
2221
|
+
import_tracing3.trace.info()
|
|
1885
2222
|
], Space.prototype, "key", null);
|
|
1886
|
-
|
|
1887
|
-
import_async7.synchronized
|
|
2223
|
+
_ts_decorate7([
|
|
2224
|
+
import_async7.synchronized,
|
|
2225
|
+
import_tracing3.trace.span()
|
|
1888
2226
|
], Space.prototype, "open", null);
|
|
1889
|
-
|
|
2227
|
+
_ts_decorate7([
|
|
1890
2228
|
import_async7.synchronized
|
|
1891
2229
|
], Space.prototype, "close", null);
|
|
1892
|
-
|
|
2230
|
+
_ts_decorate7([
|
|
1893
2231
|
import_async7.synchronized
|
|
1894
2232
|
], Space.prototype, "initializeDataPipeline", null);
|
|
1895
|
-
Space =
|
|
1896
|
-
(0, import_async7.trackLeaks)("open", "close")
|
|
2233
|
+
Space = _ts_decorate7([
|
|
2234
|
+
(0, import_async7.trackLeaks)("open", "close"),
|
|
2235
|
+
import_tracing3.trace.resource()
|
|
1897
2236
|
], Space);
|
|
1898
2237
|
|
|
1899
2238
|
// packages/core/echo/echo-pipeline/src/space/space-manager.ts
|
|
1900
2239
|
var import_async8 = require("@dxos/async");
|
|
1901
|
-
var
|
|
2240
|
+
var import_debug4 = require("@dxos/debug");
|
|
1902
2241
|
var import_keys6 = require("@dxos/keys");
|
|
1903
2242
|
var import_log12 = require("@dxos/log");
|
|
1904
2243
|
var import_protocols6 = require("@dxos/protocols");
|
|
@@ -1913,7 +2252,7 @@ var import_teleport2 = require("@dxos/teleport");
|
|
|
1913
2252
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
1914
2253
|
var import_teleport_extension_replicator = require("@dxos/teleport-extension-replicator");
|
|
1915
2254
|
var import_util8 = require("@dxos/util");
|
|
1916
|
-
function
|
|
2255
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
1917
2256
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1918
2257
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1919
2258
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1923,7 +2262,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1923
2262
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1924
2263
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1925
2264
|
}
|
|
1926
|
-
var
|
|
2265
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
|
|
1927
2266
|
var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
|
|
1928
2267
|
var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
1929
2268
|
var SpaceProtocol = class {
|
|
@@ -1953,8 +2292,8 @@ var SpaceProtocol = class {
|
|
|
1953
2292
|
(0, import_log11.log)("addFeed", {
|
|
1954
2293
|
key: feed.key
|
|
1955
2294
|
}, {
|
|
1956
|
-
F:
|
|
1957
|
-
L:
|
|
2295
|
+
F: __dxlog_file12,
|
|
2296
|
+
L: 96,
|
|
1958
2297
|
S: this,
|
|
1959
2298
|
C: (f, a) => f(...a)
|
|
1960
2299
|
});
|
|
@@ -1963,6 +2302,7 @@ var SpaceProtocol = class {
|
|
|
1963
2302
|
session.replicator.addFeed(feed);
|
|
1964
2303
|
}
|
|
1965
2304
|
}
|
|
2305
|
+
// TODO(burdon): Rename open? Common open/close interfaces for all services?
|
|
1966
2306
|
async start() {
|
|
1967
2307
|
if (this._connection) {
|
|
1968
2308
|
return;
|
|
@@ -1975,8 +2315,8 @@ var SpaceProtocol = class {
|
|
|
1975
2315
|
};
|
|
1976
2316
|
await this.blobSync.open();
|
|
1977
2317
|
(0, import_log11.log)("starting...", void 0, {
|
|
1978
|
-
F:
|
|
1979
|
-
L:
|
|
2318
|
+
F: __dxlog_file12,
|
|
2319
|
+
L: 122,
|
|
1980
2320
|
S: this,
|
|
1981
2321
|
C: (f, a) => f(...a)
|
|
1982
2322
|
});
|
|
@@ -1986,11 +2326,11 @@ var SpaceProtocol = class {
|
|
|
1986
2326
|
peerId: this._swarmIdentity.peerKey,
|
|
1987
2327
|
topic,
|
|
1988
2328
|
topology: new import_network_manager.MMSTTopology(topologyConfig),
|
|
1989
|
-
label: `
|
|
2329
|
+
label: `space swarm ${topic.truncate()}`
|
|
1990
2330
|
});
|
|
1991
2331
|
(0, import_log11.log)("started", void 0, {
|
|
1992
|
-
F:
|
|
1993
|
-
L:
|
|
2332
|
+
F: __dxlog_file12,
|
|
2333
|
+
L: 132,
|
|
1994
2334
|
S: this,
|
|
1995
2335
|
C: (f, a) => f(...a)
|
|
1996
2336
|
});
|
|
@@ -1999,15 +2339,15 @@ var SpaceProtocol = class {
|
|
|
1999
2339
|
await this.blobSync.close();
|
|
2000
2340
|
if (this._connection) {
|
|
2001
2341
|
(0, import_log11.log)("stopping...", void 0, {
|
|
2002
|
-
F:
|
|
2003
|
-
L:
|
|
2342
|
+
F: __dxlog_file12,
|
|
2343
|
+
L: 139,
|
|
2004
2344
|
S: this,
|
|
2005
2345
|
C: (f, a) => f(...a)
|
|
2006
2346
|
});
|
|
2007
2347
|
await this._connection.close();
|
|
2008
2348
|
(0, import_log11.log)("stopped", void 0, {
|
|
2009
|
-
F:
|
|
2010
|
-
L:
|
|
2349
|
+
F: __dxlog_file12,
|
|
2350
|
+
L: 141,
|
|
2011
2351
|
S: this,
|
|
2012
2352
|
C: (f, a) => f(...a)
|
|
2013
2353
|
});
|
|
@@ -2030,10 +2370,10 @@ var SpaceProtocol = class {
|
|
|
2030
2370
|
};
|
|
2031
2371
|
}
|
|
2032
2372
|
};
|
|
2033
|
-
|
|
2373
|
+
_ts_decorate8([
|
|
2034
2374
|
import_log11.logInfo
|
|
2035
2375
|
], SpaceProtocol.prototype, "_topic", void 0);
|
|
2036
|
-
|
|
2376
|
+
_ts_decorate8([
|
|
2037
2377
|
import_log11.logInfo
|
|
2038
2378
|
], SpaceProtocol.prototype, "_ownPeerKey", null);
|
|
2039
2379
|
var AuthStatus;
|
|
@@ -2072,20 +2412,18 @@ var SpaceProtocolSession = class {
|
|
|
2072
2412
|
provider: this._swarmIdentity.credentialProvider,
|
|
2073
2413
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
2074
2414
|
onAuthSuccess: () => {
|
|
2075
|
-
var _a;
|
|
2076
2415
|
(0, import_log11.log)("Peer authenticated", void 0, {
|
|
2077
|
-
F:
|
|
2078
|
-
L:
|
|
2416
|
+
F: __dxlog_file12,
|
|
2417
|
+
L: 238,
|
|
2079
2418
|
S: this,
|
|
2080
2419
|
C: (f, a) => f(...a)
|
|
2081
2420
|
});
|
|
2082
2421
|
this._authStatus = AuthStatus.SUCCESS;
|
|
2083
|
-
|
|
2422
|
+
this._onSessionAuth?.(this._teleport);
|
|
2084
2423
|
},
|
|
2085
2424
|
onAuthFailure: () => {
|
|
2086
|
-
var _a;
|
|
2087
2425
|
this._authStatus = AuthStatus.FAILURE;
|
|
2088
|
-
|
|
2426
|
+
this._onAuthFailure?.(this._teleport);
|
|
2089
2427
|
}
|
|
2090
2428
|
}));
|
|
2091
2429
|
this._teleport.addExtension("dxos.mesh.teleport.replicator", this.replicator);
|
|
@@ -2095,15 +2433,15 @@ var SpaceProtocolSession = class {
|
|
|
2095
2433
|
await this._teleport.close();
|
|
2096
2434
|
}
|
|
2097
2435
|
};
|
|
2098
|
-
|
|
2436
|
+
_ts_decorate8([
|
|
2099
2437
|
import_log11.logInfo
|
|
2100
2438
|
], SpaceProtocolSession.prototype, "_wireParams", void 0);
|
|
2101
|
-
|
|
2439
|
+
_ts_decorate8([
|
|
2102
2440
|
import_log11.logInfo
|
|
2103
2441
|
], SpaceProtocolSession.prototype, "authStatus", null);
|
|
2104
2442
|
|
|
2105
2443
|
// packages/core/echo/echo-pipeline/src/space/space-manager.ts
|
|
2106
|
-
function
|
|
2444
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
2107
2445
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2108
2446
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2109
2447
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2113,7 +2451,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
2113
2451
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2114
2452
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2115
2453
|
}
|
|
2116
|
-
var
|
|
2454
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
2117
2455
|
var SpaceManager = class SpaceManager2 {
|
|
2118
2456
|
constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
|
|
2119
2457
|
this._spaces = new import_util9.ComplexMap(import_keys6.PublicKey.hash);
|
|
@@ -2137,11 +2475,10 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2137
2475
|
].map((space) => space.close()));
|
|
2138
2476
|
}
|
|
2139
2477
|
async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
|
|
2140
|
-
var _a;
|
|
2141
2478
|
import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.begin({
|
|
2142
2479
|
id: this._instanceId
|
|
2143
2480
|
}), {
|
|
2144
|
-
F:
|
|
2481
|
+
F: __dxlog_file13,
|
|
2145
2482
|
L: 97,
|
|
2146
2483
|
S: this,
|
|
2147
2484
|
C: (f, a) => f(...a)
|
|
@@ -2149,12 +2486,12 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2149
2486
|
(0, import_log12.log)("constructing space...", {
|
|
2150
2487
|
spaceKey: metadata.genesisFeedKey
|
|
2151
2488
|
}, {
|
|
2152
|
-
F:
|
|
2489
|
+
F: __dxlog_file13,
|
|
2153
2490
|
L: 98,
|
|
2154
2491
|
S: this,
|
|
2155
2492
|
C: (f, a) => f(...a)
|
|
2156
2493
|
});
|
|
2157
|
-
const genesisFeed = await this._feedStore.openFeed(
|
|
2494
|
+
const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? (0, import_debug4.failUndefined)());
|
|
2158
2495
|
const spaceKey = metadata.key;
|
|
2159
2496
|
const protocol = new SpaceProtocol({
|
|
2160
2497
|
topic: spaceKey,
|
|
@@ -2179,21 +2516,21 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2179
2516
|
import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.end({
|
|
2180
2517
|
id: this._instanceId
|
|
2181
2518
|
}), {
|
|
2182
|
-
F:
|
|
2183
|
-
L:
|
|
2519
|
+
F: __dxlog_file13,
|
|
2520
|
+
L: 126,
|
|
2184
2521
|
S: this,
|
|
2185
2522
|
C: (f, a) => f(...a)
|
|
2186
2523
|
});
|
|
2187
2524
|
return space;
|
|
2188
2525
|
}
|
|
2189
2526
|
};
|
|
2190
|
-
|
|
2527
|
+
_ts_decorate9([
|
|
2191
2528
|
import_async8.synchronized
|
|
2192
2529
|
], SpaceManager.prototype, "open", null);
|
|
2193
|
-
|
|
2530
|
+
_ts_decorate9([
|
|
2194
2531
|
import_async8.synchronized
|
|
2195
2532
|
], SpaceManager.prototype, "close", null);
|
|
2196
|
-
SpaceManager =
|
|
2533
|
+
SpaceManager = _ts_decorate9([
|
|
2197
2534
|
(0, import_async8.trackLeaks)("open", "close")
|
|
2198
2535
|
], SpaceManager);
|
|
2199
2536
|
// Annotate the CommonJS export names for ESM import in node:
|