dignity.js 0.7.0 → 0.8.0
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/README.md +34 -0
- package/dist/dignity.cjs.js +899 -8
- package/dist/dignity.cjs.js.map +4 -4
- package/dist/dignity.esm.js +899 -8
- package/dist/dignity.esm.js.map +3 -3
- package/dist/dignity.min.js +18 -18
- package/docs/assets/dignity.esm.js +899 -8
- package/docs/assets/playground-demos.js +63 -3
- package/docs/assets/playground.css +70 -4
- package/docs/assets/playground.js +49 -2
- package/docs/assets/styles.css +2 -2
- package/docs/index.html +65 -9
- package/docs/openapi-like.json +17 -4
- package/package.json +2 -2
- package/src/core/dignity-p2p.js +428 -6
- package/src/cqrs/bulk-relay.js +35 -0
- package/src/cqrs/domain-events.js +285 -0
- package/src/cqrs/peer-group-tiers.js +46 -0
- package/src/cqrs/query-replica.js +213 -0
- package/src/gossip/peer-group.js +1 -1
- package/src/index.js +34 -1
package/README.md
CHANGED
|
@@ -142,6 +142,40 @@ await node.leavePeerGroup('feed:alice');
|
|
|
142
142
|
|
|
143
143
|
Small collaborations (chess players, document co-editing) should keep using direct `connectToPeers` mesh. Large read-only audiences (chess spectators, public timelines) should use PeerGroup gossip. See the [docs PeerGroup section](https://jose-compu.github.io/dignity.js/#peer-groups).
|
|
144
144
|
|
|
145
|
+
### CQRS tiers, domain events, and query replicas (v0.8+)
|
|
146
|
+
|
|
147
|
+
For audiences above ~5 000 subscribers per publisher, use the command/query split:
|
|
148
|
+
|
|
149
|
+
- **Command path** — publisher writes locally; signed domain events auto-publish on `create` / `update` / `remove`.
|
|
150
|
+
- **Live tier** — first `liveCap` subscribers (default 5 000) receive real-time gossip.
|
|
151
|
+
- **Bulk tier** — overflow subscribers receive batched updates via bulk relays.
|
|
152
|
+
- **Query path** — `DignityQueryReplica` maintains local materialized views from the event stream.
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
const { DignityP2P, DignityQueryReplica } = require('dignity.js');
|
|
156
|
+
|
|
157
|
+
// Publisher
|
|
158
|
+
await publisher.joinPeerGroup('feed:alice', {
|
|
159
|
+
role: 'publisher',
|
|
160
|
+
tiered: true,
|
|
161
|
+
liveCap: 5000,
|
|
162
|
+
domainEvents: true
|
|
163
|
+
});
|
|
164
|
+
await publisher.create('posts', { text: 'hello' }, { id: 'p1', peerGroupId: 'feed:alice' });
|
|
165
|
+
|
|
166
|
+
// Read-only replica (no command capability)
|
|
167
|
+
const replica = new DignityQueryReplica(reader, {
|
|
168
|
+
groupId: 'feed:alice',
|
|
169
|
+
collections: ['posts'],
|
|
170
|
+
publisherId: 'alice'
|
|
171
|
+
});
|
|
172
|
+
await replica.start({ bootstrapPeerIds: ['alice'] });
|
|
173
|
+
replica.read('posts', 'p1');
|
|
174
|
+
replica.verifyChain(); // hash-chain consistency
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Default `maxHops` is **64** (was 6), sufficient for epidemic spread at fanout 3 without per-group tuning.
|
|
178
|
+
|
|
145
179
|
## Room / Team Discovery
|
|
146
180
|
|
|
147
181
|
Use scoped discovery to find active peers in a room (for example `main`, `team:red`, `raid-42`).
|