@dxos/echo-pipeline 0.4.9-main.4fd47cd → 0.4.9-main.7750cb2
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-WAN2XUWE.mjs → chunk-P3HBH2ZU.mjs} +269 -1125
- package/dist/lib/browser/chunk-P3HBH2ZU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +2 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +2 -54
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/{chunk-U6J2HC4T.cjs → chunk-WS67FBKB.cjs} +306 -1160
- package/dist/lib/node/chunk-WS67FBKB.cjs.map +7 -0
- package/dist/lib/node/index.cjs +22 -30
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +13 -64
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/types/src/db-host/data-service.d.ts +3 -13
- package/dist/types/src/db-host/data-service.d.ts.map +1 -1
- package/dist/types/src/db-host/index.d.ts +0 -2
- package/dist/types/src/db-host/index.d.ts.map +1 -1
- package/dist/types/src/space/index.d.ts +0 -1
- package/dist/types/src/space/index.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +0 -4
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +0 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/automerge-host.ts +1 -1
- package/src/db-host/data-service.ts +10 -56
- package/src/db-host/index.ts +0 -2
- package/src/space/index.ts +0 -1
- package/src/space/space.test.ts +2 -112
- package/src/space/space.ts +0 -56
- package/src/testing/index.ts +0 -1
- package/dist/lib/browser/chunk-WAN2XUWE.mjs.map +0 -7
- package/dist/lib/node/chunk-U6J2HC4T.cjs.map +0 -7
- package/dist/types/src/db-host/data-service-host.d.ts +0 -38
- package/dist/types/src/db-host/data-service-host.d.ts.map +0 -1
- package/dist/types/src/db-host/database-host.d.ts +0 -27
- package/dist/types/src/db-host/database-host.d.ts.map +0 -1
- package/dist/types/src/space/data-pipeline.d.ts +0 -79
- package/dist/types/src/space/data-pipeline.d.ts.map +0 -1
- package/dist/types/src/space/data-pipeline.test.d.ts +0 -1
- package/dist/types/src/space/data-pipeline.test.d.ts.map +0 -1
- package/dist/types/src/testing/util.d.ts +0 -10
- package/dist/types/src/testing/util.d.ts.map +0 -1
- package/src/db-host/data-service-host.ts +0 -233
- package/src/db-host/database-host.ts +0 -63
- package/src/space/data-pipeline.test.ts +0 -3
- package/src/space/data-pipeline.ts +0 -425
- package/src/testing/util.ts +0 -61
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../../../../src/space/space.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAmC,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEtE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,KAAK,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../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Root":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-pipeline",
|
|
3
|
-
"version": "0.4.9-main.
|
|
3
|
+
"version": "0.4.9-main.7750cb2",
|
|
4
4
|
"description": "ECHO database.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -36,38 +36,38 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"crc-32": "^1.2.2",
|
|
39
|
-
"@dxos/async": "0.4.9-main.
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/context": "0.4.9-main.
|
|
43
|
-
"@dxos/credentials": "0.4.9-main.
|
|
44
|
-
"@dxos/crypto": "0.4.9-main.
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/feed-store": "0.4.9-main.
|
|
48
|
-
"@dxos/debug": "0.4.9-main.
|
|
49
|
-
"@dxos/hypercore": "0.4.9-main.
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/log": "0.4.9-main.
|
|
54
|
-
"@dxos/messaging": "0.4.9-main.
|
|
55
|
-
"@dxos/model-factory": "0.4.9-main.
|
|
56
|
-
"@dxos/network-manager": "0.4.9-main.
|
|
57
|
-
"@dxos/node-std": "0.4.9-main.
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/teleport
|
|
62
|
-
"@dxos/teleport": "0.4.9-main.
|
|
63
|
-
"@dxos/teleport-extension-gossip": "0.4.9-main.
|
|
64
|
-
"@dxos/teleport-extension-object-sync": "0.4.9-main.
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/timeframe": "0.4.9-main.
|
|
68
|
-
"@dxos/tracing": "0.4.9-main.
|
|
69
|
-
"@dxos/typings": "0.4.9-main.
|
|
70
|
-
"@dxos/util": "0.4.9-main.
|
|
39
|
+
"@dxos/async": "0.4.9-main.7750cb2",
|
|
40
|
+
"@dxos/automerge": "0.4.9-main.7750cb2",
|
|
41
|
+
"@dxos/codec-protobuf": "0.4.9-main.7750cb2",
|
|
42
|
+
"@dxos/context": "0.4.9-main.7750cb2",
|
|
43
|
+
"@dxos/credentials": "0.4.9-main.7750cb2",
|
|
44
|
+
"@dxos/crypto": "0.4.9-main.7750cb2",
|
|
45
|
+
"@dxos/echo-db": "0.4.9-main.7750cb2",
|
|
46
|
+
"@dxos/document-model": "0.4.9-main.7750cb2",
|
|
47
|
+
"@dxos/feed-store": "0.4.9-main.7750cb2",
|
|
48
|
+
"@dxos/debug": "0.4.9-main.7750cb2",
|
|
49
|
+
"@dxos/hypercore": "0.4.9-main.7750cb2",
|
|
50
|
+
"@dxos/invariant": "0.4.9-main.7750cb2",
|
|
51
|
+
"@dxos/keyring": "0.4.9-main.7750cb2",
|
|
52
|
+
"@dxos/keys": "0.4.9-main.7750cb2",
|
|
53
|
+
"@dxos/log": "0.4.9-main.7750cb2",
|
|
54
|
+
"@dxos/messaging": "0.4.9-main.7750cb2",
|
|
55
|
+
"@dxos/model-factory": "0.4.9-main.7750cb2",
|
|
56
|
+
"@dxos/network-manager": "0.4.9-main.7750cb2",
|
|
57
|
+
"@dxos/node-std": "0.4.9-main.7750cb2",
|
|
58
|
+
"@dxos/protocols": "0.4.9-main.7750cb2",
|
|
59
|
+
"@dxos/random-access-storage": "0.4.9-main.7750cb2",
|
|
60
|
+
"@dxos/rpc": "0.4.9-main.7750cb2",
|
|
61
|
+
"@dxos/teleport": "0.4.9-main.7750cb2",
|
|
62
|
+
"@dxos/teleport-extension-automerge-replicator": "0.4.9-main.7750cb2",
|
|
63
|
+
"@dxos/teleport-extension-gossip": "0.4.9-main.7750cb2",
|
|
64
|
+
"@dxos/teleport-extension-object-sync": "0.4.9-main.7750cb2",
|
|
65
|
+
"@dxos/teleport-extension-replicator": "0.4.9-main.7750cb2",
|
|
66
|
+
"@dxos/text-model": "0.4.9-main.7750cb2",
|
|
67
|
+
"@dxos/timeframe": "0.4.9-main.7750cb2",
|
|
68
|
+
"@dxos/tracing": "0.4.9-main.7750cb2",
|
|
69
|
+
"@dxos/typings": "0.4.9-main.7750cb2",
|
|
70
|
+
"@dxos/util": "0.4.9-main.7750cb2"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"fast-check": "^3.15.1",
|
|
@@ -3,83 +3,37 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Stream } from '@dxos/codec-protobuf';
|
|
6
|
-
import { raise } from '@dxos/debug';
|
|
7
|
-
import { invariant } from '@dxos/invariant';
|
|
8
|
-
import { PublicKey } from '@dxos/keys';
|
|
9
|
-
import { log } from '@dxos/log';
|
|
10
6
|
import {
|
|
11
7
|
type DataService,
|
|
12
|
-
type MutationReceipt,
|
|
13
|
-
type SubscribeRequest,
|
|
14
8
|
type EchoEvent,
|
|
15
|
-
type WriteRequest,
|
|
16
9
|
type FlushRequest,
|
|
10
|
+
type HostInfo,
|
|
11
|
+
type MutationReceipt,
|
|
12
|
+
type SubscribeRequest,
|
|
17
13
|
type SyncRepoRequest,
|
|
18
14
|
type SyncRepoResponse,
|
|
19
|
-
type
|
|
15
|
+
type WriteRequest,
|
|
20
16
|
} from '@dxos/protocols/proto/dxos/echo/service';
|
|
21
|
-
import { ComplexMap } from '@dxos/util';
|
|
22
17
|
|
|
23
|
-
import { type DataServiceHost } from './data-service-host';
|
|
24
18
|
import { type AutomergeHost } from '../automerge';
|
|
25
19
|
|
|
26
|
-
// TODO(burdon): Clear on close.
|
|
27
|
-
export class DataServiceSubscriptions {
|
|
28
|
-
private readonly _spaces = new ComplexMap<PublicKey, DataServiceHost>(PublicKey.hash);
|
|
29
|
-
|
|
30
|
-
clear() {
|
|
31
|
-
this._spaces.clear();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async registerSpace(spaceKey: PublicKey, host: DataServiceHost) {
|
|
35
|
-
log('Registering space', { spaceKey });
|
|
36
|
-
invariant(!this._spaces.has(spaceKey));
|
|
37
|
-
await host.open();
|
|
38
|
-
this._spaces.set(spaceKey, host);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async unregisterSpace(spaceKey: PublicKey) {
|
|
42
|
-
log('Unregistering space', { spaceKey });
|
|
43
|
-
const host = this._spaces.get(spaceKey);
|
|
44
|
-
await host?.close();
|
|
45
|
-
this._spaces.delete(spaceKey);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
getDataService(spaceKey: PublicKey) {
|
|
49
|
-
return this._spaces.get(spaceKey);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
20
|
/**
|
|
54
|
-
*
|
|
21
|
+
* Data sync between client and services.
|
|
55
22
|
*/
|
|
56
23
|
// TODO(burdon): Move to client-services.
|
|
57
24
|
export class DataServiceImpl implements DataService {
|
|
58
|
-
constructor(
|
|
59
|
-
private readonly _subscriptions: DataServiceSubscriptions,
|
|
60
|
-
private readonly _automergeHost: AutomergeHost,
|
|
61
|
-
) {}
|
|
25
|
+
constructor(private readonly _automergeHost: AutomergeHost) {}
|
|
62
26
|
|
|
63
27
|
subscribe(request: SubscribeRequest): Stream<EchoEvent> {
|
|
64
|
-
|
|
65
|
-
const host =
|
|
66
|
-
this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
|
|
67
|
-
return host.subscribe();
|
|
28
|
+
throw new Error('Deprecated.');
|
|
68
29
|
}
|
|
69
30
|
|
|
70
31
|
write(request: WriteRequest): Promise<MutationReceipt> {
|
|
71
|
-
|
|
72
|
-
invariant(request.batch);
|
|
73
|
-
const host =
|
|
74
|
-
this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
|
|
75
|
-
return host.write(request);
|
|
32
|
+
throw new Error('Deprecated.');
|
|
76
33
|
}
|
|
77
34
|
|
|
78
|
-
flush(request: FlushRequest): Promise<void> {
|
|
79
|
-
|
|
80
|
-
const host =
|
|
81
|
-
this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
|
|
82
|
-
return host.flush();
|
|
35
|
+
async flush(request: FlushRequest): Promise<void> {
|
|
36
|
+
// TODO(dmaretskyi): Implement with automerge.
|
|
83
37
|
}
|
|
84
38
|
|
|
85
39
|
// Automerge specific.
|
package/src/db-host/index.ts
CHANGED
package/src/space/index.ts
CHANGED
package/src/space/space.test.ts
CHANGED
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import expect from 'expect';
|
|
6
|
-
import { promisify } from 'node:util';
|
|
7
6
|
|
|
8
7
|
import { Context } from '@dxos/context';
|
|
9
|
-
import {
|
|
10
|
-
import { invariant } from '@dxos/invariant';
|
|
8
|
+
import { CredentialGenerator } from '@dxos/credentials';
|
|
11
9
|
import { afterTest, describe, test } from '@dxos/test';
|
|
12
10
|
|
|
13
|
-
import { TestAgentBuilder
|
|
11
|
+
import { TestAgentBuilder } from '../testing';
|
|
14
12
|
|
|
15
13
|
// TODO(burdon): Factor out?
|
|
16
14
|
const run = <T>(cb: () => Promise<T>): Promise<T> => cb();
|
|
@@ -29,11 +27,6 @@ describe('space/space', () => {
|
|
|
29
27
|
await agent.spaceGenesis(space);
|
|
30
28
|
|
|
31
29
|
await space.controlPipeline.state!.waitUntilTimeframe(space.controlPipeline.state!.endTimeframe);
|
|
32
|
-
await space.initializeDataPipeline();
|
|
33
|
-
await space.dataPipeline.ensureEpochInitialized();
|
|
34
|
-
|
|
35
|
-
invariant(space.dataPipeline.databaseHost);
|
|
36
|
-
await testLocalDatabase(space.dataPipeline);
|
|
37
30
|
|
|
38
31
|
await builder.close();
|
|
39
32
|
expect(space.isOpen).toBeFalsy();
|
|
@@ -57,8 +50,6 @@ describe('space/space', () => {
|
|
|
57
50
|
await agent.spaceGenesis(space);
|
|
58
51
|
|
|
59
52
|
await space.controlPipeline.state!.waitUntilTimeframe(space.controlPipeline.state!.endTimeframe);
|
|
60
|
-
await space.initializeDataPipeline();
|
|
61
|
-
await space.dataPipeline.ensureEpochInitialized();
|
|
62
53
|
|
|
63
54
|
return [agent, space];
|
|
64
55
|
});
|
|
@@ -100,9 +91,6 @@ describe('space/space', () => {
|
|
|
100
91
|
}
|
|
101
92
|
}
|
|
102
93
|
|
|
103
|
-
await space2.initializeDataPipeline();
|
|
104
|
-
await space2.dataPipeline.ensureEpochInitialized();
|
|
105
|
-
|
|
106
94
|
{
|
|
107
95
|
// Initial data exchange.
|
|
108
96
|
|
|
@@ -115,9 +103,6 @@ describe('space/space', () => {
|
|
|
115
103
|
|
|
116
104
|
// TODO(burdon): Write multiple items (extract for all tests).
|
|
117
105
|
|
|
118
|
-
await testLocalDatabase(space1.dataPipeline, space2.dataPipeline);
|
|
119
|
-
await testLocalDatabase(space2.dataPipeline, space1.dataPipeline);
|
|
120
|
-
|
|
121
106
|
await builder.close();
|
|
122
107
|
expect(space1.isOpen).toBeFalsy();
|
|
123
108
|
expect(space2.isOpen).toBeFalsy();
|
|
@@ -136,13 +121,6 @@ describe('space/space', () => {
|
|
|
136
121
|
await agent.spaceGenesis(space1);
|
|
137
122
|
|
|
138
123
|
await space1.controlPipeline.state!.waitUntilTimeframe(space1.controlPipeline.state!.endTimeframe);
|
|
139
|
-
await space1.initializeDataPipeline();
|
|
140
|
-
await space1.dataPipeline.ensureEpochInitialized();
|
|
141
|
-
|
|
142
|
-
invariant(space1.dataPipeline.databaseHost);
|
|
143
|
-
await testLocalDatabase(space1.dataPipeline);
|
|
144
|
-
|
|
145
|
-
const objectCount = space1.dataPipeline.itemManager.entities.size;
|
|
146
124
|
|
|
147
125
|
await space1.close();
|
|
148
126
|
expect(space1.isOpen).toBeFalsy();
|
|
@@ -152,16 +130,6 @@ describe('space/space', () => {
|
|
|
152
130
|
|
|
153
131
|
await space2.open(new Context());
|
|
154
132
|
await space2.controlPipeline.state!.waitUntilTimeframe(space2.controlPipeline.state!.endTimeframe);
|
|
155
|
-
await space2.initializeDataPipeline();
|
|
156
|
-
await space2.dataPipeline.ensureEpochInitialized();
|
|
157
|
-
|
|
158
|
-
space2.dataPipeline.setTargetTimeframe(space2.dataPipeline.pipelineState!.endTimeframe);
|
|
159
|
-
await space2.dataPipeline.pipelineState!.waitUntilReachedTargetTimeframe();
|
|
160
|
-
|
|
161
|
-
invariant(space2.dataPipeline.databaseHost);
|
|
162
|
-
expect(space2.dataPipeline.itemManager.entities.size).toEqual(objectCount);
|
|
163
|
-
|
|
164
|
-
await testLocalDatabase(space2.dataPipeline);
|
|
165
133
|
});
|
|
166
134
|
|
|
167
135
|
test('re-open', async () => {
|
|
@@ -170,7 +138,6 @@ describe('space/space', () => {
|
|
|
170
138
|
const agent = await builder.createPeer();
|
|
171
139
|
const space = await agent.createSpace();
|
|
172
140
|
|
|
173
|
-
let objectCount: number;
|
|
174
141
|
{
|
|
175
142
|
await space.open(new Context());
|
|
176
143
|
afterTest(() => space.close());
|
|
@@ -179,13 +146,6 @@ describe('space/space', () => {
|
|
|
179
146
|
await agent.spaceGenesis(space);
|
|
180
147
|
|
|
181
148
|
await space.controlPipeline.state!.waitUntilTimeframe(space.controlPipeline.state!.endTimeframe);
|
|
182
|
-
await space.initializeDataPipeline();
|
|
183
|
-
await space.dataPipeline.ensureEpochInitialized();
|
|
184
|
-
|
|
185
|
-
invariant(space.dataPipeline.databaseHost);
|
|
186
|
-
await testLocalDatabase(space.dataPipeline);
|
|
187
|
-
|
|
188
|
-
objectCount = space.dataPipeline.itemManager.entities.size;
|
|
189
149
|
|
|
190
150
|
await space.close();
|
|
191
151
|
expect(space.isOpen).toBeFalsy();
|
|
@@ -197,76 +157,6 @@ describe('space/space', () => {
|
|
|
197
157
|
expect(space.isOpen).toBeTruthy();
|
|
198
158
|
|
|
199
159
|
await space.controlPipeline.state!.waitUntilTimeframe(space.controlPipeline.state!.endTimeframe);
|
|
200
|
-
await space.initializeDataPipeline();
|
|
201
|
-
await space.dataPipeline.ensureEpochInitialized();
|
|
202
|
-
|
|
203
|
-
space.dataPipeline.setTargetTimeframe(space.dataPipeline.pipelineState!.endTimeframe);
|
|
204
|
-
await space.dataPipeline.pipelineState!.waitUntilReachedTargetTimeframe();
|
|
205
|
-
|
|
206
|
-
invariant(space.dataPipeline.databaseHost);
|
|
207
|
-
expect(space.dataPipeline.itemManager.entities.size).toEqual(objectCount);
|
|
208
|
-
|
|
209
|
-
await testLocalDatabase(space.dataPipeline);
|
|
210
160
|
}
|
|
211
161
|
});
|
|
212
|
-
|
|
213
|
-
test('create epoch', async () => {
|
|
214
|
-
const builder = new TestAgentBuilder();
|
|
215
|
-
afterTest(async () => await builder.close());
|
|
216
|
-
const agent = await builder.createPeer();
|
|
217
|
-
const space1 = await agent.createSpace();
|
|
218
|
-
|
|
219
|
-
await space1.open(new Context());
|
|
220
|
-
expect(space1.isOpen).toBeTruthy();
|
|
221
|
-
afterTest(() => space1.close());
|
|
222
|
-
|
|
223
|
-
await agent.spaceGenesis(space1);
|
|
224
|
-
|
|
225
|
-
await space1.controlPipeline.state!.waitUntilTimeframe(space1.controlPipeline.state!.endTimeframe);
|
|
226
|
-
await space1.initializeDataPipeline();
|
|
227
|
-
await space1.dataPipeline.ensureEpochInitialized();
|
|
228
|
-
|
|
229
|
-
invariant(space1.dataPipeline.databaseHost);
|
|
230
|
-
await testLocalDatabase(space1.dataPipeline);
|
|
231
|
-
|
|
232
|
-
const objectCount = space1.dataPipeline.itemManager.entities.size;
|
|
233
|
-
|
|
234
|
-
const epoch = await space1.dataPipeline.createEpoch();
|
|
235
|
-
await space1.controlPipeline.writer.write({
|
|
236
|
-
credential: {
|
|
237
|
-
credential: await createCredential({
|
|
238
|
-
issuer: agent.identityKey,
|
|
239
|
-
subject: space1.key,
|
|
240
|
-
assertion: {
|
|
241
|
-
'@type': 'dxos.halo.credentials.Epoch',
|
|
242
|
-
...epoch,
|
|
243
|
-
},
|
|
244
|
-
signer: agent.keyring,
|
|
245
|
-
}),
|
|
246
|
-
},
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
await space1.close();
|
|
250
|
-
expect(space1.isOpen).toBeFalsy();
|
|
251
|
-
|
|
252
|
-
// Clear the data feed - epoch snapshot should have the data.
|
|
253
|
-
const feed = await agent.feedStore.openFeed(space1.dataFeedKey!, { sparse: true });
|
|
254
|
-
await promisify(feed.core.clear.bind(feed.core))(0, feed.length);
|
|
255
|
-
|
|
256
|
-
// Re-open.
|
|
257
|
-
const space2 = await agent.createSpace(agent.identityKey, space1.key, space1.genesisFeedKey, space1.dataFeedKey);
|
|
258
|
-
|
|
259
|
-
await space2.open(new Context());
|
|
260
|
-
await space2.controlPipeline.state!.waitUntilTimeframe(space2.controlPipeline.state!.endTimeframe);
|
|
261
|
-
await space2.initializeDataPipeline();
|
|
262
|
-
await space2.dataPipeline.ensureEpochInitialized();
|
|
263
|
-
|
|
264
|
-
space2.dataPipeline.setTargetTimeframe(space2.dataPipeline.pipelineState!.endTimeframe);
|
|
265
|
-
await space2.dataPipeline.pipelineState!.waitUntilReachedTargetTimeframe();
|
|
266
|
-
|
|
267
|
-
invariant(space2.dataPipeline.databaseHost);
|
|
268
|
-
expect(space2.dataPipeline.itemManager.entities.size).toEqual(objectCount);
|
|
269
|
-
|
|
270
|
-
await testLocalDatabase(space2.dataPipeline);
|
|
271
|
-
});
|
|
272
162
|
});
|
package/src/space/space.ts
CHANGED
|
@@ -17,7 +17,6 @@ import { trace } from '@dxos/tracing';
|
|
|
17
17
|
import { type AsyncCallback, Callback } from '@dxos/util';
|
|
18
18
|
|
|
19
19
|
import { ControlPipeline } from './control-pipeline';
|
|
20
|
-
import { DataPipeline } from './data-pipeline';
|
|
21
20
|
import { type SpaceProtocol } from './space-protocol';
|
|
22
21
|
import { type SnapshotManager } from '../db-host';
|
|
23
22
|
import { type MetadataStore } from '../metadata';
|
|
@@ -65,9 +64,6 @@ export class Space {
|
|
|
65
64
|
@trace.info()
|
|
66
65
|
private readonly _controlPipeline: ControlPipeline;
|
|
67
66
|
|
|
68
|
-
@trace.info()
|
|
69
|
-
private readonly _dataPipeline: DataPipeline;
|
|
70
|
-
|
|
71
67
|
private readonly _snapshotManager: SnapshotManager;
|
|
72
68
|
|
|
73
69
|
private _isOpen = false;
|
|
@@ -93,17 +89,6 @@ export class Space {
|
|
|
93
89
|
// Enable sparse replication to not download mutations covered by prior epochs.
|
|
94
90
|
const sparse = info.assertion.designation === AdmittedFeed.Designation.DATA;
|
|
95
91
|
|
|
96
|
-
if (info.assertion.designation === AdmittedFeed.Designation.DATA) {
|
|
97
|
-
// We will add all existing data feeds when the data pipeline is initialized.
|
|
98
|
-
queueMicrotask(async () => {
|
|
99
|
-
if (this._dataPipeline.pipeline) {
|
|
100
|
-
if (!this._dataPipeline.pipeline.hasFeed(info.key)) {
|
|
101
|
-
return this._dataPipeline.pipeline.addFeed(await this._feedProvider(info.key, { sparse }));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
92
|
if (!info.key.equals(params.genesisFeed.key)) {
|
|
108
93
|
queueMicrotask(async () => {
|
|
109
94
|
this.protocol.addFeed(await params.feedProvider(info.key, { sparse }));
|
|
@@ -120,30 +105,6 @@ export class Space {
|
|
|
120
105
|
// Start replicating the genesis feed.
|
|
121
106
|
this.protocol = params.protocol;
|
|
122
107
|
this.protocol.addFeed(params.genesisFeed);
|
|
123
|
-
|
|
124
|
-
this._dataPipeline = new DataPipeline({
|
|
125
|
-
modelFactory: params.modelFactory,
|
|
126
|
-
metadataStore: params.metadataStore,
|
|
127
|
-
snapshotManager: params.snapshotManager,
|
|
128
|
-
memberKey: params.memberKey,
|
|
129
|
-
spaceKey: this._key,
|
|
130
|
-
feedInfoProvider: (feedKey) => this._controlPipeline.spaceState.feeds.get(feedKey),
|
|
131
|
-
snapshotId: params.snapshotId,
|
|
132
|
-
onPipelineCreated: async (pipeline) => {
|
|
133
|
-
if (this._dataFeed) {
|
|
134
|
-
pipeline.setWriteFeed(this._dataFeed);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Add existing feeds.
|
|
138
|
-
await this._addFeedMutex.executeSynchronized(async () => {
|
|
139
|
-
for (const feed of this._controlPipeline.spaceState.feeds.values()) {
|
|
140
|
-
if (feed.assertion.designation === AdmittedFeed.Designation.DATA && !pipeline.hasFeed(feed.key)) {
|
|
141
|
-
await pipeline.addFeed(await this._feedProvider(feed.key, { sparse: true }));
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
108
|
}
|
|
148
109
|
|
|
149
110
|
@logInfo
|
|
@@ -179,10 +140,6 @@ export class Space {
|
|
|
179
140
|
return this._controlPipeline.pipeline;
|
|
180
141
|
}
|
|
181
142
|
|
|
182
|
-
get dataPipeline(): DataPipeline {
|
|
183
|
-
return this._dataPipeline;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
143
|
get snapshotManager(): SnapshotManager {
|
|
187
144
|
return this._snapshotManager;
|
|
188
145
|
}
|
|
@@ -197,8 +154,6 @@ export class Space {
|
|
|
197
154
|
async setDataFeed(feed: FeedWrapper<FeedMessage>) {
|
|
198
155
|
invariant(!this._dataFeed, 'Data feed already set.');
|
|
199
156
|
this._dataFeed = feed;
|
|
200
|
-
await this._dataPipeline.pipeline?.addFeed(feed);
|
|
201
|
-
this._dataPipeline.pipeline?.setWriteFeed(feed);
|
|
202
157
|
return this;
|
|
203
158
|
}
|
|
204
159
|
|
|
@@ -226,7 +181,6 @@ export class Space {
|
|
|
226
181
|
// Order is important.
|
|
227
182
|
await this._controlPipeline.start();
|
|
228
183
|
await this.protocol.start();
|
|
229
|
-
await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
|
|
230
184
|
|
|
231
185
|
this._isOpen = true;
|
|
232
186
|
log('opened');
|
|
@@ -238,9 +192,6 @@ export class Space {
|
|
|
238
192
|
if (!this._isOpen) {
|
|
239
193
|
return;
|
|
240
194
|
}
|
|
241
|
-
await this._controlPipeline.spaceState.removeCredentialProcessor(this._dataPipeline);
|
|
242
|
-
|
|
243
|
-
await this._dataPipeline.close();
|
|
244
195
|
|
|
245
196
|
// Closes in reverse order to open.
|
|
246
197
|
await this.protocol.stop();
|
|
@@ -249,11 +200,4 @@ export class Space {
|
|
|
249
200
|
this._isOpen = false;
|
|
250
201
|
log('closed');
|
|
251
202
|
}
|
|
252
|
-
|
|
253
|
-
@synchronized
|
|
254
|
-
async initializeDataPipeline() {
|
|
255
|
-
log('initializeDataPipeline');
|
|
256
|
-
invariant(this._isOpen, 'Space must be open to initialize data pipeline.');
|
|
257
|
-
await this._dataPipeline.open();
|
|
258
|
-
}
|
|
259
203
|
}
|
package/src/testing/index.ts
CHANGED