@dxos/echo-db 2.33.5-dev.4dcc5349 → 2.33.5-dev.61c93034
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/src/api/selection/queries.d.ts.map +1 -1
- package/dist/src/api/selection/queries.js +13 -17
- package/dist/src/api/selection/queries.js.map +1 -1
- package/dist/src/api/selection/selection.d.ts.map +1 -1
- package/dist/src/api/selection/selection.js +1 -3
- package/dist/src/api/selection/selection.js.map +1 -1
- package/dist/src/api/selection/selection.test.js +4 -12
- package/dist/src/api/selection/selection.test.js.map +1 -1
- package/dist/src/database/item-demuxer.d.ts +1 -1
- package/dist/src/database/item-demuxer.d.ts.map +1 -1
- package/dist/src/database/item-demuxer.js +3 -5
- package/dist/src/database/item-demuxer.js.map +1 -1
- package/dist/src/database/item-manager.js +2 -2
- package/dist/src/database/item-manager.js.map +1 -1
- package/dist/src/database/testing.js +1 -1
- package/dist/src/database/testing.js.map +1 -1
- package/dist/src/halo/halo-party.d.ts.map +1 -1
- package/dist/src/halo/halo-party.js +3 -1
- package/dist/src/halo/halo-party.js.map +1 -1
- package/dist/src/halo/identity.js +2 -2
- package/dist/src/halo/identity.js.map +1 -1
- package/dist/src/halo/party-opener.d.ts +1 -1
- package/dist/src/halo/party-opener.d.ts.map +1 -1
- package/dist/src/halo/party-opener.js +2 -2
- package/dist/src/halo/party-opener.js.map +1 -1
- package/dist/src/halo/preferences.d.ts.map +1 -1
- package/dist/src/halo/preferences.js +7 -10
- package/dist/src/halo/preferences.js.map +1 -1
- package/dist/src/invitations/greeting-protocol-provider.d.ts.map +1 -1
- package/dist/src/invitations/greeting-protocol-provider.js +5 -9
- package/dist/src/invitations/greeting-protocol-provider.js.map +1 -1
- package/dist/src/invitations/greeting-responder.d.ts.map +1 -1
- package/dist/src/invitations/greeting-responder.js +8 -12
- package/dist/src/invitations/greeting-responder.js.map +1 -1
- package/dist/src/invitations/offline-invitation-claimer.d.ts.map +1 -1
- package/dist/src/invitations/offline-invitation-claimer.js +5 -7
- package/dist/src/invitations/offline-invitation-claimer.js.map +1 -1
- package/dist/src/parties/data-party.d.ts.map +1 -1
- package/dist/src/parties/data-party.js +3 -1
- package/dist/src/parties/data-party.js.map +1 -1
- package/dist/src/pipeline/message-selector.d.ts +1 -1
- package/dist/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/src/pipeline/message-selector.js +29 -32
- package/dist/src/pipeline/message-selector.js.map +1 -1
- package/dist/src/pipeline/party-core.test.js +2 -1
- package/dist/src/pipeline/party-core.test.js.map +1 -1
- package/dist/src/protocol/auth-plugin.d.ts +1 -1
- package/dist/src/protocol/auth-plugin.d.ts.map +1 -1
- package/dist/src/protocol/auth-plugin.js +1 -3
- package/dist/src/protocol/auth-plugin.js.map +1 -1
- package/dist/src/protocol/authenticator.d.ts +2 -2
- package/dist/src/protocol/authenticator.d.ts.map +1 -1
- package/dist/src/protocol/authenticator.js +12 -16
- package/dist/src/protocol/authenticator.js.map +1 -1
- package/dist/src/protocol/halo-recovery-plugin.d.ts +1 -1
- package/dist/src/protocol/halo-recovery-plugin.d.ts.map +1 -1
- package/dist/src/protocol/halo-recovery-plugin.js +1 -3
- package/dist/src/protocol/halo-recovery-plugin.js.map +1 -1
- package/dist/src/protocol/identity-credentials.d.ts +2 -2
- package/dist/src/protocol/identity-credentials.d.ts.map +1 -1
- package/dist/src/protocol/identity-credentials.js +4 -4
- package/dist/src/protocol/identity-credentials.js.map +1 -1
- package/dist/src/protocol/offline-invitation-plugin.d.ts +1 -1
- package/dist/src/protocol/offline-invitation-plugin.d.ts.map +1 -1
- package/dist/src/protocol/offline-invitation-plugin.js +1 -3
- package/dist/src/protocol/offline-invitation-plugin.js.map +1 -1
- package/dist/src/protocol/party-protocol-factory.d.ts +1 -14
- package/dist/src/protocol/party-protocol-factory.d.ts.map +1 -1
- package/dist/src/protocol/party-protocol-factory.js +2 -55
- package/dist/src/protocol/party-protocol-factory.js.map +1 -1
- package/dist/src/protocol/replicator-plugin.d.ts +7 -0
- package/dist/src/protocol/replicator-plugin.d.ts.map +1 -0
- package/dist/src/protocol/replicator-plugin.js +36 -0
- package/dist/src/protocol/replicator-plugin.js.map +1 -0
- package/dist/src/snapshots/snapshot-generator.d.ts +1 -1
- package/dist/src/snapshots/snapshot-generator.d.ts.map +1 -1
- package/dist/src/snapshots/snapshot-generator.js +13 -15
- package/dist/src/snapshots/snapshot-generator.js.map +1 -1
- package/dist/src/testing/benchmark.test.d.ts +2 -0
- package/dist/src/testing/benchmark.test.d.ts.map +1 -0
- package/dist/src/testing/benchmark.test.js +25 -0
- package/dist/src/testing/benchmark.test.js.map +1 -0
- package/dist/src/testing/testing-factories.js +2 -2
- package/dist/src/testing/testing-factories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -18
- package/src/api/selection/queries.ts +14 -18
- package/src/api/selection/selection.test.ts +4 -12
- package/src/api/selection/selection.ts +1 -7
- package/src/database/item-demuxer.ts +2 -4
- package/src/database/item-manager.ts +2 -2
- package/src/database/testing.ts +1 -1
- package/src/halo/halo-party.ts +2 -1
- package/src/halo/identity.ts +2 -2
- package/src/halo/party-opener.ts +2 -2
- package/src/halo/preferences.ts +7 -10
- package/src/invitations/greeting-protocol-provider.ts +5 -9
- package/src/invitations/greeting-responder.ts +9 -13
- package/src/invitations/offline-invitation-claimer.ts +5 -7
- package/src/parties/data-party.ts +2 -1
- package/src/pipeline/message-selector.ts +30 -36
- package/src/pipeline/party-core.test.ts +4 -7
- package/src/protocol/auth-plugin.ts +1 -3
- package/src/protocol/authenticator.ts +27 -31
- package/src/protocol/halo-recovery-plugin.ts +4 -6
- package/src/protocol/identity-credentials.ts +4 -4
- package/src/protocol/offline-invitation-plugin.ts +4 -6
- package/src/protocol/party-protocol-factory.ts +3 -56
- package/src/protocol/replicator-plugin.ts +37 -0
- package/src/snapshots/snapshot-generator.ts +12 -16
- package/src/testing/benchmark.test.ts +30 -0
- package/src/testing/testing-factories.ts +2 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import debug from 'debug';
|
|
6
|
+
|
|
7
|
+
import { keyToString } from '@dxos/crypto';
|
|
8
|
+
import { Replicator } from '@dxos/protocol-plugin-replicator';
|
|
9
|
+
|
|
10
|
+
import { PartyFeedProvider } from '../pipeline';
|
|
11
|
+
|
|
12
|
+
const log = debug('dxos:echo-db:protocol:replicator');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Creates the protocol plugin for feed replication.
|
|
16
|
+
*/
|
|
17
|
+
export const createReplicatorPlugin = (feedProvider: PartyFeedProvider) =>
|
|
18
|
+
new Replicator({
|
|
19
|
+
load: async () => {
|
|
20
|
+
const feeds = feedProvider.getFeeds();
|
|
21
|
+
log(`Loading feeds: ${feeds.map(feed => keyToString(feed.key))}`);
|
|
22
|
+
return feeds.map((feed) => ({ discoveryKey: feed.feed.discoveryKey }));
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
subscribe: (addFeedToReplicatedSet: (feed: any) => void) => feedProvider.feedOpened.on(async (feed) => {
|
|
26
|
+
log(`Adding feed: ${feed.key.toHex()}`);
|
|
27
|
+
addFeedToReplicatedSet({ discoveryKey: feed.feed.discoveryKey });
|
|
28
|
+
}),
|
|
29
|
+
|
|
30
|
+
replicate: async (remoteFeeds, info) => {
|
|
31
|
+
// We can ignore remoteFeeds entirely, since the set of feeds we want to replicate is dictated by the Party.
|
|
32
|
+
// TODO(telackey): Why are we opening feeds? Necessary or belt/braces thinking, or because open party does it?
|
|
33
|
+
const feeds = feedProvider.getFeeds();
|
|
34
|
+
log(`Replicating: peerId=${info.session}; feeds=${feeds.map(feed => feed.key.toHex())}`);
|
|
35
|
+
return feeds.map(feed => feed.feed);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
@@ -10,20 +10,16 @@ import { SnapshotStore } from './snapshot-store';
|
|
|
10
10
|
|
|
11
11
|
const log = debug('dxos:snapshot-generator');
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} catch (err: any) {
|
|
24
|
-
console.error('Failed to save snapshot');
|
|
25
|
-
console.error(err);
|
|
26
|
-
}
|
|
13
|
+
export const createAutomaticSnapshots = (party: PartyCore, clock: TimeframeClock, store: SnapshotStore, interval: number) => clock.update.on(async timeframe => {
|
|
14
|
+
const totalMessages = timeframe.totalMessages();
|
|
15
|
+
if (totalMessages > 0 && totalMessages % interval === 0) {
|
|
16
|
+
log(`Saving snapshot of ${party.key.humanize()}...`);
|
|
17
|
+
try {
|
|
18
|
+
const snapshot = party.createSnapshot();
|
|
19
|
+
await store.save(snapshot);
|
|
20
|
+
} catch (err: any) {
|
|
21
|
+
console.error('Failed to save snapshot');
|
|
22
|
+
console.error(err);
|
|
27
23
|
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { ObjectModel } from '@dxos/object-model';
|
|
6
|
+
|
|
7
|
+
import { ECHO } from '../echo';
|
|
8
|
+
|
|
9
|
+
const ITEMS = 100;
|
|
10
|
+
const MUTATIONS = 1000;
|
|
11
|
+
|
|
12
|
+
it.skip('Database benchmark', async () => {
|
|
13
|
+
const echo = new ECHO({ snapshots: false });
|
|
14
|
+
await echo.open();
|
|
15
|
+
await echo.halo.createProfile();
|
|
16
|
+
const party = await echo.createParty();
|
|
17
|
+
|
|
18
|
+
const start = Date.now();
|
|
19
|
+
for (let i = 0; i < ITEMS; i++) {
|
|
20
|
+
const item = await party.database.createItem({ model: ObjectModel, type: 'test:item' });
|
|
21
|
+
|
|
22
|
+
for (let j = 0; j < MUTATIONS; j++) {
|
|
23
|
+
await item.model.set(`key${j % 100}`, `value-${j}`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
console.log(`${i * MUTATIONS}/${ITEMS * MUTATIONS} ${((Date.now() - start) / ((i + 1) * MUTATIONS / 1000)).toFixed(1)} µs/mut ${((i + 1) * MUTATIONS / (Date.now() - start) * 1000).toFixed(1)} mut/s`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
await echo.close();
|
|
30
|
+
});
|
|
@@ -22,10 +22,10 @@ export type TestPeer = Awaited<ReturnType<typeof createTestInstance>>;
|
|
|
22
22
|
|
|
23
23
|
export type WithTestMeta<T> = T & { testMeta: TestPeer }
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const addTestMeta = <T>(obj: T, meta: TestPeer): WithTestMeta<T> => {
|
|
26
26
|
(obj as any).testMeta = meta;
|
|
27
27
|
return obj as any;
|
|
28
|
-
}
|
|
28
|
+
};
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Creates a number of test ECHO instances and a party that's shared between all of them.
|