@dxos/echo-pipeline 0.6.4 → 0.6.5-staging.435ed25
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-6MJEONOX.mjs → chunk-2MII6KJX.mjs} +464 -104
- package/dist/lib/browser/chunk-2MII6KJX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-PT5LWMPA.cjs → chunk-6MWU4MHX.cjs} +475 -116
- package/dist/lib/node/chunk-6MWU4MHX.cjs.map +7 -0
- package/dist/lib/node/index.cjs +36 -34
- package/dist/lib/node/index.cjs.map +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +11 -11
- package/dist/types/src/automerge/automerge-host.d.ts +3 -2
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-data-monitor.d.ts +73 -0
- package/dist/types/src/automerge/echo-data-monitor.d.ts.map +1 -0
- package/dist/types/src/automerge/echo-data-monitor.test.d.ts +2 -0
- package/dist/types/src/automerge/echo-data-monitor.test.d.ts.map +1 -0
- package/dist/types/src/automerge/echo-network-adapter.d.ts +9 -0
- package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
- package/dist/types/src/automerge/index.d.ts +1 -0
- package/dist/types/src/automerge/index.d.ts.map +1 -1
- package/dist/types/src/automerge/leveldb-storage-adapter.d.ts +7 -0
- package/dist/types/src/automerge/leveldb-storage-adapter.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +0 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/package.json +41 -39
- package/src/automerge/automerge-host.ts +11 -34
- package/src/automerge/echo-data-monitor.test.ts +55 -0
- package/src/automerge/echo-data-monitor.ts +374 -0
- package/src/automerge/echo-network-adapter.ts +37 -13
- package/src/automerge/index.ts +1 -0
- package/src/automerge/leveldb-storage-adapter.ts +19 -1
- package/src/space/space.ts +1 -3
- package/dist/lib/browser/chunk-6MJEONOX.mjs.map +0 -7
- package/dist/lib/node/chunk-PT5LWMPA.cjs.map +0 -7
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_6MWU4MHX_exports = {};
|
|
30
|
+
__export(chunk_6MWU4MHX_exports, {
|
|
31
31
|
AuthExtension: () => AuthExtension,
|
|
32
32
|
AuthStatus: () => AuthStatus,
|
|
33
33
|
AutomergeHost: () => AutomergeHost,
|
|
@@ -35,6 +35,7 @@ __export(chunk_PT5LWMPA_exports, {
|
|
|
35
35
|
CredentialServerExtension: () => CredentialServerExtension,
|
|
36
36
|
DataServiceImpl: () => DataServiceImpl,
|
|
37
37
|
DocumentsSynchronizer: () => DocumentsSynchronizer,
|
|
38
|
+
EchoDataMonitor: () => EchoDataMonitor,
|
|
38
39
|
LevelDBStorageAdapter: () => LevelDBStorageAdapter,
|
|
39
40
|
MOCK_AUTH_PROVIDER: () => MOCK_AUTH_PROVIDER,
|
|
40
41
|
MOCK_AUTH_VERIFIER: () => MOCK_AUTH_VERIFIER,
|
|
@@ -62,7 +63,7 @@ __export(chunk_PT5LWMPA_exports, {
|
|
|
62
63
|
startAfter: () => startAfter,
|
|
63
64
|
valueEncoding: () => valueEncoding
|
|
64
65
|
});
|
|
65
|
-
module.exports = __toCommonJS(
|
|
66
|
+
module.exports = __toCommonJS(chunk_6MWU4MHX_exports);
|
|
66
67
|
var import_hypercore = require("@dxos/hypercore");
|
|
67
68
|
var import_protocols = require("@dxos/protocols");
|
|
68
69
|
var import_invariant = require("@dxos/invariant");
|
|
@@ -91,13 +92,12 @@ var import_keys2 = require("@dxos/keys");
|
|
|
91
92
|
var import_log2 = require("@dxos/log");
|
|
92
93
|
var import_protocols4 = require("@dxos/protocols");
|
|
93
94
|
var import_tracing = require("@dxos/tracing");
|
|
94
|
-
var import_util2 = require("@dxos/util");
|
|
95
95
|
var import_async4 = require("@dxos/async");
|
|
96
96
|
var import_automerge_repo2 = require("@dxos/automerge/automerge-repo");
|
|
97
97
|
var import_context6 = require("@dxos/context");
|
|
98
98
|
var import_invariant4 = require("@dxos/invariant");
|
|
99
99
|
var import_log3 = require("@dxos/log");
|
|
100
|
-
var
|
|
100
|
+
var import_util2 = require("@dxos/util");
|
|
101
101
|
var import_indexing = require("@dxos/indexing");
|
|
102
102
|
var import_invariant5 = require("@dxos/invariant");
|
|
103
103
|
var import_keys3 = require("@dxos/keys");
|
|
@@ -120,7 +120,7 @@ var import_invariant7 = require("@dxos/invariant");
|
|
|
120
120
|
var import_keys4 = require("@dxos/keys");
|
|
121
121
|
var import_log6 = require("@dxos/log");
|
|
122
122
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
123
|
-
var
|
|
123
|
+
var import_util3 = require("@dxos/util");
|
|
124
124
|
var import_invariant8 = require("@dxos/invariant");
|
|
125
125
|
var import_log7 = require("@dxos/log");
|
|
126
126
|
var import_async8 = require("@dxos/async");
|
|
@@ -131,7 +131,7 @@ var import_keys5 = require("@dxos/keys");
|
|
|
131
131
|
var import_log8 = require("@dxos/log");
|
|
132
132
|
var import_credentials = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
133
133
|
var import_tracing2 = require("@dxos/tracing");
|
|
134
|
-
var
|
|
134
|
+
var import_util4 = require("@dxos/util");
|
|
135
135
|
var import_async9 = require("@dxos/async");
|
|
136
136
|
var import_context10 = require("@dxos/context");
|
|
137
137
|
var import_credentials2 = require("@dxos/credentials");
|
|
@@ -140,7 +140,7 @@ var import_log9 = require("@dxos/log");
|
|
|
140
140
|
var import_credentials3 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
141
141
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
142
142
|
var import_tracing3 = require("@dxos/tracing");
|
|
143
|
-
var
|
|
143
|
+
var import_util5 = require("@dxos/util");
|
|
144
144
|
var import_async10 = require("@dxos/async");
|
|
145
145
|
var import_context11 = require("@dxos/context");
|
|
146
146
|
var import_protocols6 = require("@dxos/protocols");
|
|
@@ -153,13 +153,13 @@ var import_teleport3 = require("@dxos/teleport");
|
|
|
153
153
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
154
154
|
var import_teleport_extension_replicator = require("@dxos/teleport-extension-replicator");
|
|
155
155
|
var import_tracing4 = require("@dxos/tracing");
|
|
156
|
-
var
|
|
156
|
+
var import_util6 = require("@dxos/util");
|
|
157
157
|
var import_async11 = require("@dxos/async");
|
|
158
158
|
var import_debug3 = require("@dxos/debug");
|
|
159
159
|
var import_keys8 = require("@dxos/keys");
|
|
160
160
|
var import_log11 = require("@dxos/log");
|
|
161
161
|
var import_protocols7 = require("@dxos/protocols");
|
|
162
|
-
var
|
|
162
|
+
var import_util7 = require("@dxos/util");
|
|
163
163
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
164
164
|
var import_invariant10 = require("@dxos/invariant");
|
|
165
165
|
var import_keys9 = require("@dxos/keys");
|
|
@@ -167,12 +167,14 @@ var import_log12 = require("@dxos/log");
|
|
|
167
167
|
var import_invariant11 = require("@dxos/invariant");
|
|
168
168
|
var import_keys10 = require("@dxos/keys");
|
|
169
169
|
var import_log13 = require("@dxos/log");
|
|
170
|
-
var
|
|
170
|
+
var import_util8 = require("@dxos/util");
|
|
171
171
|
var import_automerge_repo3 = require("@dxos/automerge/automerge-repo");
|
|
172
172
|
var import_context12 = require("@dxos/context");
|
|
173
173
|
var import_invariant12 = require("@dxos/invariant");
|
|
174
174
|
var import_log14 = require("@dxos/log");
|
|
175
175
|
var import_teleport_extension_automerge_replicator = require("@dxos/teleport-extension-automerge-replicator");
|
|
176
|
+
var import_tracing5 = require("@dxos/tracing");
|
|
177
|
+
var import_util9 = require("@dxos/util");
|
|
176
178
|
var import_crc_32 = __toESM(require("crc-32"));
|
|
177
179
|
var import_async12 = require("@dxos/async");
|
|
178
180
|
var import_context13 = require("@dxos/context");
|
|
@@ -586,9 +588,13 @@ var LevelDBStorageAdapter = class extends import_context4.Resource {
|
|
|
586
588
|
if (this._lifecycleState !== import_context4.LifecycleState.OPEN) {
|
|
587
589
|
return void 0;
|
|
588
590
|
}
|
|
589
|
-
|
|
591
|
+
const startMs = Date.now();
|
|
592
|
+
const chunk = await this._params.db.get(keyArray, {
|
|
590
593
|
...encodingOptions
|
|
591
594
|
});
|
|
595
|
+
this._params.monitor?.recordBytesLoaded(chunk.byteLength);
|
|
596
|
+
this._params.monitor?.recordLoadDuration(Date.now() - startMs);
|
|
597
|
+
return chunk;
|
|
592
598
|
} catch (err) {
|
|
593
599
|
if (isLevelDbNotFoundError(err)) {
|
|
594
600
|
return void 0;
|
|
@@ -600,6 +606,7 @@ var LevelDBStorageAdapter = class extends import_context4.Resource {
|
|
|
600
606
|
if (this._lifecycleState !== import_context4.LifecycleState.OPEN) {
|
|
601
607
|
return void 0;
|
|
602
608
|
}
|
|
609
|
+
const startMs = Date.now();
|
|
603
610
|
const batch = this._params.db.batch();
|
|
604
611
|
await this._params.callbacks?.beforeSave?.({
|
|
605
612
|
path: keyArray,
|
|
@@ -609,7 +616,9 @@ var LevelDBStorageAdapter = class extends import_context4.Resource {
|
|
|
609
616
|
...encodingOptions
|
|
610
617
|
});
|
|
611
618
|
await batch.write();
|
|
619
|
+
this._params.monitor?.recordBytesStored(binary.byteLength);
|
|
612
620
|
await this._params.callbacks?.afterSave?.(keyArray);
|
|
621
|
+
this._params.monitor?.recordStoreDuration(Date.now() - startMs);
|
|
613
622
|
}
|
|
614
623
|
async remove(keyArray) {
|
|
615
624
|
if (this._lifecycleState !== import_context4.LifecycleState.OPEN) {
|
|
@@ -623,6 +632,7 @@ var LevelDBStorageAdapter = class extends import_context4.Resource {
|
|
|
623
632
|
if (this._lifecycleState !== import_context4.LifecycleState.OPEN) {
|
|
624
633
|
return [];
|
|
625
634
|
}
|
|
635
|
+
const startMs = Date.now();
|
|
626
636
|
const result = [];
|
|
627
637
|
for await (const [key, value] of this._params.db.iterator({
|
|
628
638
|
gte: keyPrefix,
|
|
@@ -636,7 +646,9 @@ var LevelDBStorageAdapter = class extends import_context4.Resource {
|
|
|
636
646
|
key,
|
|
637
647
|
data: value
|
|
638
648
|
});
|
|
649
|
+
this._params.monitor?.recordBytesLoaded(value.byteLength);
|
|
639
650
|
}
|
|
651
|
+
this._params.monitor?.recordLoadDuration(Date.now() - startMs);
|
|
640
652
|
return result;
|
|
641
653
|
}
|
|
642
654
|
async removeRange(keyPrefix) {
|
|
@@ -699,20 +711,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
699
711
|
this._connected.wake();
|
|
700
712
|
}
|
|
701
713
|
send(message) {
|
|
702
|
-
|
|
703
|
-
if (!connectionEntry) {
|
|
704
|
-
throw new Error("Connection not found.");
|
|
705
|
-
}
|
|
706
|
-
connectionEntry.writer.write(message).catch((err) => {
|
|
707
|
-
if (connectionEntry.isOpen) {
|
|
708
|
-
import_log3.log.catch(err, void 0, {
|
|
709
|
-
F: __dxlog_file3,
|
|
710
|
-
L: 63,
|
|
711
|
-
S: this,
|
|
712
|
-
C: (f, a) => f(...a)
|
|
713
|
-
});
|
|
714
|
-
}
|
|
715
|
-
});
|
|
714
|
+
this._send(message);
|
|
716
715
|
}
|
|
717
716
|
disconnect() {
|
|
718
717
|
}
|
|
@@ -723,7 +722,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
723
722
|
this._lifecycleState = import_context6.LifecycleState.OPEN;
|
|
724
723
|
(0, import_log3.log)("emit ready", void 0, {
|
|
725
724
|
F: __dxlog_file3,
|
|
726
|
-
L:
|
|
725
|
+
L: 78,
|
|
727
726
|
S: this,
|
|
728
727
|
C: (f, a) => f(...a)
|
|
729
728
|
});
|
|
@@ -749,7 +748,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
749
748
|
async addReplicator(replicator) {
|
|
750
749
|
(0, import_invariant4.invariant)(this._lifecycleState === import_context6.LifecycleState.OPEN, void 0, {
|
|
751
750
|
F: __dxlog_file3,
|
|
752
|
-
L:
|
|
751
|
+
L: 104,
|
|
753
752
|
S: this,
|
|
754
753
|
A: [
|
|
755
754
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -758,7 +757,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
758
757
|
});
|
|
759
758
|
(0, import_invariant4.invariant)(this.peerId, void 0, {
|
|
760
759
|
F: __dxlog_file3,
|
|
761
|
-
L:
|
|
760
|
+
L: 105,
|
|
762
761
|
S: this,
|
|
763
762
|
A: [
|
|
764
763
|
"this.peerId",
|
|
@@ -767,7 +766,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
767
766
|
});
|
|
768
767
|
(0, import_invariant4.invariant)(!this._replicators.has(replicator), void 0, {
|
|
769
768
|
F: __dxlog_file3,
|
|
770
|
-
L:
|
|
769
|
+
L: 106,
|
|
771
770
|
S: this,
|
|
772
771
|
A: [
|
|
773
772
|
"!this._replicators.has(replicator)",
|
|
@@ -786,7 +785,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
786
785
|
async removeReplicator(replicator) {
|
|
787
786
|
(0, import_invariant4.invariant)(this._lifecycleState === import_context6.LifecycleState.OPEN, void 0, {
|
|
788
787
|
F: __dxlog_file3,
|
|
789
|
-
L:
|
|
788
|
+
L: 120,
|
|
790
789
|
S: this,
|
|
791
790
|
A: [
|
|
792
791
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -795,7 +794,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
795
794
|
});
|
|
796
795
|
(0, import_invariant4.invariant)(this._replicators.has(replicator), void 0, {
|
|
797
796
|
F: __dxlog_file3,
|
|
798
|
-
L:
|
|
797
|
+
L: 121,
|
|
799
798
|
S: this,
|
|
800
799
|
A: [
|
|
801
800
|
"this._replicators.has(replicator)",
|
|
@@ -826,7 +825,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
826
825
|
targetId,
|
|
827
826
|
collectionId
|
|
828
827
|
};
|
|
829
|
-
this.
|
|
828
|
+
this._send(message);
|
|
830
829
|
}
|
|
831
830
|
sendCollectionState(collectionId, targetId, state) {
|
|
832
831
|
const message = {
|
|
@@ -836,7 +835,28 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
836
835
|
collectionId,
|
|
837
836
|
state
|
|
838
837
|
};
|
|
839
|
-
this.
|
|
838
|
+
this._send(message);
|
|
839
|
+
}
|
|
840
|
+
_send(message) {
|
|
841
|
+
const connectionEntry = this._connections.get(message.targetId);
|
|
842
|
+
if (!connectionEntry) {
|
|
843
|
+
throw new Error("Connection not found.");
|
|
844
|
+
}
|
|
845
|
+
const writeStart = Date.now();
|
|
846
|
+
connectionEntry.writer.write(message).then(() => {
|
|
847
|
+
const durationMs = Date.now() - writeStart;
|
|
848
|
+
this._params.monitor?.recordMessageSent(message, durationMs);
|
|
849
|
+
}).catch((err) => {
|
|
850
|
+
if (connectionEntry.isOpen) {
|
|
851
|
+
import_log3.log.catch(err, void 0, {
|
|
852
|
+
F: __dxlog_file3,
|
|
853
|
+
L: 181,
|
|
854
|
+
S: this,
|
|
855
|
+
C: (f, a) => f(...a)
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
this._params.monitor?.recordMessageSendingFailed(message);
|
|
859
|
+
});
|
|
840
860
|
}
|
|
841
861
|
// TODO(dmaretskyi): Remove.
|
|
842
862
|
getPeersInterestedInCollection(collectionId) {
|
|
@@ -844,20 +864,20 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
844
864
|
return connection.connection.shouldSyncCollection({
|
|
845
865
|
collectionId
|
|
846
866
|
}) ? connection.connection.peerId : null;
|
|
847
|
-
}).filter(
|
|
867
|
+
}).filter(import_util2.nonNullable);
|
|
848
868
|
}
|
|
849
869
|
_onConnectionOpen(connection) {
|
|
850
870
|
(0, import_log3.log)("Connection opened", {
|
|
851
871
|
peerId: connection.peerId
|
|
852
872
|
}, {
|
|
853
873
|
F: __dxlog_file3,
|
|
854
|
-
L:
|
|
874
|
+
L: 199,
|
|
855
875
|
S: this,
|
|
856
876
|
C: (f, a) => f(...a)
|
|
857
877
|
});
|
|
858
878
|
(0, import_invariant4.invariant)(!this._connections.has(connection.peerId), void 0, {
|
|
859
879
|
F: __dxlog_file3,
|
|
860
|
-
L:
|
|
880
|
+
L: 200,
|
|
861
881
|
S: this,
|
|
862
882
|
A: [
|
|
863
883
|
"!this._connections.has(connection.peerId as PeerId)",
|
|
@@ -886,7 +906,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
886
906
|
if (connectionEntry.isOpen) {
|
|
887
907
|
import_log3.log.catch(err, void 0, {
|
|
888
908
|
F: __dxlog_file3,
|
|
889
|
-
L:
|
|
909
|
+
L: 219,
|
|
890
910
|
S: this,
|
|
891
911
|
C: (f, a) => f(...a)
|
|
892
912
|
});
|
|
@@ -897,11 +917,12 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
897
917
|
peerId: connection.peerId
|
|
898
918
|
}, {
|
|
899
919
|
F: __dxlog_file3,
|
|
900
|
-
L:
|
|
920
|
+
L: 224,
|
|
901
921
|
S: this,
|
|
902
922
|
C: (f, a) => f(...a)
|
|
903
923
|
});
|
|
904
924
|
this._emitPeerCandidate(connection);
|
|
925
|
+
this._params.monitor?.recordPeerConnected(connection.peerId);
|
|
905
926
|
}
|
|
906
927
|
_onMessage(message) {
|
|
907
928
|
if (isCollectionQueryMessage(message)) {
|
|
@@ -911,6 +932,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
911
932
|
} else {
|
|
912
933
|
this.emit("message", message);
|
|
913
934
|
}
|
|
935
|
+
this._params.monitor?.recordMessageReceived(message);
|
|
914
936
|
}
|
|
915
937
|
/**
|
|
916
938
|
* Trigger doc-synchronizer shared documents set recalculation. Happens on peer-candidate.
|
|
@@ -921,14 +943,14 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
921
943
|
peerId: connection.peerId
|
|
922
944
|
}, {
|
|
923
945
|
F: __dxlog_file3,
|
|
924
|
-
L:
|
|
946
|
+
L: 245,
|
|
925
947
|
S: this,
|
|
926
948
|
C: (f, a) => f(...a)
|
|
927
949
|
});
|
|
928
950
|
const entry = this._connections.get(connection.peerId);
|
|
929
951
|
(0, import_invariant4.invariant)(entry, void 0, {
|
|
930
952
|
F: __dxlog_file3,
|
|
931
|
-
L:
|
|
953
|
+
L: 247,
|
|
932
954
|
S: this,
|
|
933
955
|
A: [
|
|
934
956
|
"entry",
|
|
@@ -945,14 +967,14 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
945
967
|
peerId: connection.peerId
|
|
946
968
|
}, {
|
|
947
969
|
F: __dxlog_file3,
|
|
948
|
-
L:
|
|
970
|
+
L: 253,
|
|
949
971
|
S: this,
|
|
950
972
|
C: (f, a) => f(...a)
|
|
951
973
|
});
|
|
952
974
|
const entry = this._connections.get(connection.peerId);
|
|
953
975
|
(0, import_invariant4.invariant)(entry, void 0, {
|
|
954
976
|
F: __dxlog_file3,
|
|
955
|
-
L:
|
|
977
|
+
L: 255,
|
|
956
978
|
S: this,
|
|
957
979
|
A: [
|
|
958
980
|
"entry",
|
|
@@ -963,15 +985,16 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
963
985
|
this.emit("peer-disconnected", {
|
|
964
986
|
peerId: connection.peerId
|
|
965
987
|
});
|
|
988
|
+
this._params.monitor?.recordPeerDisconnected(connection.peerId);
|
|
966
989
|
void entry.reader.cancel().catch((err) => import_log3.log.catch(err, void 0, {
|
|
967
990
|
F: __dxlog_file3,
|
|
968
|
-
L:
|
|
991
|
+
L: 261,
|
|
969
992
|
S: this,
|
|
970
993
|
C: (f, a) => f(...a)
|
|
971
994
|
}));
|
|
972
995
|
void entry.writer.abort().catch((err) => import_log3.log.catch(err, void 0, {
|
|
973
996
|
F: __dxlog_file3,
|
|
974
|
-
L:
|
|
997
|
+
L: 262,
|
|
975
998
|
S: this,
|
|
976
999
|
C: (f, a) => f(...a)
|
|
977
1000
|
}));
|
|
@@ -1032,13 +1055,8 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
1032
1055
|
}
|
|
1033
1056
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
1034
1057
|
var AutomergeHost = class extends import_context5.Resource {
|
|
1035
|
-
constructor({ db, indexMetadataStore }) {
|
|
1058
|
+
constructor({ db, indexMetadataStore, dataMonitor }) {
|
|
1036
1059
|
super();
|
|
1037
|
-
this._echoNetworkAdapter = new EchoNetworkAdapter({
|
|
1038
|
-
getContainingSpaceForDocument: this._getContainingSpaceForDocument.bind(this),
|
|
1039
|
-
onCollectionStateQueried: this._onCollectionStateQueried.bind(this),
|
|
1040
|
-
onCollectionStateReceived: this._onCollectionStateReceived.bind(this)
|
|
1041
|
-
});
|
|
1042
1060
|
this._collectionSynchronizer = new CollectionSynchronizer({
|
|
1043
1061
|
queryCollectionState: this._queryCollectionState.bind(this),
|
|
1044
1062
|
sendCollectionState: this._sendCollectionState.bind(this),
|
|
@@ -1050,7 +1068,14 @@ var AutomergeHost = class extends import_context5.Resource {
|
|
|
1050
1068
|
callbacks: {
|
|
1051
1069
|
beforeSave: async (params) => this._beforeSave(params),
|
|
1052
1070
|
afterSave: async (key) => this._afterSave(key)
|
|
1053
|
-
}
|
|
1071
|
+
},
|
|
1072
|
+
monitor: dataMonitor
|
|
1073
|
+
});
|
|
1074
|
+
this._echoNetworkAdapter = new EchoNetworkAdapter({
|
|
1075
|
+
getContainingSpaceForDocument: this._getContainingSpaceForDocument.bind(this),
|
|
1076
|
+
onCollectionStateQueried: this._onCollectionStateQueried.bind(this),
|
|
1077
|
+
onCollectionStateReceived: this._onCollectionStateReceived.bind(this),
|
|
1078
|
+
monitor: dataMonitor
|
|
1054
1079
|
});
|
|
1055
1080
|
this._headsStore = new HeadsStore({
|
|
1056
1081
|
db: db.sublevel("heads")
|
|
@@ -1155,7 +1180,7 @@ var AutomergeHost = class extends import_context5.Resource {
|
|
|
1155
1180
|
await Promise.all(headsToWait.map(async (entry, index) => {
|
|
1156
1181
|
const handle = await this.loadDoc(import_context5.Context.default(void 0, {
|
|
1157
1182
|
F: __dxlog_file4,
|
|
1158
|
-
L:
|
|
1183
|
+
L: 226
|
|
1159
1184
|
}), entry.documentId);
|
|
1160
1185
|
await waitForHeads(handle, entry.heads);
|
|
1161
1186
|
}));
|
|
@@ -1168,7 +1193,7 @@ var AutomergeHost = class extends import_context5.Resource {
|
|
|
1168
1193
|
documentId
|
|
1169
1194
|
}, {
|
|
1170
1195
|
F: __dxlog_file4,
|
|
1171
|
-
L:
|
|
1196
|
+
L: 238,
|
|
1172
1197
|
S: this,
|
|
1173
1198
|
C: (f, a) => f(...a)
|
|
1174
1199
|
});
|
|
@@ -1184,7 +1209,7 @@ var AutomergeHost = class extends import_context5.Resource {
|
|
|
1184
1209
|
documentId
|
|
1185
1210
|
}, {
|
|
1186
1211
|
F: __dxlog_file4,
|
|
1187
|
-
L:
|
|
1212
|
+
L: 242,
|
|
1188
1213
|
S: this,
|
|
1189
1214
|
C: (f, a) => f(...a)
|
|
1190
1215
|
});
|
|
@@ -1193,7 +1218,7 @@ var AutomergeHost = class extends import_context5.Resource {
|
|
|
1193
1218
|
const doc = handle.docSync();
|
|
1194
1219
|
(0, import_invariant3.invariant)(doc, void 0, {
|
|
1195
1220
|
F: __dxlog_file4,
|
|
1196
|
-
L:
|
|
1221
|
+
L: 247,
|
|
1197
1222
|
S: this,
|
|
1198
1223
|
A: [
|
|
1199
1224
|
"doc",
|
|
@@ -1207,7 +1232,7 @@ var AutomergeHost = class extends import_context5.Resource {
|
|
|
1207
1232
|
}
|
|
1208
1233
|
import_log2.log.info("done re-indexing heads", void 0, {
|
|
1209
1234
|
F: __dxlog_file4,
|
|
1210
|
-
L:
|
|
1235
|
+
L: 254,
|
|
1211
1236
|
S: this,
|
|
1212
1237
|
C: (f, a) => f(...a)
|
|
1213
1238
|
});
|
|
@@ -1276,28 +1301,6 @@ var AutomergeHost = class extends import_context5.Resource {
|
|
|
1276
1301
|
this._onHeadsChanged(documentId, heads);
|
|
1277
1302
|
}
|
|
1278
1303
|
}
|
|
1279
|
-
_automergeDocs() {
|
|
1280
|
-
return (0, import_util2.mapValues)(this._repo.handles, (handle) => ({
|
|
1281
|
-
state: handle.state,
|
|
1282
|
-
hasDoc: !!handle.docSync(),
|
|
1283
|
-
heads: handle.docSync() ? import_automerge3.next.getHeads(handle.docSync()) : null,
|
|
1284
|
-
data: handle.docSync() && (0, import_util2.mapValues)(handle.docSync(), (value, key) => {
|
|
1285
|
-
try {
|
|
1286
|
-
switch (key) {
|
|
1287
|
-
case "access":
|
|
1288
|
-
case "links":
|
|
1289
|
-
return value;
|
|
1290
|
-
case "objects":
|
|
1291
|
-
return Object.keys(value);
|
|
1292
|
-
default:
|
|
1293
|
-
return `${value}`;
|
|
1294
|
-
}
|
|
1295
|
-
} catch (err) {
|
|
1296
|
-
return `${err}`;
|
|
1297
|
-
}
|
|
1298
|
-
})
|
|
1299
|
-
}));
|
|
1300
|
-
}
|
|
1301
1304
|
_automergePeers() {
|
|
1302
1305
|
return this._repo.peers;
|
|
1303
1306
|
}
|
|
@@ -1415,7 +1418,7 @@ var AutomergeHost = class extends import_context5.Resource {
|
|
|
1415
1418
|
count: different.length
|
|
1416
1419
|
}, {
|
|
1417
1420
|
F: __dxlog_file4,
|
|
1418
|
-
L:
|
|
1421
|
+
L: 463,
|
|
1419
1422
|
S: this,
|
|
1420
1423
|
C: (f, a) => f(...a)
|
|
1421
1424
|
});
|
|
@@ -1437,11 +1440,6 @@ var AutomergeHost = class extends import_context5.Resource {
|
|
|
1437
1440
|
_ts_decorate2([
|
|
1438
1441
|
import_tracing.trace.info()
|
|
1439
1442
|
], AutomergeHost.prototype, "_peerId", void 0);
|
|
1440
|
-
_ts_decorate2([
|
|
1441
|
-
import_tracing.trace.info({
|
|
1442
|
-
depth: null
|
|
1443
|
-
})
|
|
1444
|
-
], AutomergeHost.prototype, "_automergeDocs", null);
|
|
1445
1443
|
_ts_decorate2([
|
|
1446
1444
|
import_tracing.trace.info({
|
|
1447
1445
|
depth: null
|
|
@@ -1480,7 +1478,7 @@ var changeIsPresentInDoc = (doc, changeHash) => {
|
|
|
1480
1478
|
var decodeCollectionState = (state) => {
|
|
1481
1479
|
(0, import_invariant3.invariant)(typeof state === "object" && state !== null, "Invalid state", {
|
|
1482
1480
|
F: __dxlog_file4,
|
|
1483
|
-
L:
|
|
1481
|
+
L: 516,
|
|
1484
1482
|
S: void 0,
|
|
1485
1483
|
A: [
|
|
1486
1484
|
"typeof state === 'object' && state !== null",
|
|
@@ -1847,11 +1845,11 @@ var PipelineState = class {
|
|
|
1847
1845
|
var Pipeline = class {
|
|
1848
1846
|
constructor() {
|
|
1849
1847
|
this._timeframeClock = new TimeframeClock(new import_timeframe2.Timeframe());
|
|
1850
|
-
this._feeds = new
|
|
1848
|
+
this._feeds = new import_util3.ComplexMap(import_keys4.PublicKey.hash);
|
|
1851
1849
|
this._state = new PipelineState(this._feeds, this._timeframeClock);
|
|
1852
1850
|
this._processingTrigger = new import_async7.Trigger().wake();
|
|
1853
1851
|
this._pauseTrigger = new import_async7.Trigger().wake();
|
|
1854
|
-
this._downloads = new
|
|
1852
|
+
this._downloads = new import_util3.ComplexMap((value) => import_keys4.PublicKey.hash(value.key));
|
|
1855
1853
|
this._isStopping = false;
|
|
1856
1854
|
this._isStarted = false;
|
|
1857
1855
|
this._isBeingConsumed = false;
|
|
@@ -2165,7 +2163,7 @@ var ControlPipeline = class {
|
|
|
2165
2163
|
L: 47
|
|
2166
2164
|
});
|
|
2167
2165
|
this._lastTimeframeSaveTime = Date.now();
|
|
2168
|
-
this.onFeedAdmitted = new
|
|
2166
|
+
this.onFeedAdmitted = new import_util5.Callback();
|
|
2169
2167
|
this._usage = new import_tracing3.TimeUsageCounter();
|
|
2170
2168
|
this._mutations = new import_tracing3.TimeSeriesCounter();
|
|
2171
2169
|
this._snapshotTask = new import_async9.DeferredTask(this._ctx, async () => {
|
|
@@ -2323,7 +2321,7 @@ var ControlPipeline = class {
|
|
|
2323
2321
|
C: (f, a) => f(...a)
|
|
2324
2322
|
});
|
|
2325
2323
|
if (msg.data.payload.credential) {
|
|
2326
|
-
const timer =
|
|
2324
|
+
const timer = import_util5.tracer.mark("dxos.echo.pipeline.control");
|
|
2327
2325
|
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, {
|
|
2328
2326
|
sourceFeed: import_keys6.PublicKey.from(msg.feedKey)
|
|
2329
2327
|
});
|
|
@@ -2416,12 +2414,11 @@ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeli
|
|
|
2416
2414
|
var Space = class extends import_context9.Resource {
|
|
2417
2415
|
constructor(params) {
|
|
2418
2416
|
super();
|
|
2419
|
-
this.
|
|
2420
|
-
this.onCredentialProcessed = new import_util5.Callback();
|
|
2417
|
+
this.onCredentialProcessed = new import_util4.Callback();
|
|
2421
2418
|
this.stateUpdate = new import_async8.Event();
|
|
2422
2419
|
(0, import_invariant9.invariant)(params.spaceKey && params.feedProvider, void 0, {
|
|
2423
2420
|
F: __dxlog_file11,
|
|
2424
|
-
L:
|
|
2421
|
+
L: 76,
|
|
2425
2422
|
S: this,
|
|
2426
2423
|
A: [
|
|
2427
2424
|
"params.spaceKey && params.feedProvider",
|
|
@@ -2455,7 +2452,7 @@ var Space = class extends import_context9.Resource {
|
|
|
2455
2452
|
credential
|
|
2456
2453
|
}, {
|
|
2457
2454
|
F: __dxlog_file11,
|
|
2458
|
-
L:
|
|
2455
|
+
L: 104,
|
|
2459
2456
|
S: this,
|
|
2460
2457
|
C: (f, a) => f(...a)
|
|
2461
2458
|
});
|
|
@@ -2466,7 +2463,7 @@ var Space = class extends import_context9.Resource {
|
|
|
2466
2463
|
invitation
|
|
2467
2464
|
}, {
|
|
2468
2465
|
F: __dxlog_file11,
|
|
2469
|
-
L:
|
|
2466
|
+
L: 108,
|
|
2470
2467
|
S: this,
|
|
2471
2468
|
C: (f, a) => f(...a)
|
|
2472
2469
|
});
|
|
@@ -2477,7 +2474,7 @@ var Space = class extends import_context9.Resource {
|
|
|
2477
2474
|
invitation
|
|
2478
2475
|
}, {
|
|
2479
2476
|
F: __dxlog_file11,
|
|
2480
|
-
L:
|
|
2477
|
+
L: 112,
|
|
2481
2478
|
S: this,
|
|
2482
2479
|
C: (f, a) => f(...a)
|
|
2483
2480
|
});
|
|
@@ -2491,7 +2488,7 @@ var Space = class extends import_context9.Resource {
|
|
|
2491
2488
|
])
|
|
2492
2489
|
}), {
|
|
2493
2490
|
F: __dxlog_file11,
|
|
2494
|
-
L:
|
|
2491
|
+
L: 116,
|
|
2495
2492
|
S: this,
|
|
2496
2493
|
C: (f, a) => f(...a)
|
|
2497
2494
|
});
|
|
@@ -2533,7 +2530,7 @@ var Space = class extends import_context9.Resource {
|
|
|
2533
2530
|
async setControlFeed(feed) {
|
|
2534
2531
|
(0, import_invariant9.invariant)(!this._controlFeed, "Control feed already set.", {
|
|
2535
2532
|
F: __dxlog_file11,
|
|
2536
|
-
L:
|
|
2533
|
+
L: 169,
|
|
2537
2534
|
S: this,
|
|
2538
2535
|
A: [
|
|
2539
2536
|
"!this._controlFeed",
|
|
@@ -2547,7 +2544,7 @@ var Space = class extends import_context9.Resource {
|
|
|
2547
2544
|
async setDataFeed(feed) {
|
|
2548
2545
|
(0, import_invariant9.invariant)(!this._dataFeed, "Data feed already set.", {
|
|
2549
2546
|
F: __dxlog_file11,
|
|
2550
|
-
L:
|
|
2547
|
+
L: 176,
|
|
2551
2548
|
S: this,
|
|
2552
2549
|
A: [
|
|
2553
2550
|
"!this._dataFeed",
|
|
@@ -2566,7 +2563,7 @@ var Space = class extends import_context9.Resource {
|
|
|
2566
2563
|
async _open(ctx) {
|
|
2567
2564
|
(0, import_log8.log)("opening...", void 0, {
|
|
2568
2565
|
F: __dxlog_file11,
|
|
2569
|
-
L:
|
|
2566
|
+
L: 190,
|
|
2570
2567
|
S: this,
|
|
2571
2568
|
C: (f, a) => f(...a)
|
|
2572
2569
|
});
|
|
@@ -2574,7 +2571,7 @@ var Space = class extends import_context9.Resource {
|
|
|
2574
2571
|
await this.protocol.start();
|
|
2575
2572
|
(0, import_log8.log)("opened", void 0, {
|
|
2576
2573
|
F: __dxlog_file11,
|
|
2577
|
-
L:
|
|
2574
|
+
L: 196,
|
|
2578
2575
|
S: this,
|
|
2579
2576
|
C: (f, a) => f(...a)
|
|
2580
2577
|
});
|
|
@@ -2584,7 +2581,7 @@ var Space = class extends import_context9.Resource {
|
|
|
2584
2581
|
key: this._key
|
|
2585
2582
|
}, {
|
|
2586
2583
|
F: __dxlog_file11,
|
|
2587
|
-
L:
|
|
2584
|
+
L: 201,
|
|
2588
2585
|
S: this,
|
|
2589
2586
|
C: (f, a) => f(...a)
|
|
2590
2587
|
});
|
|
@@ -2592,7 +2589,7 @@ var Space = class extends import_context9.Resource {
|
|
|
2592
2589
|
await this._controlPipeline.stop();
|
|
2593
2590
|
(0, import_log8.log)("closed", void 0, {
|
|
2594
2591
|
F: __dxlog_file11,
|
|
2595
|
-
L:
|
|
2592
|
+
L: 207,
|
|
2596
2593
|
S: this,
|
|
2597
2594
|
C: (f, a) => f(...a)
|
|
2598
2595
|
});
|
|
@@ -2622,7 +2619,7 @@ Space = _ts_decorate6([
|
|
|
2622
2619
|
(0, import_async8.trackLeaks)("open", "close"),
|
|
2623
2620
|
import_tracing2.trace.resource()
|
|
2624
2621
|
], Space);
|
|
2625
|
-
var SPACE_IDS_CACHE = new
|
|
2622
|
+
var SPACE_IDS_CACHE = new import_util4.ComplexMap(import_keys5.PublicKey.hash);
|
|
2626
2623
|
var createIdFromSpaceKey = async (spaceKey) => {
|
|
2627
2624
|
const cachedValue = SPACE_IDS_CACHE.get(spaceKey);
|
|
2628
2625
|
if (cachedValue !== void 0) {
|
|
@@ -2711,7 +2708,7 @@ var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
|
2711
2708
|
var SpaceProtocol = class {
|
|
2712
2709
|
constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore }) {
|
|
2713
2710
|
this._feeds = /* @__PURE__ */ new Set();
|
|
2714
|
-
this._sessions = new
|
|
2711
|
+
this._sessions = new import_util6.ComplexMap(import_keys7.PublicKey.hash);
|
|
2715
2712
|
this._topology = new import_network_manager.MMSTTopology({
|
|
2716
2713
|
originateConnections: 4,
|
|
2717
2714
|
maxPeers: 10,
|
|
@@ -3198,7 +3195,7 @@ var MeshEchoReplicator = class {
|
|
|
3198
3195
|
C: (f, a) => f(...a)
|
|
3199
3196
|
});
|
|
3200
3197
|
const spaceId = await createIdFromSpaceKey(spaceKey);
|
|
3201
|
-
(0,
|
|
3198
|
+
(0, import_util8.defaultMap)(this._authorizedDevices, spaceId, () => new import_util8.ComplexSet(import_keys10.PublicKey.hash)).add(deviceKey);
|
|
3202
3199
|
for (const connection of this._connections) {
|
|
3203
3200
|
if (connection.remoteDeviceKey && connection.remoteDeviceKey.equals(deviceKey)) {
|
|
3204
3201
|
if (this._connectionsPerPeer.has(connection.peerId)) {
|
|
@@ -3208,6 +3205,367 @@ var MeshEchoReplicator = class {
|
|
|
3208
3205
|
}
|
|
3209
3206
|
}
|
|
3210
3207
|
};
|
|
3208
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
3209
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3210
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3211
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3212
|
+
else
|
|
3213
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3214
|
+
if (d = decorators[i])
|
|
3215
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3216
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3217
|
+
}
|
|
3218
|
+
var PER_SECOND_RATE_AVG_WINDOW_SIZE = 5;
|
|
3219
|
+
var DEFAULT_AVG_WINDOW_SIZE = 25;
|
|
3220
|
+
var EchoDataMonitor = class {
|
|
3221
|
+
constructor(_params = {
|
|
3222
|
+
timeSeriesLength: 30
|
|
3223
|
+
}) {
|
|
3224
|
+
this._params = _params;
|
|
3225
|
+
this._lastTick = 0;
|
|
3226
|
+
this._activeCounters = createLocalCounters();
|
|
3227
|
+
this._localTimeSeries = createLocalTimeSeries();
|
|
3228
|
+
this._storageAverages = createStorageAverages();
|
|
3229
|
+
this._replicationAverages = createNetworkAverages();
|
|
3230
|
+
this._sizeByMessageType = {};
|
|
3231
|
+
this._lastReceivedMessages = new import_util9.CircularBuffer(100);
|
|
3232
|
+
this._lastSentMessages = new import_util9.CircularBuffer(100);
|
|
3233
|
+
this._connectionsCount = 0;
|
|
3234
|
+
}
|
|
3235
|
+
tick(timeMs) {
|
|
3236
|
+
this._advanceTimeWindow(timeMs - this._lastTick);
|
|
3237
|
+
this._lastTick = timeMs;
|
|
3238
|
+
}
|
|
3239
|
+
computeStats() {
|
|
3240
|
+
return {
|
|
3241
|
+
meta: {
|
|
3242
|
+
rateAverageOverSeconds: PER_SECOND_RATE_AVG_WINDOW_SIZE
|
|
3243
|
+
},
|
|
3244
|
+
storage: {
|
|
3245
|
+
reads: {
|
|
3246
|
+
payloadSize: this._storageAverages.loadedChunkSize.average(),
|
|
3247
|
+
opDuration: this._storageAverages.loadDuration.average(),
|
|
3248
|
+
countPerSecond: this._storageAverages.loadsPerSecond.average()
|
|
3249
|
+
},
|
|
3250
|
+
writes: {
|
|
3251
|
+
payloadSize: this._storageAverages.storedChunkSize.average(),
|
|
3252
|
+
opDuration: this._storageAverages.storeDuration.average(),
|
|
3253
|
+
countPerSecond: this._storageAverages.storesPerSecond.average()
|
|
3254
|
+
}
|
|
3255
|
+
},
|
|
3256
|
+
replicator: {
|
|
3257
|
+
connections: this._connectionsCount,
|
|
3258
|
+
receivedMessages: {
|
|
3259
|
+
payloadSize: this._replicationAverages.receivedMessageSize.average(),
|
|
3260
|
+
countPerSecond: this._replicationAverages.receivedPerSecond.average()
|
|
3261
|
+
},
|
|
3262
|
+
sentMessages: {
|
|
3263
|
+
payloadSize: this._replicationAverages.sentMessageSize.average(),
|
|
3264
|
+
opDuration: this._replicationAverages.sendDuration.average(),
|
|
3265
|
+
countPerSecond: this._replicationAverages.sentPerSecond.average(),
|
|
3266
|
+
failedPerSecond: this._replicationAverages.sendsFailedPerSecond.average()
|
|
3267
|
+
},
|
|
3268
|
+
countByMessageType: this._computeMessageHistogram("type"),
|
|
3269
|
+
avgSizeByMessageType: (0, import_util9.mapValues)(this._sizeByMessageType, (summary) => summary.average())
|
|
3270
|
+
}
|
|
3271
|
+
};
|
|
3272
|
+
}
|
|
3273
|
+
get connectionsCount() {
|
|
3274
|
+
return this._connectionsCount;
|
|
3275
|
+
}
|
|
3276
|
+
/**
|
|
3277
|
+
* @internal
|
|
3278
|
+
*/
|
|
3279
|
+
get lastPerSecondStats() {
|
|
3280
|
+
return this._lastCompleteCounters;
|
|
3281
|
+
}
|
|
3282
|
+
/**
|
|
3283
|
+
* @internal
|
|
3284
|
+
*/
|
|
3285
|
+
get timeSeries() {
|
|
3286
|
+
return {
|
|
3287
|
+
...this._localTimeSeries.storage,
|
|
3288
|
+
...this._localTimeSeries.replication
|
|
3289
|
+
};
|
|
3290
|
+
}
|
|
3291
|
+
/**
|
|
3292
|
+
* @internal
|
|
3293
|
+
*/
|
|
3294
|
+
get messagesByPeerId() {
|
|
3295
|
+
return this._computeMessageHistogram("peerId");
|
|
3296
|
+
}
|
|
3297
|
+
_advanceTimeWindow(millisPassed) {
|
|
3298
|
+
const oldMetrics = Object.freeze(this._activeCounters);
|
|
3299
|
+
this._activeCounters = createLocalCounters();
|
|
3300
|
+
this._lastCompleteCounters = oldMetrics;
|
|
3301
|
+
for (const peerId of Object.keys(oldMetrics.byPeerId)) {
|
|
3302
|
+
this._activeCounters.byPeerId[peerId] = createMessageCounter();
|
|
3303
|
+
}
|
|
3304
|
+
this._addToTimeSeries(oldMetrics.replication, this._localTimeSeries.replication);
|
|
3305
|
+
this._addToTimeSeries(oldMetrics.storage, this._localTimeSeries.storage);
|
|
3306
|
+
if (Math.abs(millisPassed - 1e3) < 100) {
|
|
3307
|
+
this._reportPerSecondRate(oldMetrics);
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
_addToTimeSeries(values, timeSeries) {
|
|
3311
|
+
for (const [key, value] of Object.entries(values)) {
|
|
3312
|
+
const values2 = timeSeries[key];
|
|
3313
|
+
values2.push(value);
|
|
3314
|
+
if (values2.length > this._params.timeSeriesLength) {
|
|
3315
|
+
values2.shift();
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
}
|
|
3319
|
+
_reportPerSecondRate(metrics) {
|
|
3320
|
+
const toReport = [
|
|
3321
|
+
[
|
|
3322
|
+
"storage.load",
|
|
3323
|
+
metrics.storage.loadedChunks,
|
|
3324
|
+
this._storageAverages.loadsPerSecond
|
|
3325
|
+
],
|
|
3326
|
+
[
|
|
3327
|
+
"storage.store",
|
|
3328
|
+
metrics.storage.storedChunks,
|
|
3329
|
+
this._storageAverages.storesPerSecond
|
|
3330
|
+
],
|
|
3331
|
+
[
|
|
3332
|
+
"network.receive",
|
|
3333
|
+
metrics.replication.received,
|
|
3334
|
+
this._replicationAverages.receivedPerSecond
|
|
3335
|
+
],
|
|
3336
|
+
[
|
|
3337
|
+
"network.send",
|
|
3338
|
+
metrics.replication.sent,
|
|
3339
|
+
this._replicationAverages.sentPerSecond
|
|
3340
|
+
]
|
|
3341
|
+
];
|
|
3342
|
+
for (const [metricName, metric, summary] of toReport) {
|
|
3343
|
+
summary.record(metric);
|
|
3344
|
+
if (metric > 0) {
|
|
3345
|
+
import_tracing5.trace.metrics.distribution(`dxos.echo.${metricName}-rate`, metric);
|
|
3346
|
+
import_tracing5.trace.metrics.increment(`dxos.echo.${metricName}`, 1, {
|
|
3347
|
+
tags: {
|
|
3348
|
+
status: "busy"
|
|
3349
|
+
}
|
|
3350
|
+
});
|
|
3351
|
+
} else {
|
|
3352
|
+
import_tracing5.trace.metrics.increment(`dxos.echo.${metricName}`, 1, {
|
|
3353
|
+
tags: {
|
|
3354
|
+
status: "idle"
|
|
3355
|
+
}
|
|
3356
|
+
});
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
this._replicationAverages.sendsFailedPerSecond.record(metrics.replication.failed);
|
|
3360
|
+
}
|
|
3361
|
+
recordPeerConnected(peerId) {
|
|
3362
|
+
this._activeCounters.byPeerId[peerId] = createMessageCounter();
|
|
3363
|
+
this._connectionsCount++;
|
|
3364
|
+
}
|
|
3365
|
+
recordPeerDisconnected(peerId) {
|
|
3366
|
+
this._connectionsCount--;
|
|
3367
|
+
delete this._activeCounters.byPeerId[peerId];
|
|
3368
|
+
}
|
|
3369
|
+
recordBytesStored(count) {
|
|
3370
|
+
this._activeCounters.storage.storedChunks++;
|
|
3371
|
+
this._activeCounters.storage.storedBytes += count;
|
|
3372
|
+
this._storageAverages.storedChunkSize.record(count);
|
|
3373
|
+
import_tracing5.trace.metrics.distribution("dxos.echo.storage.bytes-stored", count, {
|
|
3374
|
+
unit: "bytes"
|
|
3375
|
+
});
|
|
3376
|
+
}
|
|
3377
|
+
recordLoadDuration(durationMs) {
|
|
3378
|
+
this._storageAverages.loadDuration.record(durationMs);
|
|
3379
|
+
}
|
|
3380
|
+
recordStoreDuration(durationMs) {
|
|
3381
|
+
this._storageAverages.storeDuration.record(durationMs);
|
|
3382
|
+
}
|
|
3383
|
+
recordBytesLoaded(count) {
|
|
3384
|
+
this._activeCounters.storage.loadedChunks++;
|
|
3385
|
+
this._activeCounters.storage.loadedBytes += count;
|
|
3386
|
+
this._storageAverages.loadedChunkSize.record(count);
|
|
3387
|
+
import_tracing5.trace.metrics.distribution("dxos.echo.storage.bytes-loaded", count, {
|
|
3388
|
+
unit: "bytes"
|
|
3389
|
+
});
|
|
3390
|
+
}
|
|
3391
|
+
recordMessageSent(message, duration) {
|
|
3392
|
+
let metricsGroupName;
|
|
3393
|
+
const bytes = getByteCount(message);
|
|
3394
|
+
const tags = {
|
|
3395
|
+
type: message.type
|
|
3396
|
+
};
|
|
3397
|
+
if (isAutomergeProtocolMessage(message)) {
|
|
3398
|
+
this._activeCounters.replication.sent++;
|
|
3399
|
+
this._replicationAverages.sendDuration.record(duration);
|
|
3400
|
+
this._replicationAverages.sentMessageSize.record(bytes);
|
|
3401
|
+
metricsGroupName = "replication";
|
|
3402
|
+
} else {
|
|
3403
|
+
metricsGroupName = "collection-sync";
|
|
3404
|
+
}
|
|
3405
|
+
import_tracing5.trace.metrics.distribution(`dxos.echo.${metricsGroupName}.bytes-sent`, bytes, {
|
|
3406
|
+
unit: "bytes",
|
|
3407
|
+
tags
|
|
3408
|
+
});
|
|
3409
|
+
import_tracing5.trace.metrics.distribution(`dxos.echo.${metricsGroupName}.send-duration`, duration, {
|
|
3410
|
+
unit: "millisecond",
|
|
3411
|
+
tags
|
|
3412
|
+
});
|
|
3413
|
+
import_tracing5.trace.metrics.increment(`dxos.echo.${metricsGroupName}.send-status`, 1, {
|
|
3414
|
+
tags: {
|
|
3415
|
+
...tags,
|
|
3416
|
+
success: true
|
|
3417
|
+
}
|
|
3418
|
+
});
|
|
3419
|
+
const { messageSize, messageCounts } = this._getStatsForType(message);
|
|
3420
|
+
messageSize.record(bytes);
|
|
3421
|
+
messageCounts.sent++;
|
|
3422
|
+
this._lastSentMessages.push({
|
|
3423
|
+
type: message.type,
|
|
3424
|
+
peerId: message.targetId
|
|
3425
|
+
});
|
|
3426
|
+
}
|
|
3427
|
+
recordMessageReceived(message) {
|
|
3428
|
+
const bytes = getByteCount(message);
|
|
3429
|
+
const tags = {
|
|
3430
|
+
type: message.type
|
|
3431
|
+
};
|
|
3432
|
+
if (isAutomergeProtocolMessage(message)) {
|
|
3433
|
+
this._activeCounters.replication.received++;
|
|
3434
|
+
this._replicationAverages.receivedMessageSize.record(bytes);
|
|
3435
|
+
import_tracing5.trace.metrics.distribution("dxos.echo.replication.bytes-received", bytes, {
|
|
3436
|
+
unit: "bytes",
|
|
3437
|
+
tags
|
|
3438
|
+
});
|
|
3439
|
+
} else {
|
|
3440
|
+
import_tracing5.trace.metrics.distribution("dxos.echo.collection-sync.bytes-received", bytes, {
|
|
3441
|
+
unit: "bytes",
|
|
3442
|
+
tags
|
|
3443
|
+
});
|
|
3444
|
+
}
|
|
3445
|
+
const { messageSize, messageCounts } = this._getStatsForType(message);
|
|
3446
|
+
messageSize.record(bytes);
|
|
3447
|
+
messageCounts.received++;
|
|
3448
|
+
this._lastReceivedMessages.push({
|
|
3449
|
+
type: message.type,
|
|
3450
|
+
peerId: message.senderId
|
|
3451
|
+
});
|
|
3452
|
+
}
|
|
3453
|
+
recordMessageSendingFailed(message) {
|
|
3454
|
+
const tags = {
|
|
3455
|
+
type: message.type,
|
|
3456
|
+
success: false
|
|
3457
|
+
};
|
|
3458
|
+
if (isAutomergeProtocolMessage(message)) {
|
|
3459
|
+
this._activeCounters.replication.failed++;
|
|
3460
|
+
import_tracing5.trace.metrics.increment("dxos.echo.replication.send-status", 1, {
|
|
3461
|
+
unit: "bytes",
|
|
3462
|
+
tags
|
|
3463
|
+
});
|
|
3464
|
+
} else {
|
|
3465
|
+
import_tracing5.trace.metrics.increment("dxos.echo.collection-sync.send-status", 1, {
|
|
3466
|
+
unit: "bytes",
|
|
3467
|
+
tags
|
|
3468
|
+
});
|
|
3469
|
+
}
|
|
3470
|
+
const { messageCounts } = this._getStatsForType(message);
|
|
3471
|
+
messageCounts.failed++;
|
|
3472
|
+
}
|
|
3473
|
+
_getStatsForType(message) {
|
|
3474
|
+
const messageSize = this._sizeByMessageType[message.type] ??= createSlidingWindow();
|
|
3475
|
+
const messageCounts = this._activeCounters.byType[message.type] ??= createMessageCounter();
|
|
3476
|
+
return {
|
|
3477
|
+
messageCounts,
|
|
3478
|
+
messageSize
|
|
3479
|
+
};
|
|
3480
|
+
}
|
|
3481
|
+
_computeMessageHistogram(groupKey) {
|
|
3482
|
+
const result = {};
|
|
3483
|
+
for (const receivedMessage of this._lastReceivedMessages) {
|
|
3484
|
+
const counters = result[receivedMessage[groupKey]] ??= {
|
|
3485
|
+
received: 0,
|
|
3486
|
+
sent: 0
|
|
3487
|
+
};
|
|
3488
|
+
counters.received++;
|
|
3489
|
+
}
|
|
3490
|
+
for (const receivedMessage of this._lastSentMessages) {
|
|
3491
|
+
const counters = result[receivedMessage[groupKey]] ??= {
|
|
3492
|
+
received: 0,
|
|
3493
|
+
sent: 0
|
|
3494
|
+
};
|
|
3495
|
+
counters.sent++;
|
|
3496
|
+
}
|
|
3497
|
+
return result;
|
|
3498
|
+
}
|
|
3499
|
+
};
|
|
3500
|
+
EchoDataMonitor = _ts_decorate8([
|
|
3501
|
+
import_tracing5.trace.resource()
|
|
3502
|
+
], EchoDataMonitor);
|
|
3503
|
+
var isAutomergeProtocolMessage = (message) => {
|
|
3504
|
+
return !(isCollectionQueryMessage(message) || isCollectionStateMessage(message));
|
|
3505
|
+
};
|
|
3506
|
+
var createSlidingWindow = (overrides) => new import_util9.SlidingWindowSummary({
|
|
3507
|
+
dataPoints: DEFAULT_AVG_WINDOW_SIZE,
|
|
3508
|
+
precision: 2,
|
|
3509
|
+
...overrides
|
|
3510
|
+
});
|
|
3511
|
+
var createLocalCounters = () => ({
|
|
3512
|
+
storage: {
|
|
3513
|
+
loadedBytes: 0,
|
|
3514
|
+
storedBytes: 0,
|
|
3515
|
+
storedChunks: 0,
|
|
3516
|
+
loadedChunks: 0
|
|
3517
|
+
},
|
|
3518
|
+
replication: createMessageCounter(),
|
|
3519
|
+
byPeerId: {},
|
|
3520
|
+
byType: {}
|
|
3521
|
+
});
|
|
3522
|
+
var createLocalTimeSeries = () => ({
|
|
3523
|
+
storage: {
|
|
3524
|
+
loadedBytes: [],
|
|
3525
|
+
storedBytes: [],
|
|
3526
|
+
storedChunks: [],
|
|
3527
|
+
loadedChunks: []
|
|
3528
|
+
},
|
|
3529
|
+
replication: {
|
|
3530
|
+
sent: [],
|
|
3531
|
+
failed: [],
|
|
3532
|
+
received: []
|
|
3533
|
+
}
|
|
3534
|
+
});
|
|
3535
|
+
var createMessageCounter = () => ({
|
|
3536
|
+
sent: 0,
|
|
3537
|
+
received: 0,
|
|
3538
|
+
failed: 0
|
|
3539
|
+
});
|
|
3540
|
+
var createNetworkAverages = () => ({
|
|
3541
|
+
receivedMessageSize: createSlidingWindow(),
|
|
3542
|
+
sentMessageSize: createSlidingWindow(),
|
|
3543
|
+
sendDuration: createSlidingWindow(),
|
|
3544
|
+
receivedPerSecond: createSlidingWindow({
|
|
3545
|
+
dataPoints: PER_SECOND_RATE_AVG_WINDOW_SIZE
|
|
3546
|
+
}),
|
|
3547
|
+
sentPerSecond: createSlidingWindow({
|
|
3548
|
+
dataPoints: PER_SECOND_RATE_AVG_WINDOW_SIZE
|
|
3549
|
+
}),
|
|
3550
|
+
sendsFailedPerSecond: createSlidingWindow({
|
|
3551
|
+
dataPoints: PER_SECOND_RATE_AVG_WINDOW_SIZE
|
|
3552
|
+
})
|
|
3553
|
+
});
|
|
3554
|
+
var createStorageAverages = () => ({
|
|
3555
|
+
storedChunkSize: createSlidingWindow(),
|
|
3556
|
+
loadedChunkSize: createSlidingWindow(),
|
|
3557
|
+
loadDuration: createSlidingWindow(),
|
|
3558
|
+
storeDuration: createSlidingWindow(),
|
|
3559
|
+
loadsPerSecond: createSlidingWindow({
|
|
3560
|
+
dataPoints: PER_SECOND_RATE_AVG_WINDOW_SIZE
|
|
3561
|
+
}),
|
|
3562
|
+
storesPerSecond: createSlidingWindow({
|
|
3563
|
+
dataPoints: PER_SECOND_RATE_AVG_WINDOW_SIZE
|
|
3564
|
+
})
|
|
3565
|
+
});
|
|
3566
|
+
var getByteCount = (message) => {
|
|
3567
|
+
return message.type.length + message.senderId.length + message.targetId.length + (message.data?.byteLength ?? 0) + (message.documentId?.length ?? 0);
|
|
3568
|
+
};
|
|
3211
3569
|
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service.ts";
|
|
3212
3570
|
var DataServiceImpl = class {
|
|
3213
3571
|
constructor(params) {
|
|
@@ -3318,7 +3676,7 @@ var DataServiceImpl = class {
|
|
|
3318
3676
|
};
|
|
3319
3677
|
}
|
|
3320
3678
|
};
|
|
3321
|
-
function
|
|
3679
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
3322
3680
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3323
3681
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3324
3682
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3331,7 +3689,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
3331
3689
|
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
3332
3690
|
var SpaceManager = class {
|
|
3333
3691
|
constructor({ feedStore, networkManager, metadataStore, snapshotStore, blobStore }) {
|
|
3334
|
-
this._spaces = new
|
|
3692
|
+
this._spaces = new import_util7.ComplexMap(import_keys8.PublicKey.hash);
|
|
3335
3693
|
this._instanceId = import_keys8.PublicKey.random().toHex();
|
|
3336
3694
|
this._feedStore = feedStore;
|
|
3337
3695
|
this._networkManager = networkManager;
|
|
@@ -3464,16 +3822,16 @@ var SpaceManager = class {
|
|
|
3464
3822
|
}
|
|
3465
3823
|
}
|
|
3466
3824
|
};
|
|
3467
|
-
|
|
3825
|
+
_ts_decorate9([
|
|
3468
3826
|
import_async11.synchronized
|
|
3469
3827
|
], SpaceManager.prototype, "open", null);
|
|
3470
|
-
|
|
3828
|
+
_ts_decorate9([
|
|
3471
3829
|
import_async11.synchronized
|
|
3472
3830
|
], SpaceManager.prototype, "close", null);
|
|
3473
|
-
SpaceManager =
|
|
3831
|
+
SpaceManager = _ts_decorate9([
|
|
3474
3832
|
(0, import_async11.trackLeaks)("open", "close")
|
|
3475
3833
|
], SpaceManager);
|
|
3476
|
-
function
|
|
3834
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
3477
3835
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3478
3836
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3479
3837
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3789,13 +4147,13 @@ var MetadataStore = class {
|
|
|
3789
4147
|
await this.flush();
|
|
3790
4148
|
}
|
|
3791
4149
|
};
|
|
3792
|
-
|
|
4150
|
+
_ts_decorate10([
|
|
3793
4151
|
import_async12.synchronized
|
|
3794
4152
|
], MetadataStore.prototype, "load", null);
|
|
3795
|
-
|
|
4153
|
+
_ts_decorate10([
|
|
3796
4154
|
import_async12.synchronized
|
|
3797
4155
|
], MetadataStore.prototype, "_save", null);
|
|
3798
|
-
|
|
4156
|
+
_ts_decorate10([
|
|
3799
4157
|
import_async12.synchronized
|
|
3800
4158
|
], MetadataStore.prototype, "_saveSpaceLargeMetadata", null);
|
|
3801
4159
|
var fromBytesInt32 = (buf) => buf.readInt32LE(0);
|
|
@@ -3814,6 +4172,7 @@ var isLegacyInvitationFormat = (invitation) => {
|
|
|
3814
4172
|
CredentialServerExtension,
|
|
3815
4173
|
DataServiceImpl,
|
|
3816
4174
|
DocumentsSynchronizer,
|
|
4175
|
+
EchoDataMonitor,
|
|
3817
4176
|
LevelDBStorageAdapter,
|
|
3818
4177
|
MOCK_AUTH_PROVIDER,
|
|
3819
4178
|
MOCK_AUTH_VERIFIER,
|
|
@@ -3841,4 +4200,4 @@ var isLegacyInvitationFormat = (invitation) => {
|
|
|
3841
4200
|
startAfter,
|
|
3842
4201
|
valueEncoding
|
|
3843
4202
|
});
|
|
3844
|
-
//# sourceMappingURL=chunk-
|
|
4203
|
+
//# sourceMappingURL=chunk-6MWU4MHX.cjs.map
|