@dxos/echo-pipeline 0.8.1-staging.391c573 → 0.8.1-staging.97aedb1
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/index.mjs +159 -85
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +147 -79
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +159 -85
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/automerge/collection-synchronizer.d.ts.map +1 -1
- package/dist/types/src/automerge/mesh-echo-replicator-connection.d.ts +1 -0
- package/dist/types/src/automerge/mesh-echo-replicator-connection.d.ts.map +1 -1
- package/dist/types/src/automerge/mesh-echo-replicator.d.ts +8 -2
- package/dist/types/src/automerge/mesh-echo-replicator.d.ts.map +1 -1
- package/package.json +34 -34
- package/src/automerge/collection-synchronizer.ts +28 -0
- package/src/automerge/mesh-echo-replicator-connection.ts +5 -7
- package/src/automerge/mesh-echo-replicator.ts +44 -12
- package/src/edge/echo-edge-replicator.ts +6 -6
|
@@ -205,7 +205,7 @@ import { invariant as invariant3 } from "@dxos/invariant";
|
|
|
205
205
|
import { PublicKey } from "@dxos/keys";
|
|
206
206
|
import { log as log4 } from "@dxos/log";
|
|
207
207
|
import { objectPointerCodec } from "@dxos/protocols";
|
|
208
|
-
import { trace } from "@dxos/tracing";
|
|
208
|
+
import { trace as trace2 } from "@dxos/tracing";
|
|
209
209
|
import { bufferToArray } from "@dxos/util";
|
|
210
210
|
|
|
211
211
|
// packages/core/echo/echo-pipeline/src/automerge/collection-synchronizer.ts
|
|
@@ -213,7 +213,14 @@ import { asyncReturn, Event, scheduleTask, scheduleTaskInterval } from "@dxos/as
|
|
|
213
213
|
import { next as am } from "@dxos/automerge/automerge";
|
|
214
214
|
import { Resource as Resource2 } from "@dxos/context";
|
|
215
215
|
import { log as log2 } from "@dxos/log";
|
|
216
|
+
import { trace } from "@dxos/tracing";
|
|
216
217
|
import { defaultMap } from "@dxos/util";
|
|
218
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
219
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
220
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
221
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
222
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
223
|
+
}
|
|
217
224
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/collection-synchronizer.ts";
|
|
218
225
|
var MIN_QUERY_INTERVAL = 5e3;
|
|
219
226
|
var POLL_INTERVAL = 3e4;
|
|
@@ -256,7 +263,7 @@ var CollectionSynchronizer = class extends Resource2 {
|
|
|
256
263
|
state
|
|
257
264
|
}, {
|
|
258
265
|
F: __dxlog_file2,
|
|
259
|
-
L:
|
|
266
|
+
L: 75,
|
|
260
267
|
S: this,
|
|
261
268
|
C: (f, a) => f(...a)
|
|
262
269
|
});
|
|
@@ -275,7 +282,7 @@ var CollectionSynchronizer = class extends Resource2 {
|
|
|
275
282
|
collectionId
|
|
276
283
|
}, {
|
|
277
284
|
F: __dxlog_file2,
|
|
278
|
-
L:
|
|
285
|
+
L: 89,
|
|
279
286
|
S: this,
|
|
280
287
|
C: (f, a) => f(...a)
|
|
281
288
|
});
|
|
@@ -305,6 +312,17 @@ var CollectionSynchronizer = class extends Resource2 {
|
|
|
305
312
|
* Callback when a connection to a peer is established.
|
|
306
313
|
*/
|
|
307
314
|
onConnectionOpen(peerId) {
|
|
315
|
+
const spanId = getSpanName(peerId);
|
|
316
|
+
trace.spanStart({
|
|
317
|
+
id: spanId,
|
|
318
|
+
methodName: spanId,
|
|
319
|
+
instance: this,
|
|
320
|
+
parentCtx: this._ctx,
|
|
321
|
+
showInBrowserTimeline: true,
|
|
322
|
+
attributes: {
|
|
323
|
+
peerId
|
|
324
|
+
}
|
|
325
|
+
});
|
|
308
326
|
this._connectedPeers.add(peerId);
|
|
309
327
|
queueMicrotask(async () => {
|
|
310
328
|
if (this._ctx.disposed) {
|
|
@@ -347,7 +365,7 @@ var CollectionSynchronizer = class extends Resource2 {
|
|
|
347
365
|
state
|
|
348
366
|
}, {
|
|
349
367
|
F: __dxlog_file2,
|
|
350
|
-
L:
|
|
368
|
+
L: 170,
|
|
351
369
|
S: this,
|
|
352
370
|
C: (f, a) => f(...a)
|
|
353
371
|
});
|
|
@@ -357,6 +375,21 @@ var CollectionSynchronizer = class extends Resource2 {
|
|
|
357
375
|
documents: {}
|
|
358
376
|
};
|
|
359
377
|
const diff = diffCollectionState(existingState, state);
|
|
378
|
+
const spanId = getSpanName(peerId);
|
|
379
|
+
if (diff.different.length === 0) {
|
|
380
|
+
trace.spanEnd(spanId);
|
|
381
|
+
} else {
|
|
382
|
+
trace.spanStart({
|
|
383
|
+
id: spanId,
|
|
384
|
+
methodName: spanId,
|
|
385
|
+
instance: this,
|
|
386
|
+
parentCtx: this._ctx,
|
|
387
|
+
showInBrowserTimeline: true,
|
|
388
|
+
attributes: {
|
|
389
|
+
peerId
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
}
|
|
360
393
|
if (diff.missingOnLocal.length > 0 || diff.different.length > 0) {
|
|
361
394
|
perCollectionState.remoteStates.set(peerId, state);
|
|
362
395
|
this.remoteStateUpdated.emit({
|
|
@@ -384,6 +417,9 @@ var CollectionSynchronizer = class extends Resource2 {
|
|
|
384
417
|
}
|
|
385
418
|
}
|
|
386
419
|
};
|
|
420
|
+
CollectionSynchronizer = _ts_decorate([
|
|
421
|
+
trace.resource()
|
|
422
|
+
], CollectionSynchronizer);
|
|
387
423
|
var diffCollectionState = (local, remote) => {
|
|
388
424
|
const allDocuments = /* @__PURE__ */ new Set([
|
|
389
425
|
...Object.keys(local.documents),
|
|
@@ -420,6 +456,9 @@ var validateCollectionState = (state) => {
|
|
|
420
456
|
var isValidDocumentId = (documentId) => {
|
|
421
457
|
return typeof documentId === "string" && !documentId.includes(":");
|
|
422
458
|
};
|
|
459
|
+
var getSpanName = (peerId) => {
|
|
460
|
+
return `collection-sync-${peerId}`;
|
|
461
|
+
};
|
|
423
462
|
|
|
424
463
|
// packages/core/echo/echo-pipeline/src/automerge/echo-network-adapter.ts
|
|
425
464
|
import { synchronized, Trigger } from "@dxos/async";
|
|
@@ -435,7 +474,7 @@ var isCollectionQueryMessage = (message) => message.type === MESSAGE_TYPE_COLLEC
|
|
|
435
474
|
var isCollectionStateMessage = (message) => message.type === MESSAGE_TYPE_COLLECTION_STATE;
|
|
436
475
|
|
|
437
476
|
// packages/core/echo/echo-pipeline/src/automerge/echo-network-adapter.ts
|
|
438
|
-
function
|
|
477
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
439
478
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
440
479
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
441
480
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -764,16 +803,16 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
764
803
|
});
|
|
765
804
|
}
|
|
766
805
|
};
|
|
767
|
-
|
|
806
|
+
_ts_decorate2([
|
|
768
807
|
synchronized
|
|
769
808
|
], EchoNetworkAdapter.prototype, "open", null);
|
|
770
|
-
|
|
809
|
+
_ts_decorate2([
|
|
771
810
|
synchronized
|
|
772
811
|
], EchoNetworkAdapter.prototype, "close", null);
|
|
773
|
-
|
|
812
|
+
_ts_decorate2([
|
|
774
813
|
synchronized
|
|
775
814
|
], EchoNetworkAdapter.prototype, "addReplicator", null);
|
|
776
|
-
|
|
815
|
+
_ts_decorate2([
|
|
777
816
|
synchronized
|
|
778
817
|
], EchoNetworkAdapter.prototype, "removeReplicator", null);
|
|
779
818
|
var createEchoPeerMetadata = () => ({
|
|
@@ -911,7 +950,7 @@ var encodingOptions = {
|
|
|
911
950
|
var isLevelDbNotFoundError = (err) => err.code === "LEVEL_NOT_FOUND";
|
|
912
951
|
|
|
913
952
|
// packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts
|
|
914
|
-
function
|
|
953
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
915
954
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
916
955
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
917
956
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -1366,21 +1405,21 @@ var AutomergeHost = class extends Resource4 {
|
|
|
1366
1405
|
}
|
|
1367
1406
|
}
|
|
1368
1407
|
};
|
|
1369
|
-
|
|
1370
|
-
|
|
1408
|
+
_ts_decorate3([
|
|
1409
|
+
trace2.info()
|
|
1371
1410
|
], AutomergeHost.prototype, "_peerId", void 0);
|
|
1372
|
-
|
|
1373
|
-
|
|
1411
|
+
_ts_decorate3([
|
|
1412
|
+
trace2.info({
|
|
1374
1413
|
depth: null
|
|
1375
1414
|
})
|
|
1376
1415
|
], AutomergeHost.prototype, "_automergePeers", null);
|
|
1377
|
-
|
|
1378
|
-
|
|
1416
|
+
_ts_decorate3([
|
|
1417
|
+
trace2.span({
|
|
1379
1418
|
showInBrowserTimeline: true
|
|
1380
1419
|
})
|
|
1381
1420
|
], AutomergeHost.prototype, "flush", null);
|
|
1382
|
-
AutomergeHost =
|
|
1383
|
-
|
|
1421
|
+
AutomergeHost = _ts_decorate3([
|
|
1422
|
+
trace2.resource()
|
|
1384
1423
|
], AutomergeHost);
|
|
1385
1424
|
var getSpaceKeyFromDoc = (doc) => {
|
|
1386
1425
|
const rawSpaceKey = doc.access?.spaceKey ?? doc.experimental_spaceKey;
|
|
@@ -1486,7 +1525,7 @@ var MeshReplicatorConnection = class extends Resource5 {
|
|
|
1486
1525
|
remotePeerId: remotePeerId.toHex()
|
|
1487
1526
|
}, {
|
|
1488
1527
|
F: __dxlog_file5,
|
|
1489
|
-
L:
|
|
1528
|
+
L: 79,
|
|
1490
1529
|
S: this,
|
|
1491
1530
|
C: (f, a) => f(...a)
|
|
1492
1531
|
});
|
|
@@ -1513,7 +1552,7 @@ var MeshReplicatorConnection = class extends Resource5 {
|
|
|
1513
1552
|
get peerId() {
|
|
1514
1553
|
invariant4(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1515
1554
|
F: __dxlog_file5,
|
|
1516
|
-
L:
|
|
1555
|
+
L: 105,
|
|
1517
1556
|
S: this,
|
|
1518
1557
|
A: [
|
|
1519
1558
|
"this._remotePeerId != null",
|
|
@@ -1522,6 +1561,9 @@ var MeshReplicatorConnection = class extends Resource5 {
|
|
|
1522
1561
|
});
|
|
1523
1562
|
return this._remotePeerId;
|
|
1524
1563
|
}
|
|
1564
|
+
get isEnabled() {
|
|
1565
|
+
return this._isEnabled;
|
|
1566
|
+
}
|
|
1525
1567
|
async shouldAdvertise(params) {
|
|
1526
1568
|
return this._params.shouldAdvertise(params);
|
|
1527
1569
|
}
|
|
@@ -1535,7 +1577,7 @@ var MeshReplicatorConnection = class extends Resource5 {
|
|
|
1535
1577
|
enable() {
|
|
1536
1578
|
invariant4(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1537
1579
|
F: __dxlog_file5,
|
|
1538
|
-
L:
|
|
1580
|
+
L: 126,
|
|
1539
1581
|
S: this,
|
|
1540
1582
|
A: [
|
|
1541
1583
|
"this._remotePeerId != null",
|
|
@@ -1566,7 +1608,7 @@ var logSendSync = (message) => {
|
|
|
1566
1608
|
};
|
|
1567
1609
|
}, {
|
|
1568
1610
|
F: __dxlog_file5,
|
|
1569
|
-
L:
|
|
1611
|
+
L: 139,
|
|
1570
1612
|
S: void 0,
|
|
1571
1613
|
C: (f, a) => f(...a)
|
|
1572
1614
|
});
|
|
@@ -1595,12 +1637,18 @@ var getSpaceIdFromCollectionId = (collectionId) => {
|
|
|
1595
1637
|
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
|
|
1596
1638
|
var MeshEchoReplicator = class {
|
|
1597
1639
|
constructor() {
|
|
1598
|
-
this._connections = /* @__PURE__ */ new Set();
|
|
1599
1640
|
/**
|
|
1600
|
-
*
|
|
1641
|
+
* We might have multiple connections open with a peer (one per space), but there'll be only one enabled
|
|
1642
|
+
* connection at any given moment, because there's a single repo for all the spaces.
|
|
1643
|
+
* When a connection closes (space was closed) it gets removed from the list and the next connection
|
|
1644
|
+
* in the line gets enabled.
|
|
1601
1645
|
*/
|
|
1602
1646
|
this._connectionsPerPeer = /* @__PURE__ */ new Map();
|
|
1603
1647
|
/**
|
|
1648
|
+
* A set of all connections (enabled and disabled).
|
|
1649
|
+
*/
|
|
1650
|
+
this._connections = /* @__PURE__ */ new Set();
|
|
1651
|
+
/**
|
|
1604
1652
|
* spaceId -> deviceKey[]
|
|
1605
1653
|
*/
|
|
1606
1654
|
this._authorizedDevices = /* @__PURE__ */ new Map();
|
|
@@ -1610,8 +1658,10 @@ var MeshEchoReplicator = class {
|
|
|
1610
1658
|
this._context = context;
|
|
1611
1659
|
}
|
|
1612
1660
|
async disconnect() {
|
|
1613
|
-
for (const connection of this.
|
|
1614
|
-
|
|
1661
|
+
for (const connection of this._connections) {
|
|
1662
|
+
if (connection.isEnabled) {
|
|
1663
|
+
this._context?.onConnectionClosed(connection);
|
|
1664
|
+
}
|
|
1615
1665
|
}
|
|
1616
1666
|
for (const connection of this._connections) {
|
|
1617
1667
|
await connection.close();
|
|
@@ -1623,7 +1673,7 @@ var MeshEchoReplicator = class {
|
|
|
1623
1673
|
createExtension(extensionFactory) {
|
|
1624
1674
|
invariant6(this._context, void 0, {
|
|
1625
1675
|
F: __dxlog_file7,
|
|
1626
|
-
L:
|
|
1676
|
+
L: 67,
|
|
1627
1677
|
S: this,
|
|
1628
1678
|
A: [
|
|
1629
1679
|
"this._context",
|
|
@@ -1638,23 +1688,28 @@ var MeshEchoReplicator = class {
|
|
|
1638
1688
|
peerId: connection.peerId
|
|
1639
1689
|
}, {
|
|
1640
1690
|
F: __dxlog_file7,
|
|
1641
|
-
L:
|
|
1691
|
+
L: 73,
|
|
1642
1692
|
S: this,
|
|
1643
1693
|
C: (f, a) => f(...a)
|
|
1644
1694
|
});
|
|
1645
1695
|
invariant6(this._context, void 0, {
|
|
1646
1696
|
F: __dxlog_file7,
|
|
1647
|
-
L:
|
|
1697
|
+
L: 74,
|
|
1648
1698
|
S: this,
|
|
1649
1699
|
A: [
|
|
1650
1700
|
"this._context",
|
|
1651
1701
|
""
|
|
1652
1702
|
]
|
|
1653
1703
|
});
|
|
1654
|
-
|
|
1655
|
-
|
|
1704
|
+
const existingConnections = this._connectionsPerPeer.get(connection.peerId);
|
|
1705
|
+
if (existingConnections?.length) {
|
|
1706
|
+
const enabledConnection = existingConnections[0];
|
|
1707
|
+
this._context.onConnectionAuthScopeChanged(enabledConnection);
|
|
1708
|
+
existingConnections.push(connection);
|
|
1656
1709
|
} else {
|
|
1657
|
-
this._connectionsPerPeer.set(connection.peerId,
|
|
1710
|
+
this._connectionsPerPeer.set(connection.peerId, [
|
|
1711
|
+
connection
|
|
1712
|
+
]);
|
|
1658
1713
|
this._context.onConnectionOpen(connection);
|
|
1659
1714
|
connection.enable();
|
|
1660
1715
|
}
|
|
@@ -1664,14 +1719,33 @@ var MeshEchoReplicator = class {
|
|
|
1664
1719
|
peerId: connection.peerId
|
|
1665
1720
|
}, {
|
|
1666
1721
|
F: __dxlog_file7,
|
|
1667
|
-
L:
|
|
1722
|
+
L: 88,
|
|
1668
1723
|
S: this,
|
|
1669
1724
|
C: (f, a) => f(...a)
|
|
1670
1725
|
});
|
|
1671
|
-
this._context?.onConnectionClosed(connection);
|
|
1672
|
-
this._connectionsPerPeer.delete(connection.peerId);
|
|
1673
|
-
connection.disable();
|
|
1674
1726
|
this._connections.delete(connection);
|
|
1727
|
+
const existingConnections = this._connectionsPerPeer.get(connection.peerId) ?? [];
|
|
1728
|
+
const index = existingConnections.indexOf(connection);
|
|
1729
|
+
if (index < 0) {
|
|
1730
|
+
log6.warn("disconnected connection not found", {
|
|
1731
|
+
peerId: connection.peerId
|
|
1732
|
+
}, {
|
|
1733
|
+
F: __dxlog_file7,
|
|
1734
|
+
L: 96,
|
|
1735
|
+
S: this,
|
|
1736
|
+
C: (f, a) => f(...a)
|
|
1737
|
+
});
|
|
1738
|
+
return;
|
|
1739
|
+
}
|
|
1740
|
+
existingConnections.splice(index, 1);
|
|
1741
|
+
if (connection.isEnabled) {
|
|
1742
|
+
this._context?.onConnectionClosed(connection);
|
|
1743
|
+
connection.disable();
|
|
1744
|
+
if (existingConnections.length > 0) {
|
|
1745
|
+
this._context?.onConnectionOpen(existingConnections[0]);
|
|
1746
|
+
existingConnections[0].enable();
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1675
1749
|
},
|
|
1676
1750
|
shouldAdvertise: async (params) => {
|
|
1677
1751
|
log6("shouldAdvertise", {
|
|
@@ -1679,13 +1753,13 @@ var MeshEchoReplicator = class {
|
|
|
1679
1753
|
documentId: params.documentId
|
|
1680
1754
|
}, {
|
|
1681
1755
|
F: __dxlog_file7,
|
|
1682
|
-
L:
|
|
1756
|
+
L: 114,
|
|
1683
1757
|
S: this,
|
|
1684
1758
|
C: (f, a) => f(...a)
|
|
1685
1759
|
});
|
|
1686
1760
|
invariant6(this._context, void 0, {
|
|
1687
1761
|
F: __dxlog_file7,
|
|
1688
|
-
L:
|
|
1762
|
+
L: 115,
|
|
1689
1763
|
S: this,
|
|
1690
1764
|
A: [
|
|
1691
1765
|
"this._context",
|
|
@@ -1705,7 +1779,7 @@ var MeshEchoReplicator = class {
|
|
|
1705
1779
|
acceptDocument: remoteDocumentExists
|
|
1706
1780
|
}, {
|
|
1707
1781
|
F: __dxlog_file7,
|
|
1708
|
-
L:
|
|
1782
|
+
L: 123,
|
|
1709
1783
|
S: this,
|
|
1710
1784
|
C: (f, a) => f(...a)
|
|
1711
1785
|
});
|
|
@@ -1719,7 +1793,7 @@ var MeshEchoReplicator = class {
|
|
|
1719
1793
|
documentId: params.documentId
|
|
1720
1794
|
}, {
|
|
1721
1795
|
F: __dxlog_file7,
|
|
1722
|
-
L:
|
|
1796
|
+
L: 139,
|
|
1723
1797
|
S: this,
|
|
1724
1798
|
C: (f, a) => f(...a)
|
|
1725
1799
|
});
|
|
@@ -1735,7 +1809,7 @@ var MeshEchoReplicator = class {
|
|
|
1735
1809
|
isAuthorized
|
|
1736
1810
|
}, {
|
|
1737
1811
|
F: __dxlog_file7,
|
|
1738
|
-
L:
|
|
1812
|
+
L: 147,
|
|
1739
1813
|
S: this,
|
|
1740
1814
|
C: (f, a) => f(...a)
|
|
1741
1815
|
});
|
|
@@ -1743,7 +1817,7 @@ var MeshEchoReplicator = class {
|
|
|
1743
1817
|
} catch (err) {
|
|
1744
1818
|
log6.catch(err, void 0, {
|
|
1745
1819
|
F: __dxlog_file7,
|
|
1746
|
-
L:
|
|
1820
|
+
L: 157,
|
|
1747
1821
|
S: this,
|
|
1748
1822
|
C: (f, a) => f(...a)
|
|
1749
1823
|
});
|
|
@@ -1759,7 +1833,7 @@ var MeshEchoReplicator = class {
|
|
|
1759
1833
|
collectionId
|
|
1760
1834
|
}, {
|
|
1761
1835
|
F: __dxlog_file7,
|
|
1762
|
-
L:
|
|
1836
|
+
L: 167,
|
|
1763
1837
|
S: this,
|
|
1764
1838
|
C: (f, a) => f(...a)
|
|
1765
1839
|
});
|
|
@@ -1778,14 +1852,14 @@ var MeshEchoReplicator = class {
|
|
|
1778
1852
|
deviceKey
|
|
1779
1853
|
}, {
|
|
1780
1854
|
F: __dxlog_file7,
|
|
1781
|
-
L:
|
|
1855
|
+
L: 184,
|
|
1782
1856
|
S: this,
|
|
1783
1857
|
C: (f, a) => f(...a)
|
|
1784
1858
|
});
|
|
1785
1859
|
const spaceId = await createIdFromSpaceKey(spaceKey);
|
|
1786
1860
|
defaultMap2(this._authorizedDevices, spaceId, () => new ComplexSet(PublicKey2.hash)).add(deviceKey);
|
|
1787
1861
|
for (const connection of this._connections) {
|
|
1788
|
-
if (connection.remoteDeviceKey && connection.remoteDeviceKey.equals(deviceKey)) {
|
|
1862
|
+
if (connection.isEnabled && connection.remoteDeviceKey && connection.remoteDeviceKey.equals(deviceKey)) {
|
|
1789
1863
|
if (this._connectionsPerPeer.has(connection.peerId)) {
|
|
1790
1864
|
this._context?.onConnectionAuthScopeChanged(connection);
|
|
1791
1865
|
}
|
|
@@ -1795,9 +1869,9 @@ var MeshEchoReplicator = class {
|
|
|
1795
1869
|
};
|
|
1796
1870
|
|
|
1797
1871
|
// packages/core/echo/echo-pipeline/src/automerge/echo-data-monitor.ts
|
|
1798
|
-
import { trace as
|
|
1872
|
+
import { trace as trace3 } from "@dxos/tracing";
|
|
1799
1873
|
import { CircularBuffer, mapValues, SlidingWindowSummary } from "@dxos/util";
|
|
1800
|
-
function
|
|
1874
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
1801
1875
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1802
1876
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1803
1877
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -1930,14 +2004,14 @@ var EchoDataMonitor = class {
|
|
|
1930
2004
|
for (const [metricName, metric, summary] of toReport) {
|
|
1931
2005
|
summary.record(metric);
|
|
1932
2006
|
if (metric > 0) {
|
|
1933
|
-
|
|
1934
|
-
|
|
2007
|
+
trace3.metrics.distribution(`dxos.echo.${metricName}-rate`, metric);
|
|
2008
|
+
trace3.metrics.increment(`dxos.echo.${metricName}`, 1, {
|
|
1935
2009
|
tags: {
|
|
1936
2010
|
status: "busy"
|
|
1937
2011
|
}
|
|
1938
2012
|
});
|
|
1939
2013
|
} else {
|
|
1940
|
-
|
|
2014
|
+
trace3.metrics.increment(`dxos.echo.${metricName}`, 1, {
|
|
1941
2015
|
tags: {
|
|
1942
2016
|
status: "idle"
|
|
1943
2017
|
}
|
|
@@ -1958,7 +2032,7 @@ var EchoDataMonitor = class {
|
|
|
1958
2032
|
this._activeCounters.storage.storedChunks++;
|
|
1959
2033
|
this._activeCounters.storage.storedBytes += count;
|
|
1960
2034
|
this._storageAverages.storedChunkSize.record(count);
|
|
1961
|
-
|
|
2035
|
+
trace3.metrics.distribution("dxos.echo.storage.bytes-stored", count, {
|
|
1962
2036
|
unit: "bytes"
|
|
1963
2037
|
});
|
|
1964
2038
|
}
|
|
@@ -1972,7 +2046,7 @@ var EchoDataMonitor = class {
|
|
|
1972
2046
|
this._activeCounters.storage.loadedChunks++;
|
|
1973
2047
|
this._activeCounters.storage.loadedBytes += count;
|
|
1974
2048
|
this._storageAverages.loadedChunkSize.record(count);
|
|
1975
|
-
|
|
2049
|
+
trace3.metrics.distribution("dxos.echo.storage.bytes-loaded", count, {
|
|
1976
2050
|
unit: "bytes"
|
|
1977
2051
|
});
|
|
1978
2052
|
}
|
|
@@ -1990,15 +2064,15 @@ var EchoDataMonitor = class {
|
|
|
1990
2064
|
} else {
|
|
1991
2065
|
metricsGroupName = "collection-sync";
|
|
1992
2066
|
}
|
|
1993
|
-
|
|
2067
|
+
trace3.metrics.distribution(`dxos.echo.${metricsGroupName}.bytes-sent`, bytes, {
|
|
1994
2068
|
unit: "bytes",
|
|
1995
2069
|
tags
|
|
1996
2070
|
});
|
|
1997
|
-
|
|
2071
|
+
trace3.metrics.distribution(`dxos.echo.${metricsGroupName}.send-duration`, duration, {
|
|
1998
2072
|
unit: "millisecond",
|
|
1999
2073
|
tags
|
|
2000
2074
|
});
|
|
2001
|
-
|
|
2075
|
+
trace3.metrics.increment(`dxos.echo.${metricsGroupName}.send-status`, 1, {
|
|
2002
2076
|
tags: {
|
|
2003
2077
|
...tags,
|
|
2004
2078
|
success: true
|
|
@@ -2020,12 +2094,12 @@ var EchoDataMonitor = class {
|
|
|
2020
2094
|
if (isAutomergeProtocolMessage(message)) {
|
|
2021
2095
|
this._activeCounters.replication.received++;
|
|
2022
2096
|
this._replicationAverages.receivedMessageSize.record(bytes);
|
|
2023
|
-
|
|
2097
|
+
trace3.metrics.distribution("dxos.echo.replication.bytes-received", bytes, {
|
|
2024
2098
|
unit: "bytes",
|
|
2025
2099
|
tags
|
|
2026
2100
|
});
|
|
2027
2101
|
} else {
|
|
2028
|
-
|
|
2102
|
+
trace3.metrics.distribution("dxos.echo.collection-sync.bytes-received", bytes, {
|
|
2029
2103
|
unit: "bytes",
|
|
2030
2104
|
tags
|
|
2031
2105
|
});
|
|
@@ -2045,12 +2119,12 @@ var EchoDataMonitor = class {
|
|
|
2045
2119
|
};
|
|
2046
2120
|
if (isAutomergeProtocolMessage(message)) {
|
|
2047
2121
|
this._activeCounters.replication.failed++;
|
|
2048
|
-
|
|
2122
|
+
trace3.metrics.increment("dxos.echo.replication.send-status", 1, {
|
|
2049
2123
|
unit: "bytes",
|
|
2050
2124
|
tags
|
|
2051
2125
|
});
|
|
2052
2126
|
} else {
|
|
2053
|
-
|
|
2127
|
+
trace3.metrics.increment("dxos.echo.collection-sync.send-status", 1, {
|
|
2054
2128
|
unit: "bytes",
|
|
2055
2129
|
tags
|
|
2056
2130
|
});
|
|
@@ -2085,8 +2159,8 @@ var EchoDataMonitor = class {
|
|
|
2085
2159
|
return result;
|
|
2086
2160
|
}
|
|
2087
2161
|
};
|
|
2088
|
-
EchoDataMonitor =
|
|
2089
|
-
|
|
2162
|
+
EchoDataMonitor = _ts_decorate4([
|
|
2163
|
+
trace3.resource()
|
|
2090
2164
|
], EchoDataMonitor);
|
|
2091
2165
|
var isAutomergeProtocolMessage = (message) => {
|
|
2092
2166
|
return !(isCollectionQueryMessage(message) || isCollectionStateMessage(message));
|
|
@@ -2304,7 +2378,7 @@ import { createIdFromSpaceKey as createIdFromSpaceKey3, SpaceDocVersion as Space
|
|
|
2304
2378
|
import { IndexMetadataStore, IndexStore, Indexer } from "@dxos/indexing";
|
|
2305
2379
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
2306
2380
|
import { IndexKind } from "@dxos/protocols/proto/dxos/echo/indexing";
|
|
2307
|
-
import { trace as
|
|
2381
|
+
import { trace as trace6 } from "@dxos/tracing";
|
|
2308
2382
|
|
|
2309
2383
|
// packages/core/echo/echo-pipeline/src/db-host/documents-iterator.ts
|
|
2310
2384
|
import * as A3 from "@dxos/automerge/automerge";
|
|
@@ -2401,7 +2475,7 @@ import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
|
|
|
2401
2475
|
import { Context as Context4, Resource as Resource7 } from "@dxos/context";
|
|
2402
2476
|
import { log as log9 } from "@dxos/log";
|
|
2403
2477
|
import { objectPointerCodec as objectPointerCodec4 } from "@dxos/protocols";
|
|
2404
|
-
import { trace as
|
|
2478
|
+
import { trace as trace5 } from "@dxos/tracing";
|
|
2405
2479
|
|
|
2406
2480
|
// packages/core/echo/echo-pipeline/src/db-host/query-state.ts
|
|
2407
2481
|
import { Context as Context3, LifecycleState as LifecycleState3, Resource as Resource6 } from "@dxos/context";
|
|
@@ -2409,9 +2483,9 @@ import { createIdFromSpaceKey as createIdFromSpaceKey2 } from "@dxos/echo-protoc
|
|
|
2409
2483
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2410
2484
|
import { DXN, PublicKey as PublicKey3 } from "@dxos/keys";
|
|
2411
2485
|
import { objectPointerCodec as objectPointerCodec3 } from "@dxos/protocols";
|
|
2412
|
-
import { trace as
|
|
2486
|
+
import { trace as trace4 } from "@dxos/tracing";
|
|
2413
2487
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
2414
|
-
function
|
|
2488
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
2415
2489
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2416
2490
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2417
2491
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -2511,19 +2585,19 @@ var QueryState = class extends Resource6 {
|
|
|
2511
2585
|
};
|
|
2512
2586
|
}
|
|
2513
2587
|
};
|
|
2514
|
-
|
|
2515
|
-
|
|
2588
|
+
_ts_decorate5([
|
|
2589
|
+
trace4.info({
|
|
2516
2590
|
depth: null
|
|
2517
2591
|
})
|
|
2518
2592
|
], QueryState.prototype, "filter", void 0);
|
|
2519
|
-
|
|
2520
|
-
|
|
2593
|
+
_ts_decorate5([
|
|
2594
|
+
trace4.info()
|
|
2521
2595
|
], QueryState.prototype, "metrics", void 0);
|
|
2522
|
-
|
|
2523
|
-
|
|
2596
|
+
_ts_decorate5([
|
|
2597
|
+
trace4.info()
|
|
2524
2598
|
], QueryState.prototype, "active", null);
|
|
2525
|
-
|
|
2526
|
-
|
|
2599
|
+
_ts_decorate5([
|
|
2600
|
+
trace4.span({
|
|
2527
2601
|
showInBrowserTimeline: true,
|
|
2528
2602
|
op: "db.query",
|
|
2529
2603
|
attributes: {
|
|
@@ -2531,8 +2605,8 @@ _ts_decorate4([
|
|
|
2531
2605
|
}
|
|
2532
2606
|
})
|
|
2533
2607
|
], QueryState.prototype, "execQuery", null);
|
|
2534
|
-
QueryState =
|
|
2535
|
-
|
|
2608
|
+
QueryState = _ts_decorate5([
|
|
2609
|
+
trace4.resource()
|
|
2536
2610
|
], QueryState);
|
|
2537
2611
|
var filterToIndexQuery = (filter) => {
|
|
2538
2612
|
invariant9(!(filter.type && (filter.or ?? []).length > 0), "Cannot mix type and or filters.", {
|
|
@@ -2600,7 +2674,7 @@ var QueryServiceImpl = class extends Resource7 {
|
|
|
2600
2674
|
}
|
|
2601
2675
|
}));
|
|
2602
2676
|
});
|
|
2603
|
-
|
|
2677
|
+
trace5.diagnostic({
|
|
2604
2678
|
id: "active-queries",
|
|
2605
2679
|
name: "Active Queries",
|
|
2606
2680
|
fetch: () => {
|
|
@@ -3015,7 +3089,7 @@ var EchoHost = class extends Resource9 {
|
|
|
3015
3089
|
await this._indexer.updateIndexes();
|
|
3016
3090
|
}
|
|
3017
3091
|
});
|
|
3018
|
-
|
|
3092
|
+
trace6.diagnostic({
|
|
3019
3093
|
id: "echo-stats",
|
|
3020
3094
|
name: "Echo Stats",
|
|
3021
3095
|
fetch: async () => {
|
|
@@ -3025,7 +3099,7 @@ var EchoHost = class extends Resource9 {
|
|
|
3025
3099
|
};
|
|
3026
3100
|
}
|
|
3027
3101
|
});
|
|
3028
|
-
|
|
3102
|
+
trace6.diagnostic({
|
|
3029
3103
|
id: "database-roots",
|
|
3030
3104
|
name: "Database Roots",
|
|
3031
3105
|
fetch: async () => {
|
|
@@ -3038,7 +3112,7 @@ var EchoHost = class extends Resource9 {
|
|
|
3038
3112
|
}));
|
|
3039
3113
|
}
|
|
3040
3114
|
});
|
|
3041
|
-
|
|
3115
|
+
trace6.diagnostic({
|
|
3042
3116
|
id: "database-root-metrics",
|
|
3043
3117
|
name: "Database Roots (with metrics)",
|
|
3044
3118
|
fetch: async () => {
|
|
@@ -3323,7 +3397,7 @@ var EchoEdgeReplicator = class {
|
|
|
3323
3397
|
this._sharePolicyEnabled = !disableSharePolicy;
|
|
3324
3398
|
}
|
|
3325
3399
|
async connect(context) {
|
|
3326
|
-
log12.info("
|
|
3400
|
+
log12.info("connecting...", {
|
|
3327
3401
|
peerId: context.peerId,
|
|
3328
3402
|
connectedSpaces: this._connectedSpaces.size
|
|
3329
3403
|
}, {
|
|
@@ -3516,7 +3590,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
3516
3590
|
});
|
|
3517
3591
|
}
|
|
3518
3592
|
async _open(ctx) {
|
|
3519
|
-
log12("
|
|
3593
|
+
log12("opening...", void 0, {
|
|
3520
3594
|
F: __dxlog_file17,
|
|
3521
3595
|
L: 251,
|
|
3522
3596
|
S: this,
|
|
@@ -3529,7 +3603,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
3529
3603
|
await this._onRemoteConnected();
|
|
3530
3604
|
}
|
|
3531
3605
|
async _close() {
|
|
3532
|
-
log12("
|
|
3606
|
+
log12("closing...", void 0, {
|
|
3533
3607
|
F: __dxlog_file17,
|
|
3534
3608
|
L: 266,
|
|
3535
3609
|
S: this,
|
|
@@ -3561,7 +3635,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
3561
3635
|
documentId: params.documentId,
|
|
3562
3636
|
peerId: this._remotePeerId
|
|
3563
3637
|
});
|
|
3564
|
-
log12.verbose("
|
|
3638
|
+
log12.verbose("document not found locally for share policy check", {
|
|
3565
3639
|
documentId: params.documentId,
|
|
3566
3640
|
acceptDocument: remoteDocumentExists,
|
|
3567
3641
|
remoteId: this._remotePeerId
|
|
@@ -3587,7 +3661,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
3587
3661
|
return;
|
|
3588
3662
|
}
|
|
3589
3663
|
const payload = cbor2.decode(message.payload.value);
|
|
3590
|
-
log12.verbose("
|
|
3664
|
+
log12.verbose("received", {
|
|
3591
3665
|
type: payload.type,
|
|
3592
3666
|
documentId: payload.type === "sync" && payload.documentId,
|
|
3593
3667
|
remoteId: this._remotePeerId
|
|
@@ -3610,7 +3684,7 @@ var EdgeReplicatorConnection = class extends Resource11 {
|
|
|
3610
3684
|
}
|
|
3611
3685
|
async _sendMessage(message) {
|
|
3612
3686
|
message.targetId = this._targetServiceId;
|
|
3613
|
-
log12.verbose("
|
|
3687
|
+
log12.verbose("sending...", {
|
|
3614
3688
|
type: message.type,
|
|
3615
3689
|
documentId: message.type === "sync" && message.documentId,
|
|
3616
3690
|
remoteId: this._remotePeerId
|