@dxos/echo-pipeline 0.1.56-main.d626cba → 0.1.56-main.da2eab1
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-3OTHGQEY.mjs → chunk-GDF4DQU2.mjs} +243 -186
- package/dist/lib/browser/chunk-GDF4DQU2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/index.cjs +247 -190
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +249 -192
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/db-host/data-service-host.d.ts.map +1 -1
- package/dist/types/src/pipeline/pipeline-stress.test.d.ts +2 -0
- package/dist/types/src/pipeline/pipeline-stress.test.d.ts.map +1 -0
- package/dist/types/src/pipeline/pipeline.d.ts +4 -3
- package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
- package/dist/types/src/space/control-pipeline.d.ts +4 -0
- package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/data-pipeline.d.ts +2 -0
- package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/dist/types/src/space/space-protocol.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/dist/types/src/testing/database-test-rig.d.ts +4 -1
- package/dist/types/src/testing/database-test-rig.d.ts.map +1 -1
- package/package.json +32 -32
- package/src/db-host/data-service-host.ts +9 -2
- package/src/pipeline/pipeline-stress.test.ts +226 -0
- package/src/pipeline/pipeline.test.ts +2 -214
- package/src/pipeline/pipeline.ts +47 -22
- package/src/space/control-pipeline.ts +47 -22
- package/src/space/data-pipeline.ts +20 -10
- package/src/space/space-manager.ts +1 -0
- package/src/space/space-protocol.ts +3 -1
- package/src/space/space.ts +1 -0
- package/src/testing/database-test-rig.ts +27 -2
- package/src/tests/database-unit.test.ts +39 -0
- package/dist/lib/browser/chunk-3OTHGQEY.mjs.map +0 -7
|
@@ -39,6 +39,7 @@ import { Context } from "@dxos/context";
|
|
|
39
39
|
import { tagMutationsInBatch, setMetadataOnObject } from "@dxos/echo-db";
|
|
40
40
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
41
41
|
import { log } from "@dxos/log";
|
|
42
|
+
import { EchoEvent } from "@dxos/protocols/proto/dxos/echo/service";
|
|
42
43
|
import { ComplexMap } from "@dxos/util";
|
|
43
44
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
|
|
44
45
|
var DataServiceHost = class {
|
|
@@ -66,11 +67,19 @@ var DataServiceHost = class {
|
|
|
66
67
|
objects
|
|
67
68
|
}
|
|
68
69
|
});
|
|
70
|
+
this._itemDemuxer.snapshot.on(ctx, (snapshot) => {
|
|
71
|
+
next({
|
|
72
|
+
action: EchoEvent.DatabaseAction.RESET,
|
|
73
|
+
batch: {
|
|
74
|
+
objects: snapshot.items
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
69
78
|
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
70
79
|
const { batch, meta } = message;
|
|
71
80
|
invariant2(!meta.clientTag, "Unexpected client tag in mutation message", {
|
|
72
81
|
F: __dxlog_file2,
|
|
73
|
-
L:
|
|
82
|
+
L: 68,
|
|
74
83
|
S: this,
|
|
75
84
|
A: [
|
|
76
85
|
"!(meta as any).clientTag",
|
|
@@ -78,11 +87,11 @@ var DataServiceHost = class {
|
|
|
78
87
|
]
|
|
79
88
|
});
|
|
80
89
|
log("message", {
|
|
81
|
-
batch,
|
|
90
|
+
batch: batch.objects?.length,
|
|
82
91
|
meta
|
|
83
92
|
}, {
|
|
84
93
|
F: __dxlog_file2,
|
|
85
|
-
L:
|
|
94
|
+
L: 69,
|
|
86
95
|
S: this,
|
|
87
96
|
C: (f, a) => f(...a)
|
|
88
97
|
});
|
|
@@ -110,7 +119,7 @@ var DataServiceHost = class {
|
|
|
110
119
|
async write(request) {
|
|
111
120
|
invariant2(!this._ctx.disposed, "Cannot write to closed DataServiceHost", {
|
|
112
121
|
F: __dxlog_file2,
|
|
113
|
-
L:
|
|
122
|
+
L: 95,
|
|
114
123
|
S: this,
|
|
115
124
|
A: [
|
|
116
125
|
"!this._ctx.disposed",
|
|
@@ -119,7 +128,7 @@ var DataServiceHost = class {
|
|
|
119
128
|
});
|
|
120
129
|
invariant2(this._writeStream, "Cannot write mutations in readonly mode", {
|
|
121
130
|
F: __dxlog_file2,
|
|
122
|
-
L:
|
|
131
|
+
L: 96,
|
|
123
132
|
S: this,
|
|
124
133
|
A: [
|
|
125
134
|
"this._writeStream",
|
|
@@ -131,7 +140,7 @@ var DataServiceHost = class {
|
|
|
131
140
|
objectCount: request.batch.objects?.length ?? 0
|
|
132
141
|
}, {
|
|
133
142
|
F: __dxlog_file2,
|
|
134
|
-
L:
|
|
143
|
+
L: 98,
|
|
135
144
|
S: this,
|
|
136
145
|
C: (f, a) => f(...a)
|
|
137
146
|
});
|
|
@@ -145,7 +154,7 @@ var DataServiceHost = class {
|
|
|
145
154
|
seq: receipt2.seq
|
|
146
155
|
}, {
|
|
147
156
|
F: __dxlog_file2,
|
|
148
|
-
L:
|
|
157
|
+
L: 107,
|
|
149
158
|
S: this,
|
|
150
159
|
C: (f, a) => f(...a)
|
|
151
160
|
});
|
|
@@ -867,9 +876,11 @@ var Pipeline = class {
|
|
|
867
876
|
// Waits for the message consumer to process the message and yield control back to the pipeline.
|
|
868
877
|
this._processingTrigger = new Trigger().wake();
|
|
869
878
|
this._pauseTrigger = new Trigger().wake();
|
|
879
|
+
// Pending downloads.
|
|
880
|
+
this._downloads = new ComplexMap3((value) => PublicKey3.hash(value.key));
|
|
870
881
|
this._isStopping = false;
|
|
871
882
|
this._isStarted = false;
|
|
872
|
-
this.
|
|
883
|
+
this._isBeingConsumed = false;
|
|
873
884
|
this._isPaused = false;
|
|
874
885
|
}
|
|
875
886
|
get state() {
|
|
@@ -878,7 +889,7 @@ var Pipeline = class {
|
|
|
878
889
|
get writer() {
|
|
879
890
|
invariant6(this._writer, "Writer not set.", {
|
|
880
891
|
F: __dxlog_file7,
|
|
881
|
-
L:
|
|
892
|
+
L: 233,
|
|
882
893
|
S: this,
|
|
883
894
|
A: [
|
|
884
895
|
"this._writer",
|
|
@@ -900,12 +911,14 @@ var Pipeline = class {
|
|
|
900
911
|
if (this._feedSetIterator) {
|
|
901
912
|
await this._feedSetIterator.addFeed(feed);
|
|
902
913
|
}
|
|
903
|
-
this.
|
|
914
|
+
if (this._isStarted && !this._isPaused) {
|
|
915
|
+
this._setFeedDownloadState(feed);
|
|
916
|
+
}
|
|
904
917
|
}
|
|
905
918
|
setWriteFeed(feed) {
|
|
906
919
|
invariant6(!this._writer, "Writer already set.", {
|
|
907
920
|
F: __dxlog_file7,
|
|
908
|
-
L:
|
|
921
|
+
L: 260,
|
|
909
922
|
S: this,
|
|
910
923
|
A: [
|
|
911
924
|
"!this._writer",
|
|
@@ -914,7 +927,7 @@ var Pipeline = class {
|
|
|
914
927
|
});
|
|
915
928
|
invariant6(feed.properties.writable, "Feed must be writable.", {
|
|
916
929
|
F: __dxlog_file7,
|
|
917
|
-
L:
|
|
930
|
+
L: 261,
|
|
918
931
|
S: this,
|
|
919
932
|
A: [
|
|
920
933
|
"feed.properties.writable",
|
|
@@ -929,7 +942,7 @@ var Pipeline = class {
|
|
|
929
942
|
async start() {
|
|
930
943
|
invariant6(!this._isStarted, "Pipeline is already started.", {
|
|
931
944
|
F: __dxlog_file7,
|
|
932
|
-
L:
|
|
945
|
+
L: 274,
|
|
933
946
|
S: this,
|
|
934
947
|
A: [
|
|
935
948
|
"!this._isStarted",
|
|
@@ -938,7 +951,7 @@ var Pipeline = class {
|
|
|
938
951
|
});
|
|
939
952
|
log6("starting...", void 0, {
|
|
940
953
|
F: __dxlog_file7,
|
|
941
|
-
L:
|
|
954
|
+
L: 275,
|
|
942
955
|
S: this,
|
|
943
956
|
C: (f, a) => f(...a)
|
|
944
957
|
});
|
|
@@ -947,19 +960,28 @@ var Pipeline = class {
|
|
|
947
960
|
this._isStarted = true;
|
|
948
961
|
log6("started", void 0, {
|
|
949
962
|
F: __dxlog_file7,
|
|
950
|
-
L:
|
|
963
|
+
L: 279,
|
|
951
964
|
S: this,
|
|
952
965
|
C: (f, a) => f(...a)
|
|
953
966
|
});
|
|
967
|
+
if (!this._isPaused) {
|
|
968
|
+
for (const feed of this._feeds.values()) {
|
|
969
|
+
this._setFeedDownloadState(feed);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
954
972
|
}
|
|
955
973
|
async stop() {
|
|
956
974
|
log6("stopping...", void 0, {
|
|
957
975
|
F: __dxlog_file7,
|
|
958
|
-
L:
|
|
976
|
+
L: 290,
|
|
959
977
|
S: this,
|
|
960
978
|
C: (f, a) => f(...a)
|
|
961
979
|
});
|
|
962
980
|
this._isStopping = true;
|
|
981
|
+
for (const [feed, handle] of this._downloads.entries()) {
|
|
982
|
+
feed.undownload(handle);
|
|
983
|
+
}
|
|
984
|
+
this._downloads.clear();
|
|
963
985
|
await this._feedSetIterator?.close();
|
|
964
986
|
await this._processingTrigger.wait();
|
|
965
987
|
await this._state._ctx.dispose();
|
|
@@ -968,7 +990,7 @@ var Pipeline = class {
|
|
|
968
990
|
this._isStarted = false;
|
|
969
991
|
log6("stopped", void 0, {
|
|
970
992
|
F: __dxlog_file7,
|
|
971
|
-
L:
|
|
993
|
+
L: 302,
|
|
972
994
|
S: this,
|
|
973
995
|
C: (f, a) => f(...a)
|
|
974
996
|
});
|
|
@@ -980,7 +1002,7 @@ var Pipeline = class {
|
|
|
980
1002
|
async setCursor(timeframe) {
|
|
981
1003
|
invariant6(!this._isStarted || this._isPaused, "Invalid state.", {
|
|
982
1004
|
F: __dxlog_file7,
|
|
983
|
-
L:
|
|
1005
|
+
L: 311,
|
|
984
1006
|
S: this,
|
|
985
1007
|
A: [
|
|
986
1008
|
"!this._isStarted || this._isPaused",
|
|
@@ -989,9 +1011,6 @@ var Pipeline = class {
|
|
|
989
1011
|
});
|
|
990
1012
|
this._state._startTimeframe = timeframe;
|
|
991
1013
|
this._timeframeClock.setTimeframe(timeframe);
|
|
992
|
-
for (const feed of this._feeds.values()) {
|
|
993
|
-
this._setFeedDownloadState(feed);
|
|
994
|
-
}
|
|
995
1014
|
if (this._feedSetIterator) {
|
|
996
1015
|
await this._feedSetIterator.close();
|
|
997
1016
|
await this._initIterator();
|
|
@@ -1002,15 +1021,6 @@ var Pipeline = class {
|
|
|
1002
1021
|
* Calling pause while processing will cause a deadlock.
|
|
1003
1022
|
*/
|
|
1004
1023
|
async pause() {
|
|
1005
|
-
invariant6(this._isStarted, "Pipeline is not open.", {
|
|
1006
|
-
F: __dxlog_file7,
|
|
1007
|
-
L: 316,
|
|
1008
|
-
S: this,
|
|
1009
|
-
A: [
|
|
1010
|
-
"this._isStarted",
|
|
1011
|
-
"'Pipeline is not open.'"
|
|
1012
|
-
]
|
|
1013
|
-
});
|
|
1014
1024
|
if (this._isPaused) {
|
|
1015
1025
|
return;
|
|
1016
1026
|
}
|
|
@@ -1019,18 +1029,9 @@ var Pipeline = class {
|
|
|
1019
1029
|
this._isPaused = true;
|
|
1020
1030
|
}
|
|
1021
1031
|
async unpause() {
|
|
1022
|
-
invariant6(this._isStarted, "Pipeline is not open.", {
|
|
1023
|
-
F: __dxlog_file7,
|
|
1024
|
-
L: 328,
|
|
1025
|
-
S: this,
|
|
1026
|
-
A: [
|
|
1027
|
-
"this._isStarted",
|
|
1028
|
-
"'Pipeline is not open.'"
|
|
1029
|
-
]
|
|
1030
|
-
});
|
|
1031
1032
|
invariant6(this._isPaused, "Pipeline is not paused.", {
|
|
1032
1033
|
F: __dxlog_file7,
|
|
1033
|
-
L:
|
|
1034
|
+
L: 340,
|
|
1034
1035
|
S: this,
|
|
1035
1036
|
A: [
|
|
1036
1037
|
"this._isPaused",
|
|
@@ -1039,25 +1040,28 @@ var Pipeline = class {
|
|
|
1039
1040
|
});
|
|
1040
1041
|
this._pauseTrigger.wake();
|
|
1041
1042
|
this._isPaused = false;
|
|
1043
|
+
for (const feed of this._feeds.values()) {
|
|
1044
|
+
this._setFeedDownloadState(feed);
|
|
1045
|
+
}
|
|
1042
1046
|
}
|
|
1043
1047
|
/**
|
|
1044
1048
|
* Starts to iterate over the ordered messages from the added feeds.
|
|
1045
1049
|
* Updates the timeframe clock after the message has bee processed.
|
|
1046
1050
|
*/
|
|
1047
1051
|
async *consume() {
|
|
1048
|
-
invariant6(!this.
|
|
1052
|
+
invariant6(!this._isBeingConsumed, "Pipeline is already being consumed.", {
|
|
1049
1053
|
F: __dxlog_file7,
|
|
1050
|
-
L:
|
|
1054
|
+
L: 355,
|
|
1051
1055
|
S: this,
|
|
1052
1056
|
A: [
|
|
1053
|
-
"!this.
|
|
1057
|
+
"!this._isBeingConsumed",
|
|
1054
1058
|
"'Pipeline is already being consumed.'"
|
|
1055
1059
|
]
|
|
1056
1060
|
});
|
|
1057
|
-
this.
|
|
1061
|
+
this._isBeingConsumed = true;
|
|
1058
1062
|
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1059
1063
|
F: __dxlog_file7,
|
|
1060
|
-
L:
|
|
1064
|
+
L: 358,
|
|
1061
1065
|
S: this,
|
|
1062
1066
|
A: [
|
|
1063
1067
|
"this._feedSetIterator",
|
|
@@ -1071,7 +1075,7 @@ var Pipeline = class {
|
|
|
1071
1075
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
1072
1076
|
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1073
1077
|
F: __dxlog_file7,
|
|
1074
|
-
L:
|
|
1078
|
+
L: 367,
|
|
1075
1079
|
S: this,
|
|
1076
1080
|
A: [
|
|
1077
1081
|
"this._feedSetIterator",
|
|
@@ -1091,32 +1095,40 @@ var Pipeline = class {
|
|
|
1091
1095
|
this._timeframeClock.updateTimeframe();
|
|
1092
1096
|
}
|
|
1093
1097
|
}
|
|
1094
|
-
this.
|
|
1098
|
+
this._isBeingConsumed = false;
|
|
1095
1099
|
}
|
|
1096
1100
|
_setFeedDownloadState(feed) {
|
|
1101
|
+
let handle = this._downloads.get(feed);
|
|
1102
|
+
if (handle) {
|
|
1103
|
+
feed.undownload(handle);
|
|
1104
|
+
}
|
|
1097
1105
|
const timeframe = this._state._startTimeframe;
|
|
1098
|
-
const seq = timeframe.get(feed.key) ??
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
+
const seq = timeframe.get(feed.key) ?? -1;
|
|
1107
|
+
log6.info("download", {
|
|
1108
|
+
feed: feed.key.truncate(),
|
|
1109
|
+
seq,
|
|
1110
|
+
length: feed.length
|
|
1111
|
+
}, {
|
|
1112
|
+
F: __dxlog_file7,
|
|
1113
|
+
L: 396,
|
|
1114
|
+
S: this,
|
|
1115
|
+
C: (f, a) => f(...a)
|
|
1106
1116
|
});
|
|
1107
|
-
feed.download({
|
|
1117
|
+
handle = feed.download({
|
|
1108
1118
|
start: seq + 1,
|
|
1109
1119
|
linear: true
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1120
|
+
}, (err, data) => {
|
|
1121
|
+
if (err) {
|
|
1122
|
+
} else {
|
|
1123
|
+
log6.info("data", data, {
|
|
1124
|
+
F: __dxlog_file7,
|
|
1125
|
+
L: 401,
|
|
1126
|
+
S: this,
|
|
1127
|
+
C: (f, a) => f(...a)
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1119
1130
|
});
|
|
1131
|
+
this._downloads.set(feed, handle);
|
|
1120
1132
|
}
|
|
1121
1133
|
async _initIterator() {
|
|
1122
1134
|
this._feedSetIterator = new FeedSetIterator(createMessageSelector(this._timeframeClock), {
|
|
@@ -1126,7 +1138,7 @@ var Pipeline = class {
|
|
|
1126
1138
|
this._feedSetIterator.stalled.on((iterator) => {
|
|
1127
1139
|
log6.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
|
|
1128
1140
|
F: __dxlog_file7,
|
|
1129
|
-
L:
|
|
1141
|
+
L: 415,
|
|
1130
1142
|
S: this,
|
|
1131
1143
|
C: (f, a) => f(...a)
|
|
1132
1144
|
});
|
|
@@ -1260,11 +1272,12 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1260
1272
|
import { Event as Event4, scheduleTask as scheduleTask2, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
1261
1273
|
import { Context as Context4 } from "@dxos/context";
|
|
1262
1274
|
import { checkCredentialType } from "@dxos/credentials";
|
|
1263
|
-
import { getStateMachineFromItem, ItemManager } from "@dxos/echo-db";
|
|
1275
|
+
import { getStateMachineFromItem, ItemManager, TYPE_PROPERTIES } from "@dxos/echo-db";
|
|
1264
1276
|
import { CancelledError } from "@dxos/errors";
|
|
1265
1277
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
1266
|
-
import { log as log8 } from "@dxos/log";
|
|
1278
|
+
import { log as log8, omit } from "@dxos/log";
|
|
1267
1279
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
1280
|
+
import { TimeSeriesCounter, TimeUsageCounter, trace } from "@dxos/tracing";
|
|
1268
1281
|
import { tracer } from "@dxos/util";
|
|
1269
1282
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
1270
1283
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1291,6 +1304,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1291
1304
|
this._lastTimeframeSaveTime = 0;
|
|
1292
1305
|
this._lastSnapshotSaveTime = 0;
|
|
1293
1306
|
this._lastProcessedEpoch = -1;
|
|
1307
|
+
this._usage = new TimeUsageCounter();
|
|
1308
|
+
this._mutations = new TimeSeriesCounter();
|
|
1294
1309
|
this.currentEpoch = void 0;
|
|
1295
1310
|
this.appliedEpoch = void 0;
|
|
1296
1311
|
this.onNewEpoch = new Event4();
|
|
@@ -1323,8 +1338,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1323
1338
|
}
|
|
1324
1339
|
this._pipeline = new Pipeline();
|
|
1325
1340
|
await this._params.onPipelineCreated(this._pipeline);
|
|
1326
|
-
await this._pipeline.start();
|
|
1327
1341
|
await this._pipeline.pause();
|
|
1342
|
+
await this._pipeline.start();
|
|
1328
1343
|
if (this._targetTimeframe) {
|
|
1329
1344
|
this._pipeline.state.setTargetTimeframe(this._targetTimeframe);
|
|
1330
1345
|
}
|
|
@@ -1332,7 +1347,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1332
1347
|
write: (data, options) => {
|
|
1333
1348
|
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1334
1349
|
F: __dxlog_file9,
|
|
1335
|
-
L:
|
|
1350
|
+
L: 154,
|
|
1336
1351
|
S: this,
|
|
1337
1352
|
A: [
|
|
1338
1353
|
"this._pipeline",
|
|
@@ -1341,7 +1356,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1341
1356
|
});
|
|
1342
1357
|
invariant8(this.currentEpoch, "Epoch is not initialized.", {
|
|
1343
1358
|
F: __dxlog_file9,
|
|
1344
|
-
L:
|
|
1359
|
+
L: 155,
|
|
1345
1360
|
S: this,
|
|
1346
1361
|
A: [
|
|
1347
1362
|
"this.currentEpoch",
|
|
@@ -1367,7 +1382,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1367
1382
|
}
|
|
1368
1383
|
log8("close", void 0, {
|
|
1369
1384
|
F: __dxlog_file9,
|
|
1370
|
-
L:
|
|
1385
|
+
L: 179,
|
|
1371
1386
|
S: this,
|
|
1372
1387
|
C: (f, a) => f(...a)
|
|
1373
1388
|
});
|
|
@@ -1382,7 +1397,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1382
1397
|
} catch (err) {
|
|
1383
1398
|
log8.catch(err, void 0, {
|
|
1384
1399
|
F: __dxlog_file9,
|
|
1385
|
-
L:
|
|
1400
|
+
L: 192,
|
|
1386
1401
|
S: this,
|
|
1387
1402
|
C: (f, a) => f(...a)
|
|
1388
1403
|
});
|
|
@@ -1406,7 +1421,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1406
1421
|
}
|
|
1407
1422
|
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1408
1423
|
F: __dxlog_file9,
|
|
1409
|
-
L:
|
|
1424
|
+
L: 215,
|
|
1410
1425
|
S: this,
|
|
1411
1426
|
A: [
|
|
1412
1427
|
"this._pipeline",
|
|
@@ -1414,13 +1429,15 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1414
1429
|
]
|
|
1415
1430
|
});
|
|
1416
1431
|
for await (const msg of this._pipeline.consume()) {
|
|
1432
|
+
const span = this._usage.beginRecording();
|
|
1433
|
+
this._mutations.inc();
|
|
1417
1434
|
const { feedKey, seq, data } = msg;
|
|
1418
1435
|
log8("processing message", {
|
|
1419
1436
|
feedKey,
|
|
1420
1437
|
seq
|
|
1421
1438
|
}, {
|
|
1422
1439
|
F: __dxlog_file9,
|
|
1423
|
-
L:
|
|
1440
|
+
L: 221,
|
|
1424
1441
|
S: this,
|
|
1425
1442
|
C: (f, a) => f(...a)
|
|
1426
1443
|
});
|
|
@@ -1432,7 +1449,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1432
1449
|
feedKey
|
|
1433
1450
|
}, {
|
|
1434
1451
|
F: __dxlog_file9,
|
|
1435
|
-
L:
|
|
1452
|
+
L: 227,
|
|
1436
1453
|
S: this,
|
|
1437
1454
|
C: (f, a) => f(...a)
|
|
1438
1455
|
});
|
|
@@ -1455,7 +1472,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1455
1472
|
spaceKey: this._params.spaceKey.toHex()
|
|
1456
1473
|
}, {
|
|
1457
1474
|
F: __dxlog_file9,
|
|
1458
|
-
L:
|
|
1475
|
+
L: 244,
|
|
1459
1476
|
S: this,
|
|
1460
1477
|
C: (f, a) => f(...a)
|
|
1461
1478
|
});
|
|
@@ -1464,17 +1481,18 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1464
1481
|
} catch (err) {
|
|
1465
1482
|
log8.catch(err, void 0, {
|
|
1466
1483
|
F: __dxlog_file9,
|
|
1467
|
-
L:
|
|
1484
|
+
L: 254,
|
|
1468
1485
|
S: this,
|
|
1469
1486
|
C: (f, a) => f(...a)
|
|
1470
1487
|
});
|
|
1471
1488
|
}
|
|
1489
|
+
span.end();
|
|
1472
1490
|
}
|
|
1473
1491
|
}
|
|
1474
1492
|
_createSnapshot() {
|
|
1475
1493
|
invariant8(this.databaseHost, "Database backend is not initialized.", {
|
|
1476
1494
|
F: __dxlog_file9,
|
|
1477
|
-
L:
|
|
1495
|
+
L: 262,
|
|
1478
1496
|
S: this,
|
|
1479
1497
|
A: [
|
|
1480
1498
|
"this.databaseHost",
|
|
@@ -1496,14 +1514,14 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1496
1514
|
const cache = {};
|
|
1497
1515
|
try {
|
|
1498
1516
|
const propertiesItem = this.itemManager.items.find((item) => item.modelMeta?.type === "dxos:model/document" && // TODO(burdon): Document?
|
|
1499
|
-
(getStateMachineFromItem(item)?.snapshot()).type ===
|
|
1517
|
+
(getStateMachineFromItem(item)?.snapshot()).type === TYPE_PROPERTIES);
|
|
1500
1518
|
if (propertiesItem) {
|
|
1501
1519
|
cache.properties = getStateMachineFromItem(propertiesItem)?.snapshot();
|
|
1502
1520
|
}
|
|
1503
1521
|
} catch (err) {
|
|
1504
1522
|
log8.warn("Failed to cache properties", err, {
|
|
1505
1523
|
F: __dxlog_file9,
|
|
1506
|
-
L:
|
|
1524
|
+
L: 291,
|
|
1507
1525
|
S: this,
|
|
1508
1526
|
C: (f, a) => f(...a)
|
|
1509
1527
|
});
|
|
@@ -1529,14 +1547,14 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1529
1547
|
if (err instanceof CancelledError) {
|
|
1530
1548
|
log8("Epoch processing cancelled.", void 0, {
|
|
1531
1549
|
F: __dxlog_file9,
|
|
1532
|
-
L:
|
|
1550
|
+
L: 323,
|
|
1533
1551
|
S: this,
|
|
1534
1552
|
C: (f, a) => f(...a)
|
|
1535
1553
|
});
|
|
1536
1554
|
} else {
|
|
1537
1555
|
log8.catch(err, void 0, {
|
|
1538
1556
|
F: __dxlog_file9,
|
|
1539
|
-
L:
|
|
1557
|
+
L: 325,
|
|
1540
1558
|
S: this,
|
|
1541
1559
|
C: (f, a) => f(...a)
|
|
1542
1560
|
});
|
|
@@ -1548,14 +1566,6 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1548
1566
|
if (!this._isOpen) {
|
|
1549
1567
|
return;
|
|
1550
1568
|
}
|
|
1551
|
-
log8("process epoch", {
|
|
1552
|
-
epoch
|
|
1553
|
-
}, {
|
|
1554
|
-
F: __dxlog_file9,
|
|
1555
|
-
L: 321,
|
|
1556
|
-
S: this,
|
|
1557
|
-
C: (f, a) => f(...a)
|
|
1558
|
-
});
|
|
1559
1569
|
await this._processEpoch(ctx, epoch.subject.assertion);
|
|
1560
1570
|
this.appliedEpoch = epoch;
|
|
1561
1571
|
this.onNewEpoch.emit(epoch);
|
|
@@ -1564,7 +1574,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1564
1574
|
async _processEpoch(ctx, epoch) {
|
|
1565
1575
|
invariant8(this._isOpen, "Space is closed.", {
|
|
1566
1576
|
F: __dxlog_file9,
|
|
1567
|
-
L:
|
|
1577
|
+
L: 344,
|
|
1568
1578
|
S: this,
|
|
1569
1579
|
A: [
|
|
1570
1580
|
"this._isOpen",
|
|
@@ -1573,7 +1583,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1573
1583
|
});
|
|
1574
1584
|
invariant8(this._pipeline, void 0, {
|
|
1575
1585
|
F: __dxlog_file9,
|
|
1576
|
-
L:
|
|
1586
|
+
L: 345,
|
|
1577
1587
|
S: this,
|
|
1578
1588
|
A: [
|
|
1579
1589
|
"this._pipeline",
|
|
@@ -1581,11 +1591,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1581
1591
|
]
|
|
1582
1592
|
});
|
|
1583
1593
|
this._lastProcessedEpoch = epoch.number;
|
|
1584
|
-
log8("
|
|
1585
|
-
epoch
|
|
1594
|
+
log8("processing", {
|
|
1595
|
+
epoch: omit(epoch, "proof")
|
|
1586
1596
|
}, {
|
|
1587
1597
|
F: __dxlog_file9,
|
|
1588
|
-
L:
|
|
1598
|
+
L: 348,
|
|
1589
1599
|
S: this,
|
|
1590
1600
|
C: (f, a) => f(...a)
|
|
1591
1601
|
});
|
|
@@ -1593,9 +1603,9 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1593
1603
|
const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
|
|
1594
1604
|
this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
|
|
1595
1605
|
}
|
|
1596
|
-
log8("restarting pipeline
|
|
1606
|
+
log8("restarting pipeline from epoch", void 0, {
|
|
1597
1607
|
F: __dxlog_file9,
|
|
1598
|
-
L:
|
|
1608
|
+
L: 354,
|
|
1599
1609
|
S: this,
|
|
1600
1610
|
C: (f, a) => f(...a)
|
|
1601
1611
|
});
|
|
@@ -1606,7 +1616,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1606
1616
|
async waitUntilTimeframe(timeframe) {
|
|
1607
1617
|
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1608
1618
|
F: __dxlog_file9,
|
|
1609
|
-
L:
|
|
1619
|
+
L: 361,
|
|
1610
1620
|
S: this,
|
|
1611
1621
|
A: [
|
|
1612
1622
|
"this._pipeline",
|
|
@@ -1618,7 +1628,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1618
1628
|
async createEpoch() {
|
|
1619
1629
|
invariant8(this._pipeline, void 0, {
|
|
1620
1630
|
F: __dxlog_file9,
|
|
1621
|
-
L:
|
|
1631
|
+
L: 367,
|
|
1622
1632
|
S: this,
|
|
1623
1633
|
A: [
|
|
1624
1634
|
"this._pipeline",
|
|
@@ -1627,7 +1637,7 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1627
1637
|
});
|
|
1628
1638
|
invariant8(this.currentEpoch, void 0, {
|
|
1629
1639
|
F: __dxlog_file9,
|
|
1630
|
-
L:
|
|
1640
|
+
L: 368,
|
|
1631
1641
|
S: this,
|
|
1632
1642
|
A: [
|
|
1633
1643
|
"this.currentEpoch",
|
|
@@ -1650,6 +1660,12 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1650
1660
|
await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
|
|
1651
1661
|
}
|
|
1652
1662
|
};
|
|
1663
|
+
_ts_decorate5([
|
|
1664
|
+
trace.metricsCounter()
|
|
1665
|
+
], DataPipeline.prototype, "_usage", void 0);
|
|
1666
|
+
_ts_decorate5([
|
|
1667
|
+
trace.metricsCounter()
|
|
1668
|
+
], DataPipeline.prototype, "_mutations", void 0);
|
|
1653
1669
|
_ts_decorate5([
|
|
1654
1670
|
synchronized3
|
|
1655
1671
|
], DataPipeline.prototype, "open", null);
|
|
@@ -1663,7 +1679,8 @@ _ts_decorate5([
|
|
|
1663
1679
|
synchronized3
|
|
1664
1680
|
], DataPipeline.prototype, "createEpoch", null);
|
|
1665
1681
|
DataPipeline = _ts_decorate5([
|
|
1666
|
-
trackLeaks2("open", "close")
|
|
1682
|
+
trackLeaks2("open", "close"),
|
|
1683
|
+
trace.resource()
|
|
1667
1684
|
], DataPipeline);
|
|
1668
1685
|
|
|
1669
1686
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
@@ -1671,22 +1688,36 @@ import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeak
|
|
|
1671
1688
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
1672
1689
|
import { log as log10, logInfo } from "@dxos/log";
|
|
1673
1690
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1674
|
-
import { trace } from "@dxos/tracing";
|
|
1691
|
+
import { trace as trace3 } from "@dxos/tracing";
|
|
1675
1692
|
import { Callback as Callback2 } from "@dxos/util";
|
|
1676
1693
|
|
|
1677
1694
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
1695
|
+
import { Context as Context5 } from "@dxos/context";
|
|
1678
1696
|
import { SpaceStateMachine } from "@dxos/credentials";
|
|
1679
1697
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
1680
1698
|
import { log as log9 } from "@dxos/log";
|
|
1681
1699
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1682
1700
|
import { Timeframe as Timeframe4 } from "@dxos/timeframe";
|
|
1701
|
+
import { TimeSeriesCounter as TimeSeriesCounter2, TimeUsageCounter as TimeUsageCounter2, trace as trace2 } from "@dxos/tracing";
|
|
1683
1702
|
import { Callback, tracer as tracer2 } from "@dxos/util";
|
|
1703
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1704
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1705
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1706
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1707
|
+
else
|
|
1708
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
1709
|
+
if (d = decorators[i])
|
|
1710
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1711
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1712
|
+
}
|
|
1684
1713
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
1685
1714
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
1686
|
-
var ControlPipeline = class {
|
|
1715
|
+
var ControlPipeline = class ControlPipeline2 {
|
|
1687
1716
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1688
1717
|
this._lastTimeframeSaveTime = Date.now();
|
|
1689
1718
|
this.onFeedAdmitted = new Callback();
|
|
1719
|
+
this._usage = new TimeUsageCounter2();
|
|
1720
|
+
this._mutations = new TimeSeriesCounter2();
|
|
1690
1721
|
this._spaceKey = spaceKey;
|
|
1691
1722
|
this._metadata = metadataStore;
|
|
1692
1723
|
this._pipeline = new Pipeline();
|
|
@@ -1697,7 +1728,7 @@ var ControlPipeline = class {
|
|
|
1697
1728
|
key: info.key
|
|
1698
1729
|
}, {
|
|
1699
1730
|
F: __dxlog_file10,
|
|
1700
|
-
L:
|
|
1731
|
+
L: 61,
|
|
1701
1732
|
S: this,
|
|
1702
1733
|
C: (f, a) => f(...a)
|
|
1703
1734
|
});
|
|
@@ -1708,7 +1739,7 @@ var ControlPipeline = class {
|
|
|
1708
1739
|
} catch (err) {
|
|
1709
1740
|
log9.catch(err, void 0, {
|
|
1710
1741
|
F: __dxlog_file10,
|
|
1711
|
-
L:
|
|
1742
|
+
L: 69,
|
|
1712
1743
|
S: this,
|
|
1713
1744
|
C: (f, a) => f(...a)
|
|
1714
1745
|
});
|
|
@@ -1731,57 +1762,66 @@ var ControlPipeline = class {
|
|
|
1731
1762
|
async start() {
|
|
1732
1763
|
log9("starting...", void 0, {
|
|
1733
1764
|
F: __dxlog_file10,
|
|
1734
|
-
L:
|
|
1765
|
+
L: 93,
|
|
1735
1766
|
S: this,
|
|
1736
1767
|
C: (f, a) => f(...a)
|
|
1737
1768
|
});
|
|
1738
1769
|
setTimeout(async () => {
|
|
1739
|
-
|
|
1740
|
-
try {
|
|
1741
|
-
log9("processing", {
|
|
1742
|
-
key: msg.feedKey,
|
|
1743
|
-
seq: msg.seq
|
|
1744
|
-
}, {
|
|
1745
|
-
F: __dxlog_file10,
|
|
1746
|
-
L: 88,
|
|
1747
|
-
S: this,
|
|
1748
|
-
C: (f, a) => f(...a)
|
|
1749
|
-
});
|
|
1750
|
-
if (msg.data.payload.credential) {
|
|
1751
|
-
const timer = tracer2.mark("dxos.echo.pipeline.control");
|
|
1752
|
-
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
|
|
1753
|
-
timer.end();
|
|
1754
|
-
if (!result) {
|
|
1755
|
-
log9.warn("processing failed", {
|
|
1756
|
-
msg
|
|
1757
|
-
}, {
|
|
1758
|
-
F: __dxlog_file10,
|
|
1759
|
-
L: 98,
|
|
1760
|
-
S: this,
|
|
1761
|
-
C: (f, a) => f(...a)
|
|
1762
|
-
});
|
|
1763
|
-
} else {
|
|
1764
|
-
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1765
|
-
}
|
|
1766
|
-
}
|
|
1767
|
-
} catch (err) {
|
|
1768
|
-
log9.catch(err, void 0, {
|
|
1769
|
-
F: __dxlog_file10,
|
|
1770
|
-
L: 104,
|
|
1771
|
-
S: this,
|
|
1772
|
-
C: (f, a) => f(...a)
|
|
1773
|
-
});
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1770
|
+
void this._consumePipeline(new Context5());
|
|
1776
1771
|
});
|
|
1777
1772
|
await this._pipeline.start();
|
|
1778
1773
|
log9("started", void 0, {
|
|
1779
1774
|
F: __dxlog_file10,
|
|
1780
|
-
L:
|
|
1775
|
+
L: 99,
|
|
1781
1776
|
S: this,
|
|
1782
1777
|
C: (f, a) => f(...a)
|
|
1783
1778
|
});
|
|
1784
1779
|
}
|
|
1780
|
+
async _consumePipeline(ctx) {
|
|
1781
|
+
for await (const msg of this._pipeline.consume()) {
|
|
1782
|
+
const span = this._usage.beginRecording();
|
|
1783
|
+
this._mutations.inc();
|
|
1784
|
+
try {
|
|
1785
|
+
await this._processMessage(ctx, msg);
|
|
1786
|
+
} catch (err) {
|
|
1787
|
+
log9.catch(err, void 0, {
|
|
1788
|
+
F: __dxlog_file10,
|
|
1789
|
+
L: 111,
|
|
1790
|
+
S: this,
|
|
1791
|
+
C: (f, a) => f(...a)
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
span.end();
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
async _processMessage(ctx, msg) {
|
|
1798
|
+
log9("processing", {
|
|
1799
|
+
key: msg.feedKey,
|
|
1800
|
+
seq: msg.seq
|
|
1801
|
+
}, {
|
|
1802
|
+
F: __dxlog_file10,
|
|
1803
|
+
L: 121,
|
|
1804
|
+
S: this,
|
|
1805
|
+
C: (f, a) => f(...a)
|
|
1806
|
+
});
|
|
1807
|
+
if (msg.data.payload.credential) {
|
|
1808
|
+
const timer = tracer2.mark("dxos.echo.pipeline.control");
|
|
1809
|
+
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
|
|
1810
|
+
timer.end();
|
|
1811
|
+
if (!result) {
|
|
1812
|
+
log9.warn("processing failed", {
|
|
1813
|
+
msg
|
|
1814
|
+
}, {
|
|
1815
|
+
F: __dxlog_file10,
|
|
1816
|
+
L: 131,
|
|
1817
|
+
S: this,
|
|
1818
|
+
C: (f, a) => f(...a)
|
|
1819
|
+
});
|
|
1820
|
+
} else {
|
|
1821
|
+
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1785
1825
|
async _noteTargetStateIfNeeded(timeframe) {
|
|
1786
1826
|
if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2) {
|
|
1787
1827
|
this._lastTimeframeSaveTime = Date.now();
|
|
@@ -1791,7 +1831,7 @@ var ControlPipeline = class {
|
|
|
1791
1831
|
async stop() {
|
|
1792
1832
|
log9("stopping...", void 0, {
|
|
1793
1833
|
F: __dxlog_file10,
|
|
1794
|
-
L:
|
|
1834
|
+
L: 149,
|
|
1795
1835
|
S: this,
|
|
1796
1836
|
C: (f, a) => f(...a)
|
|
1797
1837
|
});
|
|
@@ -1799,7 +1839,7 @@ var ControlPipeline = class {
|
|
|
1799
1839
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1800
1840
|
log9("stopped", void 0, {
|
|
1801
1841
|
F: __dxlog_file10,
|
|
1802
|
-
L:
|
|
1842
|
+
L: 152,
|
|
1803
1843
|
S: this,
|
|
1804
1844
|
C: (f, a) => f(...a)
|
|
1805
1845
|
});
|
|
@@ -1812,16 +1852,31 @@ var ControlPipeline = class {
|
|
|
1812
1852
|
} catch (err) {
|
|
1813
1853
|
log9(err, void 0, {
|
|
1814
1854
|
F: __dxlog_file10,
|
|
1815
|
-
L:
|
|
1855
|
+
L: 161,
|
|
1816
1856
|
S: this,
|
|
1817
1857
|
C: (f, a) => f(...a)
|
|
1818
1858
|
});
|
|
1819
1859
|
}
|
|
1820
1860
|
}
|
|
1821
1861
|
};
|
|
1862
|
+
_ts_decorate6([
|
|
1863
|
+
trace2.metricsCounter()
|
|
1864
|
+
], ControlPipeline.prototype, "_usage", void 0);
|
|
1865
|
+
_ts_decorate6([
|
|
1866
|
+
trace2.metricsCounter()
|
|
1867
|
+
], ControlPipeline.prototype, "_mutations", void 0);
|
|
1868
|
+
_ts_decorate6([
|
|
1869
|
+
trace2.span()
|
|
1870
|
+
], ControlPipeline.prototype, "_consumePipeline", null);
|
|
1871
|
+
_ts_decorate6([
|
|
1872
|
+
trace2.span()
|
|
1873
|
+
], ControlPipeline.prototype, "_processMessage", null);
|
|
1874
|
+
ControlPipeline = _ts_decorate6([
|
|
1875
|
+
trace2.resource()
|
|
1876
|
+
], ControlPipeline);
|
|
1822
1877
|
|
|
1823
1878
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1824
|
-
function
|
|
1879
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1825
1880
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1826
1881
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1827
1882
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1947,7 +2002,7 @@ var Space = class Space2 {
|
|
|
1947
2002
|
setControlFeed(feed) {
|
|
1948
2003
|
invariant9(!this._controlFeed, "Control feed already set.", {
|
|
1949
2004
|
F: __dxlog_file11,
|
|
1950
|
-
L:
|
|
2005
|
+
L: 184,
|
|
1951
2006
|
S: this,
|
|
1952
2007
|
A: [
|
|
1953
2008
|
"!this._controlFeed",
|
|
@@ -1961,7 +2016,7 @@ var Space = class Space2 {
|
|
|
1961
2016
|
setDataFeed(feed) {
|
|
1962
2017
|
invariant9(!this._dataFeed, "Data feed already set.", {
|
|
1963
2018
|
F: __dxlog_file11,
|
|
1964
|
-
L:
|
|
2019
|
+
L: 191,
|
|
1965
2020
|
S: this,
|
|
1966
2021
|
A: [
|
|
1967
2022
|
"!this._dataFeed",
|
|
@@ -1987,7 +2042,7 @@ var Space = class Space2 {
|
|
|
1987
2042
|
async open(ctx) {
|
|
1988
2043
|
log10("opening...", void 0, {
|
|
1989
2044
|
F: __dxlog_file11,
|
|
1990
|
-
L:
|
|
2045
|
+
L: 213,
|
|
1991
2046
|
S: this,
|
|
1992
2047
|
C: (f, a) => f(...a)
|
|
1993
2048
|
});
|
|
@@ -2000,7 +2055,7 @@ var Space = class Space2 {
|
|
|
2000
2055
|
this._isOpen = true;
|
|
2001
2056
|
log10("opened", void 0, {
|
|
2002
2057
|
F: __dxlog_file11,
|
|
2003
|
-
L:
|
|
2058
|
+
L: 224,
|
|
2004
2059
|
S: this,
|
|
2005
2060
|
C: (f, a) => f(...a)
|
|
2006
2061
|
});
|
|
@@ -2010,7 +2065,7 @@ var Space = class Space2 {
|
|
|
2010
2065
|
key: this._key
|
|
2011
2066
|
}, {
|
|
2012
2067
|
F: __dxlog_file11,
|
|
2013
|
-
L:
|
|
2068
|
+
L: 229,
|
|
2014
2069
|
S: this,
|
|
2015
2070
|
C: (f, a) => f(...a)
|
|
2016
2071
|
});
|
|
@@ -2024,7 +2079,7 @@ var Space = class Space2 {
|
|
|
2024
2079
|
this._isOpen = false;
|
|
2025
2080
|
log10("closed", void 0, {
|
|
2026
2081
|
F: __dxlog_file11,
|
|
2027
|
-
L:
|
|
2082
|
+
L: 242,
|
|
2028
2083
|
S: this,
|
|
2029
2084
|
C: (f, a) => f(...a)
|
|
2030
2085
|
});
|
|
@@ -2032,13 +2087,13 @@ var Space = class Space2 {
|
|
|
2032
2087
|
async initializeDataPipeline() {
|
|
2033
2088
|
log10("initializeDataPipeline", void 0, {
|
|
2034
2089
|
F: __dxlog_file11,
|
|
2035
|
-
L:
|
|
2090
|
+
L: 247,
|
|
2036
2091
|
S: this,
|
|
2037
2092
|
C: (f, a) => f(...a)
|
|
2038
2093
|
});
|
|
2039
2094
|
invariant9(this._isOpen, "Space must be open to initialize data pipeline.", {
|
|
2040
2095
|
F: __dxlog_file11,
|
|
2041
|
-
L:
|
|
2096
|
+
L: 248,
|
|
2042
2097
|
S: this,
|
|
2043
2098
|
A: [
|
|
2044
2099
|
"this._isOpen",
|
|
@@ -2048,22 +2103,23 @@ var Space = class Space2 {
|
|
|
2048
2103
|
await this._dataPipeline.open();
|
|
2049
2104
|
}
|
|
2050
2105
|
};
|
|
2051
|
-
|
|
2052
|
-
logInfo
|
|
2106
|
+
_ts_decorate7([
|
|
2107
|
+
logInfo,
|
|
2108
|
+
trace3.info()
|
|
2053
2109
|
], Space.prototype, "key", null);
|
|
2054
|
-
|
|
2110
|
+
_ts_decorate7([
|
|
2055
2111
|
synchronized4,
|
|
2056
|
-
|
|
2112
|
+
trace3.span()
|
|
2057
2113
|
], Space.prototype, "open", null);
|
|
2058
|
-
|
|
2114
|
+
_ts_decorate7([
|
|
2059
2115
|
synchronized4
|
|
2060
2116
|
], Space.prototype, "close", null);
|
|
2061
|
-
|
|
2117
|
+
_ts_decorate7([
|
|
2062
2118
|
synchronized4
|
|
2063
2119
|
], Space.prototype, "initializeDataPipeline", null);
|
|
2064
|
-
Space =
|
|
2120
|
+
Space = _ts_decorate7([
|
|
2065
2121
|
trackLeaks3("open", "close"),
|
|
2066
|
-
|
|
2122
|
+
trace3.resource()
|
|
2067
2123
|
], Space);
|
|
2068
2124
|
|
|
2069
2125
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
@@ -2075,7 +2131,7 @@ import { Teleport } from "@dxos/teleport";
|
|
|
2075
2131
|
import { BlobSync } from "@dxos/teleport-extension-object-sync";
|
|
2076
2132
|
import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
|
|
2077
2133
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
2078
|
-
function
|
|
2134
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
2079
2135
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2080
2136
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2081
2137
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2116,7 +2172,7 @@ var SpaceProtocol = class {
|
|
|
2116
2172
|
key: feed.key
|
|
2117
2173
|
}, {
|
|
2118
2174
|
F: __dxlog_file12,
|
|
2119
|
-
L:
|
|
2175
|
+
L: 96,
|
|
2120
2176
|
S: this,
|
|
2121
2177
|
C: (f, a) => f(...a)
|
|
2122
2178
|
});
|
|
@@ -2125,6 +2181,7 @@ var SpaceProtocol = class {
|
|
|
2125
2181
|
session.replicator.addFeed(feed);
|
|
2126
2182
|
}
|
|
2127
2183
|
}
|
|
2184
|
+
// TODO(burdon): Rename open? Common open/close interfaces for all services?
|
|
2128
2185
|
async start() {
|
|
2129
2186
|
if (this._connection) {
|
|
2130
2187
|
return;
|
|
@@ -2138,7 +2195,7 @@ var SpaceProtocol = class {
|
|
|
2138
2195
|
await this.blobSync.open();
|
|
2139
2196
|
log11("starting...", void 0, {
|
|
2140
2197
|
F: __dxlog_file12,
|
|
2141
|
-
L:
|
|
2198
|
+
L: 122,
|
|
2142
2199
|
S: this,
|
|
2143
2200
|
C: (f, a) => f(...a)
|
|
2144
2201
|
});
|
|
@@ -2148,11 +2205,11 @@ var SpaceProtocol = class {
|
|
|
2148
2205
|
peerId: this._swarmIdentity.peerKey,
|
|
2149
2206
|
topic,
|
|
2150
2207
|
topology: new MMSTTopology(topologyConfig),
|
|
2151
|
-
label: `
|
|
2208
|
+
label: `space swarm ${topic.truncate()}`
|
|
2152
2209
|
});
|
|
2153
2210
|
log11("started", void 0, {
|
|
2154
2211
|
F: __dxlog_file12,
|
|
2155
|
-
L:
|
|
2212
|
+
L: 132,
|
|
2156
2213
|
S: this,
|
|
2157
2214
|
C: (f, a) => f(...a)
|
|
2158
2215
|
});
|
|
@@ -2162,14 +2219,14 @@ var SpaceProtocol = class {
|
|
|
2162
2219
|
if (this._connection) {
|
|
2163
2220
|
log11("stopping...", void 0, {
|
|
2164
2221
|
F: __dxlog_file12,
|
|
2165
|
-
L:
|
|
2222
|
+
L: 139,
|
|
2166
2223
|
S: this,
|
|
2167
2224
|
C: (f, a) => f(...a)
|
|
2168
2225
|
});
|
|
2169
2226
|
await this._connection.close();
|
|
2170
2227
|
log11("stopped", void 0, {
|
|
2171
2228
|
F: __dxlog_file12,
|
|
2172
|
-
L:
|
|
2229
|
+
L: 141,
|
|
2173
2230
|
S: this,
|
|
2174
2231
|
C: (f, a) => f(...a)
|
|
2175
2232
|
});
|
|
@@ -2192,10 +2249,10 @@ var SpaceProtocol = class {
|
|
|
2192
2249
|
};
|
|
2193
2250
|
}
|
|
2194
2251
|
};
|
|
2195
|
-
|
|
2252
|
+
_ts_decorate8([
|
|
2196
2253
|
logInfo2
|
|
2197
2254
|
], SpaceProtocol.prototype, "_topic", void 0);
|
|
2198
|
-
|
|
2255
|
+
_ts_decorate8([
|
|
2199
2256
|
logInfo2
|
|
2200
2257
|
], SpaceProtocol.prototype, "_ownPeerKey", null);
|
|
2201
2258
|
var AuthStatus;
|
|
@@ -2236,7 +2293,7 @@ var SpaceProtocolSession = class {
|
|
|
2236
2293
|
onAuthSuccess: () => {
|
|
2237
2294
|
log11("Peer authenticated", void 0, {
|
|
2238
2295
|
F: __dxlog_file12,
|
|
2239
|
-
L:
|
|
2296
|
+
L: 238,
|
|
2240
2297
|
S: this,
|
|
2241
2298
|
C: (f, a) => f(...a)
|
|
2242
2299
|
});
|
|
@@ -2255,10 +2312,10 @@ var SpaceProtocolSession = class {
|
|
|
2255
2312
|
await this._teleport.close();
|
|
2256
2313
|
}
|
|
2257
2314
|
};
|
|
2258
|
-
|
|
2315
|
+
_ts_decorate8([
|
|
2259
2316
|
logInfo2
|
|
2260
2317
|
], SpaceProtocolSession.prototype, "_wireParams", void 0);
|
|
2261
|
-
|
|
2318
|
+
_ts_decorate8([
|
|
2262
2319
|
logInfo2
|
|
2263
2320
|
], SpaceProtocolSession.prototype, "authStatus", null);
|
|
2264
2321
|
|
|
@@ -2267,9 +2324,9 @@ import { synchronized as synchronized5, trackLeaks as trackLeaks4 } from "@dxos/
|
|
|
2267
2324
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
2268
2325
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
2269
2326
|
import { log as log12 } from "@dxos/log";
|
|
2270
|
-
import { trace as
|
|
2327
|
+
import { trace as trace4 } from "@dxos/protocols";
|
|
2271
2328
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
2272
|
-
function
|
|
2329
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
2273
2330
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2274
2331
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2275
2332
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2303,7 +2360,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2303
2360
|
].map((space) => space.close()));
|
|
2304
2361
|
}
|
|
2305
2362
|
async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
|
|
2306
|
-
log12.trace("dxos.echo.space-manager.construct-space",
|
|
2363
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace4.begin({
|
|
2307
2364
|
id: this._instanceId
|
|
2308
2365
|
}), {
|
|
2309
2366
|
F: __dxlog_file13,
|
|
@@ -2341,24 +2398,24 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2341
2398
|
memberKey
|
|
2342
2399
|
});
|
|
2343
2400
|
this._spaces.set(space.key, space);
|
|
2344
|
-
log12.trace("dxos.echo.space-manager.construct-space",
|
|
2401
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace4.end({
|
|
2345
2402
|
id: this._instanceId
|
|
2346
2403
|
}), {
|
|
2347
2404
|
F: __dxlog_file13,
|
|
2348
|
-
L:
|
|
2405
|
+
L: 126,
|
|
2349
2406
|
S: this,
|
|
2350
2407
|
C: (f, a) => f(...a)
|
|
2351
2408
|
});
|
|
2352
2409
|
return space;
|
|
2353
2410
|
}
|
|
2354
2411
|
};
|
|
2355
|
-
|
|
2412
|
+
_ts_decorate9([
|
|
2356
2413
|
synchronized5
|
|
2357
2414
|
], SpaceManager.prototype, "open", null);
|
|
2358
|
-
|
|
2415
|
+
_ts_decorate9([
|
|
2359
2416
|
synchronized5
|
|
2360
2417
|
], SpaceManager.prototype, "close", null);
|
|
2361
|
-
SpaceManager =
|
|
2418
|
+
SpaceManager = _ts_decorate9([
|
|
2362
2419
|
trackLeaks4("open", "close")
|
|
2363
2420
|
], SpaceManager);
|
|
2364
2421
|
|
|
@@ -2388,4 +2445,4 @@ export {
|
|
|
2388
2445
|
SpaceProtocolSession,
|
|
2389
2446
|
SpaceManager
|
|
2390
2447
|
};
|
|
2391
|
-
//# sourceMappingURL=chunk-
|
|
2448
|
+
//# sourceMappingURL=chunk-GDF4DQU2.mjs.map
|