autobee 2.0.0-rc.13 → 2.0.0-rc.14
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/index.js +8 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -57,6 +57,7 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
57
57
|
this.id = null
|
|
58
58
|
this.bootstrap = null
|
|
59
59
|
this.handlers = handlers
|
|
60
|
+
this.stats = { undos: 0, fastForwards: 0, drains: 0, applies: 0, appends: 0 }
|
|
60
61
|
|
|
61
62
|
this.system = new System(this.store.namespace('system'), this.name, {
|
|
62
63
|
getEncryptionProvider: this.getSystemEncryption,
|
|
@@ -498,6 +499,8 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
498
499
|
async _drain() {
|
|
499
500
|
if (this._updating) await this._updating
|
|
500
501
|
|
|
502
|
+
this.stats.drains++
|
|
503
|
+
|
|
501
504
|
if (this.bootFrom) {
|
|
502
505
|
await this._initFromHead(this.bootFrom)
|
|
503
506
|
this.bootFrom = null
|
|
@@ -919,6 +922,7 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
919
922
|
const t = await topo.sort(this, batch)
|
|
920
923
|
|
|
921
924
|
if (t.undo) {
|
|
925
|
+
this.stats.undos++
|
|
922
926
|
t.view = await this.system.undo(t.undo)
|
|
923
927
|
}
|
|
924
928
|
|
|
@@ -967,6 +971,7 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
967
971
|
}
|
|
968
972
|
|
|
969
973
|
if (this._hasApply && (await this.system.canApply(batch[0].key, optimistic))) {
|
|
974
|
+
this.stats.applies++
|
|
970
975
|
this._host.applying = batch
|
|
971
976
|
await this._handlers.apply(userBatch, this._workingView, this._host)
|
|
972
977
|
this._host.applying = null
|
|
@@ -1035,6 +1040,8 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
1035
1040
|
async append(values, { optimistic = false } = {}) {
|
|
1036
1041
|
if (this.closing) throw new Error('Autobee closed')
|
|
1037
1042
|
|
|
1043
|
+
this.stats.appends++
|
|
1044
|
+
|
|
1038
1045
|
if (!Array.isArray(values)) values = [values]
|
|
1039
1046
|
|
|
1040
1047
|
if (!this.opened) await this.ready()
|
|
@@ -1272,6 +1279,7 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
1272
1279
|
|
|
1273
1280
|
await this._update(changes)
|
|
1274
1281
|
|
|
1282
|
+
this.stats.fastForwards++
|
|
1275
1283
|
this.emit('move-to', to, from)
|
|
1276
1284
|
this.reboot.resolve({ to, from })
|
|
1277
1285
|
|