@tinyshed/tinystore 0.8.0 → 0.9.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 +1 -1
- package/dist/backup.d.ts +2 -0
- package/dist/backup.js +1 -0
- package/dist/blobs.d.ts +18 -1
- package/dist/blobs.js +52 -45
- package/dist/directory.d.ts +72 -0
- package/dist/directory.js +121 -0
- package/dist/index.d.ts +2 -1
- package/dist/jobs.d.ts +33 -9
- package/dist/jobs.js +137 -34
- package/dist/metrics.d.ts +5 -1
- package/dist/metrics.js +2 -0
- package/dist/query.d.ts +8 -1
- package/dist/query.js +25 -4
- package/dist/search.d.ts +6 -1
- package/dist/search.js +4 -2
- package/dist/sql.d.ts +26 -2
- package/dist/sql.js +18 -5
- package/dist/store.d.ts +9 -0
- package/dist/store.js +11 -0
- package/dist/wire/protocol.d.ts +200 -7
- package/dist/wire/protocol.js +602 -13
- package/package.json +8 -8
- package/src/backup.ts +3 -0
- package/src/blobs.ts +66 -45
- package/src/directory.ts +235 -0
- package/src/index.ts +9 -0
- package/src/jobs.ts +178 -41
- package/src/metrics.ts +7 -1
- package/src/query.ts +28 -6
- package/src/search.ts +10 -5
- package/src/sql.ts +35 -5
- package/src/store.ts +12 -0
- package/src/wire/protocol.ts +637 -13
package/dist/wire/protocol.js
CHANGED
|
@@ -15,6 +15,10 @@ export const methods = {
|
|
|
15
15
|
'blobs.usage': 0x040b,
|
|
16
16
|
'blobs.clear': 0x040c,
|
|
17
17
|
'blobs.read': 0x040d,
|
|
18
|
+
'blobs.directory': 0x040e,
|
|
19
|
+
'blobs.scan': 0x040f,
|
|
20
|
+
'blobs.changes': 0x0410,
|
|
21
|
+
'blobs.forget': 0x0411,
|
|
18
22
|
/**
|
|
19
23
|
* Answers once the store has the message, not once anyone handled it; in a
|
|
20
24
|
* database's transaction, it is handed over once the transaction commits.
|
|
@@ -47,6 +51,7 @@ export const methods = {
|
|
|
47
51
|
'jobs.keep': 0x020b,
|
|
48
52
|
'jobs.watch': 0x020c,
|
|
49
53
|
'jobs.tx': 0x020d,
|
|
54
|
+
'jobs.counts': 0x020e,
|
|
50
55
|
'kv.bucket.open': 0x0101,
|
|
51
56
|
'kv.get': 0x0102,
|
|
52
57
|
'kv.has': 0x0103,
|
|
@@ -244,6 +249,8 @@ export const BackupWritten = message('backup.Written', {
|
|
|
244
249
|
bytes: [2, uint],
|
|
245
250
|
/** the store seals values with a key the backup does not hold */
|
|
246
251
|
keyLeftOut: [3, bool],
|
|
252
|
+
/** the databases opened with backup false, which it holds nothing of */
|
|
253
|
+
excluded: [4, list(str)],
|
|
247
254
|
}, {
|
|
248
255
|
write(w, v) {
|
|
249
256
|
const head = w.openMap();
|
|
@@ -263,12 +270,21 @@ export const BackupWritten = message('backup.Written', {
|
|
|
263
270
|
w.bool(v.keyLeftOut);
|
|
264
271
|
n++;
|
|
265
272
|
}
|
|
273
|
+
if (v.excluded !== undefined) {
|
|
274
|
+
w.field(4);
|
|
275
|
+
w.array(v.excluded.length);
|
|
276
|
+
for (const item0 of v.excluded) {
|
|
277
|
+
w.str(item0);
|
|
278
|
+
}
|
|
279
|
+
n++;
|
|
280
|
+
}
|
|
266
281
|
w.closeMap(head, n);
|
|
267
282
|
},
|
|
268
283
|
read(r) {
|
|
269
284
|
let $files;
|
|
270
285
|
let $bytes;
|
|
271
286
|
let $keyLeftOut;
|
|
287
|
+
let $excluded;
|
|
272
288
|
for (let n = r.message(); n > 0; n--) {
|
|
273
289
|
switch (r.field()) {
|
|
274
290
|
case 1:
|
|
@@ -280,12 +296,21 @@ export const BackupWritten = message('backup.Written', {
|
|
|
280
296
|
case 3:
|
|
281
297
|
$keyLeftOut = r.bool();
|
|
282
298
|
break;
|
|
299
|
+
case 4: {
|
|
300
|
+
const items0 = [];
|
|
301
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
302
|
+
items0.push(r.str());
|
|
303
|
+
}
|
|
304
|
+
r.leave();
|
|
305
|
+
$excluded = items0;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
283
308
|
default:
|
|
284
309
|
r.skip();
|
|
285
310
|
}
|
|
286
311
|
}
|
|
287
312
|
r.leave();
|
|
288
|
-
return { files: $files, bytes: $bytes, keyLeftOut: $keyLeftOut };
|
|
313
|
+
return { files: $files, bytes: $bytes, keyLeftOut: $keyLeftOut, excluded: $excluded };
|
|
289
314
|
},
|
|
290
315
|
});
|
|
291
316
|
/**
|
|
@@ -694,10 +719,13 @@ export const BlobsWritten = message('blobs.Written', {
|
|
|
694
719
|
});
|
|
695
720
|
/**
|
|
696
721
|
* A piece of a file's bytes: an upload's DATA from the client, a read's from
|
|
697
|
-
* the server.
|
|
722
|
+
* the server. A piece of a growing directory's file brings the file's size
|
|
723
|
+
* and time as it was read, so that the reader sees it moved.
|
|
698
724
|
*/
|
|
699
725
|
export const BlobsPiece = message('blobs.Piece', {
|
|
700
726
|
bytes: [1, bin],
|
|
727
|
+
size: [2, uint],
|
|
728
|
+
lastModified: [3, int],
|
|
701
729
|
}, {
|
|
702
730
|
write(w, v) {
|
|
703
731
|
const head = w.openMap();
|
|
@@ -707,21 +735,39 @@ export const BlobsPiece = message('blobs.Piece', {
|
|
|
707
735
|
w.bin(v.bytes);
|
|
708
736
|
n++;
|
|
709
737
|
}
|
|
738
|
+
if (v.size !== undefined) {
|
|
739
|
+
w.field(2);
|
|
740
|
+
w.uint(v.size);
|
|
741
|
+
n++;
|
|
742
|
+
}
|
|
743
|
+
if (v.lastModified !== undefined) {
|
|
744
|
+
w.field(3);
|
|
745
|
+
w.int(v.lastModified);
|
|
746
|
+
n++;
|
|
747
|
+
}
|
|
710
748
|
w.closeMap(head, n);
|
|
711
749
|
},
|
|
712
750
|
read(r) {
|
|
713
751
|
let $bytes;
|
|
752
|
+
let $size;
|
|
753
|
+
let $lastModified;
|
|
714
754
|
for (let n = r.message(); n > 0; n--) {
|
|
715
755
|
switch (r.field()) {
|
|
716
756
|
case 1:
|
|
717
757
|
$bytes = r.bytes();
|
|
718
758
|
break;
|
|
759
|
+
case 2:
|
|
760
|
+
$size = r.uint();
|
|
761
|
+
break;
|
|
762
|
+
case 3:
|
|
763
|
+
$lastModified = r.int();
|
|
764
|
+
break;
|
|
719
765
|
default:
|
|
720
766
|
r.skip();
|
|
721
767
|
}
|
|
722
768
|
}
|
|
723
769
|
r.leave();
|
|
724
|
-
return { bytes: $bytes };
|
|
770
|
+
return { bytes: $bytes, size: $size, lastModified: $lastModified };
|
|
725
771
|
},
|
|
726
772
|
});
|
|
727
773
|
/**
|
|
@@ -1356,6 +1402,331 @@ export const BlobsUsage = message('blobs.Usage', {
|
|
|
1356
1402
|
return { count: $count, size: $size };
|
|
1357
1403
|
},
|
|
1358
1404
|
});
|
|
1405
|
+
/**
|
|
1406
|
+
* Opens a directory by name: a folder of the server's machine, which the
|
|
1407
|
+
* store lists and reads and never writes. Its handle takes get, head, list,
|
|
1408
|
+
* usage and read as a set of files' does, each answered from the list the
|
|
1409
|
+
* last scan wrote but a get's and a read's bytes, which come from the disk;
|
|
1410
|
+
* every call that writes a file is invalid. A connection that came with a
|
|
1411
|
+
* token names no path: it opens the directory the server was given under the
|
|
1412
|
+
* name, and one the server was not given is invalid.
|
|
1413
|
+
*/
|
|
1414
|
+
export const BlobsDirectory = message('blobs.Directory', {
|
|
1415
|
+
/** [a-z0-9][a-z0-9_-]{0,63}, never a set of files' name too */
|
|
1416
|
+
name: [1, str],
|
|
1417
|
+
/** the folder on the server's machine; the server's own when absent */
|
|
1418
|
+
path: [2, str],
|
|
1419
|
+
/** a scan on the store's background work, a period apart */
|
|
1420
|
+
every: [3, uint],
|
|
1421
|
+
/** names a scan passes over, * for any run of a name's characters */
|
|
1422
|
+
ignore: [4, list(str)],
|
|
1423
|
+
/** a read holds to no version and goes up to the size now */
|
|
1424
|
+
growing: [5, bool],
|
|
1425
|
+
}, {
|
|
1426
|
+
write(w, v) {
|
|
1427
|
+
const head = w.openMap();
|
|
1428
|
+
let n = 0;
|
|
1429
|
+
if (v.name !== undefined) {
|
|
1430
|
+
w.field(1);
|
|
1431
|
+
w.str(v.name);
|
|
1432
|
+
n++;
|
|
1433
|
+
}
|
|
1434
|
+
if (v.path !== undefined) {
|
|
1435
|
+
w.field(2);
|
|
1436
|
+
w.str(v.path);
|
|
1437
|
+
n++;
|
|
1438
|
+
}
|
|
1439
|
+
if (v.every !== undefined) {
|
|
1440
|
+
w.field(3);
|
|
1441
|
+
w.uint(v.every);
|
|
1442
|
+
n++;
|
|
1443
|
+
}
|
|
1444
|
+
if (v.ignore !== undefined) {
|
|
1445
|
+
w.field(4);
|
|
1446
|
+
w.array(v.ignore.length);
|
|
1447
|
+
for (const item0 of v.ignore) {
|
|
1448
|
+
w.str(item0);
|
|
1449
|
+
}
|
|
1450
|
+
n++;
|
|
1451
|
+
}
|
|
1452
|
+
if (v.growing !== undefined) {
|
|
1453
|
+
w.field(5);
|
|
1454
|
+
w.bool(v.growing);
|
|
1455
|
+
n++;
|
|
1456
|
+
}
|
|
1457
|
+
w.closeMap(head, n);
|
|
1458
|
+
},
|
|
1459
|
+
read(r) {
|
|
1460
|
+
let $name;
|
|
1461
|
+
let $path;
|
|
1462
|
+
let $every;
|
|
1463
|
+
let $ignore;
|
|
1464
|
+
let $growing;
|
|
1465
|
+
for (let n = r.message(); n > 0; n--) {
|
|
1466
|
+
switch (r.field()) {
|
|
1467
|
+
case 1:
|
|
1468
|
+
$name = r.str();
|
|
1469
|
+
break;
|
|
1470
|
+
case 2:
|
|
1471
|
+
$path = r.str();
|
|
1472
|
+
break;
|
|
1473
|
+
case 3:
|
|
1474
|
+
$every = r.uint();
|
|
1475
|
+
break;
|
|
1476
|
+
case 4: {
|
|
1477
|
+
const items0 = [];
|
|
1478
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
1479
|
+
items0.push(r.str());
|
|
1480
|
+
}
|
|
1481
|
+
r.leave();
|
|
1482
|
+
$ignore = items0;
|
|
1483
|
+
break;
|
|
1484
|
+
}
|
|
1485
|
+
case 5:
|
|
1486
|
+
$growing = r.bool();
|
|
1487
|
+
break;
|
|
1488
|
+
default:
|
|
1489
|
+
r.skip();
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
r.leave();
|
|
1493
|
+
return { name: $name, path: $path, every: $every, ignore: $ignore, growing: $growing };
|
|
1494
|
+
},
|
|
1495
|
+
});
|
|
1496
|
+
/**
|
|
1497
|
+
* What a scan found, and what the list holds once it ended.
|
|
1498
|
+
*/
|
|
1499
|
+
export const BlobsScanned = message('blobs.Scanned', {
|
|
1500
|
+
added: [1, uint],
|
|
1501
|
+
changed: [2, uint],
|
|
1502
|
+
removed: [3, uint],
|
|
1503
|
+
/** what it met and could not list: a link, a folder it cannot read, another disk */
|
|
1504
|
+
skipped: [4, uint],
|
|
1505
|
+
count: [5, uint],
|
|
1506
|
+
size: [6, uint],
|
|
1507
|
+
}, {
|
|
1508
|
+
write(w, v) {
|
|
1509
|
+
const head = w.openMap();
|
|
1510
|
+
let n = 0;
|
|
1511
|
+
if (v.added !== undefined) {
|
|
1512
|
+
w.field(1);
|
|
1513
|
+
w.uint(v.added);
|
|
1514
|
+
n++;
|
|
1515
|
+
}
|
|
1516
|
+
if (v.changed !== undefined) {
|
|
1517
|
+
w.field(2);
|
|
1518
|
+
w.uint(v.changed);
|
|
1519
|
+
n++;
|
|
1520
|
+
}
|
|
1521
|
+
if (v.removed !== undefined) {
|
|
1522
|
+
w.field(3);
|
|
1523
|
+
w.uint(v.removed);
|
|
1524
|
+
n++;
|
|
1525
|
+
}
|
|
1526
|
+
if (v.skipped !== undefined) {
|
|
1527
|
+
w.field(4);
|
|
1528
|
+
w.uint(v.skipped);
|
|
1529
|
+
n++;
|
|
1530
|
+
}
|
|
1531
|
+
if (v.count !== undefined) {
|
|
1532
|
+
w.field(5);
|
|
1533
|
+
w.uint(v.count);
|
|
1534
|
+
n++;
|
|
1535
|
+
}
|
|
1536
|
+
if (v.size !== undefined) {
|
|
1537
|
+
w.field(6);
|
|
1538
|
+
w.uint(v.size);
|
|
1539
|
+
n++;
|
|
1540
|
+
}
|
|
1541
|
+
w.closeMap(head, n);
|
|
1542
|
+
},
|
|
1543
|
+
read(r) {
|
|
1544
|
+
let $added;
|
|
1545
|
+
let $changed;
|
|
1546
|
+
let $removed;
|
|
1547
|
+
let $skipped;
|
|
1548
|
+
let $count;
|
|
1549
|
+
let $size;
|
|
1550
|
+
for (let n = r.message(); n > 0; n--) {
|
|
1551
|
+
switch (r.field()) {
|
|
1552
|
+
case 1:
|
|
1553
|
+
$added = r.uint();
|
|
1554
|
+
break;
|
|
1555
|
+
case 2:
|
|
1556
|
+
$changed = r.uint();
|
|
1557
|
+
break;
|
|
1558
|
+
case 3:
|
|
1559
|
+
$removed = r.uint();
|
|
1560
|
+
break;
|
|
1561
|
+
case 4:
|
|
1562
|
+
$skipped = r.uint();
|
|
1563
|
+
break;
|
|
1564
|
+
case 5:
|
|
1565
|
+
$count = r.uint();
|
|
1566
|
+
break;
|
|
1567
|
+
case 6:
|
|
1568
|
+
$size = r.uint();
|
|
1569
|
+
break;
|
|
1570
|
+
default:
|
|
1571
|
+
r.skip();
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
r.leave();
|
|
1575
|
+
return {
|
|
1576
|
+
added: $added,
|
|
1577
|
+
changed: $changed,
|
|
1578
|
+
removed: $removed,
|
|
1579
|
+
skipped: $skipped,
|
|
1580
|
+
count: $count,
|
|
1581
|
+
size: $size,
|
|
1582
|
+
};
|
|
1583
|
+
},
|
|
1584
|
+
});
|
|
1585
|
+
/**
|
|
1586
|
+
* The changes of a directory past a cursor, from the first file it listed
|
|
1587
|
+
* when absent.
|
|
1588
|
+
*/
|
|
1589
|
+
export const BlobsSince = message('blobs.Since', {
|
|
1590
|
+
handle: [1, uint],
|
|
1591
|
+
/** a page's next */
|
|
1592
|
+
after: [2, str],
|
|
1593
|
+
}, {
|
|
1594
|
+
write(w, v) {
|
|
1595
|
+
const head = w.openMap();
|
|
1596
|
+
let n = 0;
|
|
1597
|
+
if (v.handle !== undefined) {
|
|
1598
|
+
w.field(1);
|
|
1599
|
+
w.uint(v.handle);
|
|
1600
|
+
n++;
|
|
1601
|
+
}
|
|
1602
|
+
if (v.after !== undefined) {
|
|
1603
|
+
w.field(2);
|
|
1604
|
+
w.str(v.after);
|
|
1605
|
+
n++;
|
|
1606
|
+
}
|
|
1607
|
+
w.closeMap(head, n);
|
|
1608
|
+
},
|
|
1609
|
+
read(r) {
|
|
1610
|
+
let $handle;
|
|
1611
|
+
let $after;
|
|
1612
|
+
for (let n = r.message(); n > 0; n--) {
|
|
1613
|
+
switch (r.field()) {
|
|
1614
|
+
case 1:
|
|
1615
|
+
$handle = r.uint();
|
|
1616
|
+
break;
|
|
1617
|
+
case 2:
|
|
1618
|
+
$after = r.str();
|
|
1619
|
+
break;
|
|
1620
|
+
default:
|
|
1621
|
+
r.skip();
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
r.leave();
|
|
1625
|
+
return { handle: $handle, after: $after };
|
|
1626
|
+
},
|
|
1627
|
+
});
|
|
1628
|
+
export const BlobsChange = message('blobs.Change', {
|
|
1629
|
+
/** the whole path in the directory */
|
|
1630
|
+
path: [1, str],
|
|
1631
|
+
/** added, changed or removed */
|
|
1632
|
+
change: [2, str],
|
|
1633
|
+
/** none once removed */
|
|
1634
|
+
info: [3, BlobsInfo],
|
|
1635
|
+
}, {
|
|
1636
|
+
write(w, v) {
|
|
1637
|
+
const head = w.openMap();
|
|
1638
|
+
let n = 0;
|
|
1639
|
+
if (v.path !== undefined) {
|
|
1640
|
+
w.field(1);
|
|
1641
|
+
w.str(v.path);
|
|
1642
|
+
n++;
|
|
1643
|
+
}
|
|
1644
|
+
if (v.change !== undefined) {
|
|
1645
|
+
w.field(2);
|
|
1646
|
+
w.str(v.change);
|
|
1647
|
+
n++;
|
|
1648
|
+
}
|
|
1649
|
+
if (v.info !== undefined) {
|
|
1650
|
+
w.field(3);
|
|
1651
|
+
BlobsInfo.write(w, v.info);
|
|
1652
|
+
n++;
|
|
1653
|
+
}
|
|
1654
|
+
w.closeMap(head, n);
|
|
1655
|
+
},
|
|
1656
|
+
read(r) {
|
|
1657
|
+
let $path;
|
|
1658
|
+
let $change;
|
|
1659
|
+
let $info;
|
|
1660
|
+
for (let n = r.message(); n > 0; n--) {
|
|
1661
|
+
switch (r.field()) {
|
|
1662
|
+
case 1:
|
|
1663
|
+
$path = r.str();
|
|
1664
|
+
break;
|
|
1665
|
+
case 2:
|
|
1666
|
+
$change = r.str();
|
|
1667
|
+
break;
|
|
1668
|
+
case 3:
|
|
1669
|
+
$info = BlobsInfo.read(r);
|
|
1670
|
+
break;
|
|
1671
|
+
default:
|
|
1672
|
+
r.skip();
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
r.leave();
|
|
1676
|
+
return { path: $path, change: $change, info: $info };
|
|
1677
|
+
},
|
|
1678
|
+
});
|
|
1679
|
+
/**
|
|
1680
|
+
* A page of changes in the order the scans wrote them, 1000 at most; next is
|
|
1681
|
+
* always there, with no items the cursor to ask from after the next scan.
|
|
1682
|
+
*/
|
|
1683
|
+
export const BlobsChanges = message('blobs.Changes', {
|
|
1684
|
+
items: [1, list(BlobsChange)],
|
|
1685
|
+
next: [2, str],
|
|
1686
|
+
}, {
|
|
1687
|
+
write(w, v) {
|
|
1688
|
+
const head = w.openMap();
|
|
1689
|
+
let n = 0;
|
|
1690
|
+
if (v.items !== undefined) {
|
|
1691
|
+
w.field(1);
|
|
1692
|
+
w.array(v.items.length);
|
|
1693
|
+
for (const item0 of v.items) {
|
|
1694
|
+
BlobsChange.write(w, item0);
|
|
1695
|
+
}
|
|
1696
|
+
n++;
|
|
1697
|
+
}
|
|
1698
|
+
if (v.next !== undefined) {
|
|
1699
|
+
w.field(2);
|
|
1700
|
+
w.str(v.next);
|
|
1701
|
+
n++;
|
|
1702
|
+
}
|
|
1703
|
+
w.closeMap(head, n);
|
|
1704
|
+
},
|
|
1705
|
+
read(r) {
|
|
1706
|
+
let $items;
|
|
1707
|
+
let $next;
|
|
1708
|
+
for (let n = r.message(); n > 0; n--) {
|
|
1709
|
+
switch (r.field()) {
|
|
1710
|
+
case 1: {
|
|
1711
|
+
const items0 = [];
|
|
1712
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
1713
|
+
items0.push(BlobsChange.read(r));
|
|
1714
|
+
}
|
|
1715
|
+
r.leave();
|
|
1716
|
+
$items = items0;
|
|
1717
|
+
break;
|
|
1718
|
+
}
|
|
1719
|
+
case 2:
|
|
1720
|
+
$next = r.str();
|
|
1721
|
+
break;
|
|
1722
|
+
default:
|
|
1723
|
+
r.skip();
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
r.leave();
|
|
1727
|
+
return { items: $items, next: $next };
|
|
1728
|
+
},
|
|
1729
|
+
});
|
|
1359
1730
|
/**
|
|
1360
1731
|
* A message published on a channel's branch, as docs/guides/channels/README.md has
|
|
1361
1732
|
* it: every subscription listening there now receives it.
|
|
@@ -2989,11 +3360,13 @@ export const JobsCall = message('jobs.Call', {
|
|
|
2989
3360
|
},
|
|
2990
3361
|
});
|
|
2991
3362
|
/**
|
|
2992
|
-
* The job under an id
|
|
3363
|
+
* The job under an id; or, for a cancel, a job without one by the row a page
|
|
3364
|
+
* gave, its id left out.
|
|
2993
3365
|
*/
|
|
2994
3366
|
export const JobsId = message('jobs.Id', {
|
|
2995
3367
|
handle: [1, uint],
|
|
2996
3368
|
id: [2, str],
|
|
3369
|
+
row: [3, str],
|
|
2997
3370
|
}, {
|
|
2998
3371
|
write(w, v) {
|
|
2999
3372
|
const head = w.openMap();
|
|
@@ -3008,11 +3381,17 @@ export const JobsId = message('jobs.Id', {
|
|
|
3008
3381
|
w.str(v.id);
|
|
3009
3382
|
n++;
|
|
3010
3383
|
}
|
|
3384
|
+
if (v.row !== undefined) {
|
|
3385
|
+
w.field(3);
|
|
3386
|
+
w.str(v.row);
|
|
3387
|
+
n++;
|
|
3388
|
+
}
|
|
3011
3389
|
w.closeMap(head, n);
|
|
3012
3390
|
},
|
|
3013
3391
|
read(r) {
|
|
3014
3392
|
let $handle;
|
|
3015
3393
|
let $id;
|
|
3394
|
+
let $row;
|
|
3016
3395
|
for (let n = r.message(); n > 0; n--) {
|
|
3017
3396
|
switch (r.field()) {
|
|
3018
3397
|
case 1:
|
|
@@ -3021,12 +3400,15 @@ export const JobsId = message('jobs.Id', {
|
|
|
3021
3400
|
case 2:
|
|
3022
3401
|
$id = r.str();
|
|
3023
3402
|
break;
|
|
3403
|
+
case 3:
|
|
3404
|
+
$row = r.str();
|
|
3405
|
+
break;
|
|
3024
3406
|
default:
|
|
3025
3407
|
r.skip();
|
|
3026
3408
|
}
|
|
3027
3409
|
}
|
|
3028
3410
|
r.leave();
|
|
3029
|
-
return { handle: $handle, id: $id };
|
|
3411
|
+
return { handle: $handle, id: $id, row: $row };
|
|
3030
3412
|
},
|
|
3031
3413
|
});
|
|
3032
3414
|
/**
|
|
@@ -3083,6 +3465,10 @@ export const JobsJob = message('jobs.Job', {
|
|
|
3083
3465
|
/** the last run a handler finished */
|
|
3084
3466
|
startedAt: [12, int],
|
|
3085
3467
|
endedAt: [13, int],
|
|
3468
|
+
/** where a job without an id lies, which a cancel names it by */
|
|
3469
|
+
row: [14, str],
|
|
3470
|
+
/** a walk's: why the job's value no longer reads, the job left out */
|
|
3471
|
+
failure: [15, Failure],
|
|
3086
3472
|
}, {
|
|
3087
3473
|
write(w, v) {
|
|
3088
3474
|
const head = w.openMap();
|
|
@@ -3152,6 +3538,16 @@ export const JobsJob = message('jobs.Job', {
|
|
|
3152
3538
|
w.int(v.endedAt);
|
|
3153
3539
|
n++;
|
|
3154
3540
|
}
|
|
3541
|
+
if (v.row !== undefined) {
|
|
3542
|
+
w.field(14);
|
|
3543
|
+
w.str(v.row);
|
|
3544
|
+
n++;
|
|
3545
|
+
}
|
|
3546
|
+
if (v.failure !== undefined) {
|
|
3547
|
+
w.field(15);
|
|
3548
|
+
Failure.write(w, v.failure);
|
|
3549
|
+
n++;
|
|
3550
|
+
}
|
|
3155
3551
|
w.closeMap(head, n);
|
|
3156
3552
|
},
|
|
3157
3553
|
read(r) {
|
|
@@ -3168,6 +3564,8 @@ export const JobsJob = message('jobs.Job', {
|
|
|
3168
3564
|
let $repeat;
|
|
3169
3565
|
let $startedAt;
|
|
3170
3566
|
let $endedAt;
|
|
3567
|
+
let $row;
|
|
3568
|
+
let $failure;
|
|
3171
3569
|
for (let n = r.message(); n > 0; n--) {
|
|
3172
3570
|
switch (r.field()) {
|
|
3173
3571
|
case 1:
|
|
@@ -3209,6 +3607,12 @@ export const JobsJob = message('jobs.Job', {
|
|
|
3209
3607
|
case 13:
|
|
3210
3608
|
$endedAt = r.int();
|
|
3211
3609
|
break;
|
|
3610
|
+
case 14:
|
|
3611
|
+
$row = r.str();
|
|
3612
|
+
break;
|
|
3613
|
+
case 15:
|
|
3614
|
+
$failure = Failure.read(r);
|
|
3615
|
+
break;
|
|
3212
3616
|
default:
|
|
3213
3617
|
r.skip();
|
|
3214
3618
|
}
|
|
@@ -3228,6 +3632,8 @@ export const JobsJob = message('jobs.Job', {
|
|
|
3228
3632
|
repeat: $repeat,
|
|
3229
3633
|
startedAt: $startedAt,
|
|
3230
3634
|
endedAt: $endedAt,
|
|
3635
|
+
row: $row,
|
|
3636
|
+
failure: $failure,
|
|
3231
3637
|
};
|
|
3232
3638
|
},
|
|
3233
3639
|
});
|
|
@@ -3246,6 +3652,8 @@ export const JobsList = message('jobs.List', {
|
|
|
3246
3652
|
after: [4, str],
|
|
3247
3653
|
/** 100 when absent, 1000 at most */
|
|
3248
3654
|
limit: [5, uint],
|
|
3655
|
+
/** a job whose value no longer reads comes as its failure in its place, not the page's */
|
|
3656
|
+
walk: [6, bool],
|
|
3249
3657
|
}, {
|
|
3250
3658
|
write(w, v) {
|
|
3251
3659
|
const head = w.openMap();
|
|
@@ -3275,6 +3683,11 @@ export const JobsList = message('jobs.List', {
|
|
|
3275
3683
|
w.uint(v.limit);
|
|
3276
3684
|
n++;
|
|
3277
3685
|
}
|
|
3686
|
+
if (v.walk !== undefined) {
|
|
3687
|
+
w.field(6);
|
|
3688
|
+
w.bool(v.walk);
|
|
3689
|
+
n++;
|
|
3690
|
+
}
|
|
3278
3691
|
w.closeMap(head, n);
|
|
3279
3692
|
},
|
|
3280
3693
|
read(r) {
|
|
@@ -3283,6 +3696,7 @@ export const JobsList = message('jobs.List', {
|
|
|
3283
3696
|
let $state;
|
|
3284
3697
|
let $after;
|
|
3285
3698
|
let $limit;
|
|
3699
|
+
let $walk;
|
|
3286
3700
|
for (let n = r.message(); n > 0; n--) {
|
|
3287
3701
|
switch (r.field()) {
|
|
3288
3702
|
case 1:
|
|
@@ -3300,12 +3714,22 @@ export const JobsList = message('jobs.List', {
|
|
|
3300
3714
|
case 5:
|
|
3301
3715
|
$limit = r.uint();
|
|
3302
3716
|
break;
|
|
3717
|
+
case 6:
|
|
3718
|
+
$walk = r.bool();
|
|
3719
|
+
break;
|
|
3303
3720
|
default:
|
|
3304
3721
|
r.skip();
|
|
3305
3722
|
}
|
|
3306
3723
|
}
|
|
3307
3724
|
r.leave();
|
|
3308
|
-
return {
|
|
3725
|
+
return {
|
|
3726
|
+
handle: $handle,
|
|
3727
|
+
prefix: $prefix,
|
|
3728
|
+
state: $state,
|
|
3729
|
+
after: $after,
|
|
3730
|
+
limit: $limit,
|
|
3731
|
+
walk: $walk,
|
|
3732
|
+
};
|
|
3309
3733
|
},
|
|
3310
3734
|
});
|
|
3311
3735
|
export const JobsPage = message('jobs.Page', {
|
|
@@ -3355,6 +3779,71 @@ export const JobsPage = message('jobs.Page', {
|
|
|
3355
3779
|
return { jobs: $jobs, next: $next };
|
|
3356
3780
|
},
|
|
3357
3781
|
});
|
|
3782
|
+
/**
|
|
3783
|
+
* How many jobs a queue holds in each state, from one snapshot; a done job
|
|
3784
|
+
* has left it.
|
|
3785
|
+
*/
|
|
3786
|
+
export const JobsCounts = message('jobs.Counts', {
|
|
3787
|
+
/** due later */
|
|
3788
|
+
scheduled: [1, uint],
|
|
3789
|
+
/** due, and no handler runs it yet */
|
|
3790
|
+
waiting: [2, uint],
|
|
3791
|
+
running: [3, uint],
|
|
3792
|
+
/** kept for the queue's keep */
|
|
3793
|
+
failed: [4, uint],
|
|
3794
|
+
}, {
|
|
3795
|
+
write(w, v) {
|
|
3796
|
+
const head = w.openMap();
|
|
3797
|
+
let n = 0;
|
|
3798
|
+
if (v.scheduled !== undefined) {
|
|
3799
|
+
w.field(1);
|
|
3800
|
+
w.uint(v.scheduled);
|
|
3801
|
+
n++;
|
|
3802
|
+
}
|
|
3803
|
+
if (v.waiting !== undefined) {
|
|
3804
|
+
w.field(2);
|
|
3805
|
+
w.uint(v.waiting);
|
|
3806
|
+
n++;
|
|
3807
|
+
}
|
|
3808
|
+
if (v.running !== undefined) {
|
|
3809
|
+
w.field(3);
|
|
3810
|
+
w.uint(v.running);
|
|
3811
|
+
n++;
|
|
3812
|
+
}
|
|
3813
|
+
if (v.failed !== undefined) {
|
|
3814
|
+
w.field(4);
|
|
3815
|
+
w.uint(v.failed);
|
|
3816
|
+
n++;
|
|
3817
|
+
}
|
|
3818
|
+
w.closeMap(head, n);
|
|
3819
|
+
},
|
|
3820
|
+
read(r) {
|
|
3821
|
+
let $scheduled;
|
|
3822
|
+
let $waiting;
|
|
3823
|
+
let $running;
|
|
3824
|
+
let $failed;
|
|
3825
|
+
for (let n = r.message(); n > 0; n--) {
|
|
3826
|
+
switch (r.field()) {
|
|
3827
|
+
case 1:
|
|
3828
|
+
$scheduled = r.uint();
|
|
3829
|
+
break;
|
|
3830
|
+
case 2:
|
|
3831
|
+
$waiting = r.uint();
|
|
3832
|
+
break;
|
|
3833
|
+
case 3:
|
|
3834
|
+
$running = r.uint();
|
|
3835
|
+
break;
|
|
3836
|
+
case 4:
|
|
3837
|
+
$failed = r.uint();
|
|
3838
|
+
break;
|
|
3839
|
+
default:
|
|
3840
|
+
r.skip();
|
|
3841
|
+
}
|
|
3842
|
+
}
|
|
3843
|
+
r.leave();
|
|
3844
|
+
return { scheduled: $scheduled, waiting: $waiting, running: $running, failed: $failed };
|
|
3845
|
+
},
|
|
3846
|
+
});
|
|
3358
3847
|
/**
|
|
3359
3848
|
* Starts the queue's worker for the client: the server claims its jobs as they
|
|
3360
3849
|
* fall due and hands each over as a held job, no more at once than the
|
|
@@ -3698,7 +4187,7 @@ export const JobsKept = message('jobs.Kept', {
|
|
|
3698
4187
|
});
|
|
3699
4188
|
/**
|
|
3700
4189
|
* One write of a transaction: an add, a set or an update with its call, or a
|
|
3701
|
-
* cancel with its id.
|
|
4190
|
+
* cancel with its id or its row.
|
|
3702
4191
|
*/
|
|
3703
4192
|
export const JobsOp = message('jobs.Op', {
|
|
3704
4193
|
/** jobs.add, jobs.set, jobs.update or jobs.cancel */
|
|
@@ -5836,6 +6325,8 @@ export const MetricsAggregateAsked = message('metrics.AggregateAsked', {
|
|
|
5836
6325
|
calendar: [7, str],
|
|
5837
6326
|
/** an IANA name, UTC among them, which calendar takes */
|
|
5838
6327
|
timeZone: [8, str],
|
|
6328
|
+
/** a NaN sample counts in no bucket, which says how many it passed over: skipped */
|
|
6329
|
+
skipNan: [9, bool],
|
|
5839
6330
|
}, {
|
|
5840
6331
|
write(w, v) {
|
|
5841
6332
|
const head = w.openMap();
|
|
@@ -5886,6 +6377,11 @@ export const MetricsAggregateAsked = message('metrics.AggregateAsked', {
|
|
|
5886
6377
|
w.str(v.timeZone);
|
|
5887
6378
|
n++;
|
|
5888
6379
|
}
|
|
6380
|
+
if (v.skipNan !== undefined) {
|
|
6381
|
+
w.field(9);
|
|
6382
|
+
w.bool(v.skipNan);
|
|
6383
|
+
n++;
|
|
6384
|
+
}
|
|
5889
6385
|
w.closeMap(head, n);
|
|
5890
6386
|
},
|
|
5891
6387
|
read(r) {
|
|
@@ -5897,6 +6393,7 @@ export const MetricsAggregateAsked = message('metrics.AggregateAsked', {
|
|
|
5897
6393
|
let $estimate;
|
|
5898
6394
|
let $calendar;
|
|
5899
6395
|
let $timeZone;
|
|
6396
|
+
let $skipNan;
|
|
5900
6397
|
for (let n = r.message(); n > 0; n--) {
|
|
5901
6398
|
switch (r.field()) {
|
|
5902
6399
|
case 1:
|
|
@@ -5935,6 +6432,9 @@ export const MetricsAggregateAsked = message('metrics.AggregateAsked', {
|
|
|
5935
6432
|
case 8:
|
|
5936
6433
|
$timeZone = r.str();
|
|
5937
6434
|
break;
|
|
6435
|
+
case 9:
|
|
6436
|
+
$skipNan = r.bool();
|
|
6437
|
+
break;
|
|
5938
6438
|
default:
|
|
5939
6439
|
r.skip();
|
|
5940
6440
|
}
|
|
@@ -5949,6 +6449,7 @@ export const MetricsAggregateAsked = message('metrics.AggregateAsked', {
|
|
|
5949
6449
|
estimate: $estimate,
|
|
5950
6450
|
calendar: $calendar,
|
|
5951
6451
|
timeZone: $timeZone,
|
|
6452
|
+
skipNan: $skipNan,
|
|
5952
6453
|
};
|
|
5953
6454
|
},
|
|
5954
6455
|
});
|
|
@@ -5970,6 +6471,8 @@ export const MetricsBucket = message('metrics.Bucket', {
|
|
|
5970
6471
|
partial: [8, bool],
|
|
5971
6472
|
/** its first step began before the bucket before it */
|
|
5972
6473
|
gap: [9, bool],
|
|
6474
|
+
/** the NaN samples it passed over, with skipNan */
|
|
6475
|
+
skipped: [10, uint],
|
|
5973
6476
|
}, {
|
|
5974
6477
|
write(w, v) {
|
|
5975
6478
|
const head = w.openMap();
|
|
@@ -6019,6 +6522,11 @@ export const MetricsBucket = message('metrics.Bucket', {
|
|
|
6019
6522
|
w.bool(v.gap);
|
|
6020
6523
|
n++;
|
|
6021
6524
|
}
|
|
6525
|
+
if (v.skipped !== undefined) {
|
|
6526
|
+
w.field(10);
|
|
6527
|
+
w.uint(v.skipped);
|
|
6528
|
+
n++;
|
|
6529
|
+
}
|
|
6022
6530
|
w.closeMap(head, n);
|
|
6023
6531
|
},
|
|
6024
6532
|
read(r) {
|
|
@@ -6031,6 +6539,7 @@ export const MetricsBucket = message('metrics.Bucket', {
|
|
|
6031
6539
|
let $resets;
|
|
6032
6540
|
let $partial;
|
|
6033
6541
|
let $gap;
|
|
6542
|
+
let $skipped;
|
|
6034
6543
|
for (let n = r.message(); n > 0; n--) {
|
|
6035
6544
|
switch (r.field()) {
|
|
6036
6545
|
case 1:
|
|
@@ -6060,6 +6569,9 @@ export const MetricsBucket = message('metrics.Bucket', {
|
|
|
6060
6569
|
case 9:
|
|
6061
6570
|
$gap = r.bool();
|
|
6062
6571
|
break;
|
|
6572
|
+
case 10:
|
|
6573
|
+
$skipped = r.uint();
|
|
6574
|
+
break;
|
|
6063
6575
|
default:
|
|
6064
6576
|
r.skip();
|
|
6065
6577
|
}
|
|
@@ -6075,6 +6587,7 @@ export const MetricsBucket = message('metrics.Bucket', {
|
|
|
6075
6587
|
resets: $resets,
|
|
6076
6588
|
partial: $partial,
|
|
6077
6589
|
gap: $gap,
|
|
6590
|
+
skipped: $skipped,
|
|
6078
6591
|
};
|
|
6079
6592
|
},
|
|
6080
6593
|
});
|
|
@@ -10339,7 +10852,8 @@ export const SqlMigration = message('sql.Migration', {
|
|
|
10339
10852
|
});
|
|
10340
10853
|
/**
|
|
10341
10854
|
* Opens a database. Migrations, when given, are applied and checked; without
|
|
10342
|
-
* them the file opens as it is.
|
|
10855
|
+
* them the file opens as it is. One that backups leave out lies in local/
|
|
10856
|
+
* rather than sql/, and a name whose file lies in the other folder is invalid.
|
|
10343
10857
|
*/
|
|
10344
10858
|
export const SqlOpen = message('sql.Open', {
|
|
10345
10859
|
/** [a-z0-9][a-z0-9_-]{0,63} */
|
|
@@ -10347,6 +10861,8 @@ export const SqlOpen = message('sql.Open', {
|
|
|
10347
10861
|
migrations: [2, list(SqlMigration)],
|
|
10348
10862
|
/** full or os: how far its commits go before they return; the store's own when absent */
|
|
10349
10863
|
durability: [3, str],
|
|
10864
|
+
/** false: no backup takes it, nor any node; true when absent */
|
|
10865
|
+
backup: [4, bool],
|
|
10350
10866
|
}, {
|
|
10351
10867
|
write(w, v) {
|
|
10352
10868
|
const head = w.openMap();
|
|
@@ -10369,12 +10885,18 @@ export const SqlOpen = message('sql.Open', {
|
|
|
10369
10885
|
w.str(v.durability);
|
|
10370
10886
|
n++;
|
|
10371
10887
|
}
|
|
10888
|
+
if (v.backup !== undefined) {
|
|
10889
|
+
w.field(4);
|
|
10890
|
+
w.bool(v.backup);
|
|
10891
|
+
n++;
|
|
10892
|
+
}
|
|
10372
10893
|
w.closeMap(head, n);
|
|
10373
10894
|
},
|
|
10374
10895
|
read(r) {
|
|
10375
10896
|
let $name;
|
|
10376
10897
|
let $migrations;
|
|
10377
10898
|
let $durability;
|
|
10899
|
+
let $backup;
|
|
10378
10900
|
for (let n = r.message(); n > 0; n--) {
|
|
10379
10901
|
switch (r.field()) {
|
|
10380
10902
|
case 1:
|
|
@@ -10392,12 +10914,15 @@ export const SqlOpen = message('sql.Open', {
|
|
|
10392
10914
|
case 3:
|
|
10393
10915
|
$durability = r.str();
|
|
10394
10916
|
break;
|
|
10917
|
+
case 4:
|
|
10918
|
+
$backup = r.bool();
|
|
10919
|
+
break;
|
|
10395
10920
|
default:
|
|
10396
10921
|
r.skip();
|
|
10397
10922
|
}
|
|
10398
10923
|
}
|
|
10399
10924
|
r.leave();
|
|
10400
|
-
return { name: $name, migrations: $migrations, durability: $durability };
|
|
10925
|
+
return { name: $name, migrations: $migrations, durability: $durability, backup: $backup };
|
|
10401
10926
|
},
|
|
10402
10927
|
});
|
|
10403
10928
|
/**
|
|
@@ -10536,15 +11061,61 @@ export const SqlStatement = message('sql.Statement', {
|
|
|
10536
11061
|
},
|
|
10537
11062
|
});
|
|
10538
11063
|
/**
|
|
10539
|
-
*
|
|
10540
|
-
|
|
11064
|
+
* A column a statement's rows are ordered by, named as its rows name it.
|
|
11065
|
+
*/
|
|
11066
|
+
export const SqlOrder = message('sql.Order', {
|
|
11067
|
+
column: [1, str],
|
|
11068
|
+
descending: [2, bool],
|
|
11069
|
+
}, {
|
|
11070
|
+
write(w, v) {
|
|
11071
|
+
const head = w.openMap();
|
|
11072
|
+
let n = 0;
|
|
11073
|
+
if (v.column !== undefined) {
|
|
11074
|
+
w.field(1);
|
|
11075
|
+
w.str(v.column);
|
|
11076
|
+
n++;
|
|
11077
|
+
}
|
|
11078
|
+
if (v.descending !== undefined) {
|
|
11079
|
+
w.field(2);
|
|
11080
|
+
w.bool(v.descending);
|
|
11081
|
+
n++;
|
|
11082
|
+
}
|
|
11083
|
+
w.closeMap(head, n);
|
|
11084
|
+
},
|
|
11085
|
+
read(r) {
|
|
11086
|
+
let $column;
|
|
11087
|
+
let $descending;
|
|
11088
|
+
for (let n = r.message(); n > 0; n--) {
|
|
11089
|
+
switch (r.field()) {
|
|
11090
|
+
case 1:
|
|
11091
|
+
$column = r.str();
|
|
11092
|
+
break;
|
|
11093
|
+
case 2:
|
|
11094
|
+
$descending = r.bool();
|
|
11095
|
+
break;
|
|
11096
|
+
default:
|
|
11097
|
+
r.skip();
|
|
11098
|
+
}
|
|
11099
|
+
}
|
|
11100
|
+
r.leave();
|
|
11101
|
+
return { column: $column, descending: $descending };
|
|
11102
|
+
},
|
|
11103
|
+
});
|
|
11104
|
+
/**
|
|
11105
|
+
* What a statement gives back: its rows, one row or none, one value, or each
|
|
11106
|
+
* row as the reader reads it. A write with returning runs on the writer, its
|
|
11107
|
+
* rows given once it is durable. Each reads one snapshot of five seconds at
|
|
11108
|
+
* most; with order, the columns its text orders its rows by, a unique one
|
|
11109
|
+
* last, it reads on past that after the last row it sent, and without it
|
|
11110
|
+
* fails limit there.
|
|
10541
11111
|
*/
|
|
10542
11112
|
export const SqlQuery = message('sql.Query', {
|
|
10543
11113
|
handle: [1, uint],
|
|
10544
11114
|
text: [2, str],
|
|
10545
11115
|
values: [3, list(sqlValue)],
|
|
10546
|
-
/** all, one or
|
|
11116
|
+
/** all, one, scalar or each */
|
|
10547
11117
|
want: [4, str],
|
|
11118
|
+
order: [5, list(SqlOrder)],
|
|
10548
11119
|
}, {
|
|
10549
11120
|
write(w, v) {
|
|
10550
11121
|
const head = w.openMap();
|
|
@@ -10572,6 +11143,14 @@ export const SqlQuery = message('sql.Query', {
|
|
|
10572
11143
|
w.str(v.want);
|
|
10573
11144
|
n++;
|
|
10574
11145
|
}
|
|
11146
|
+
if (v.order !== undefined) {
|
|
11147
|
+
w.field(5);
|
|
11148
|
+
w.array(v.order.length);
|
|
11149
|
+
for (const item0 of v.order) {
|
|
11150
|
+
SqlOrder.write(w, item0);
|
|
11151
|
+
}
|
|
11152
|
+
n++;
|
|
11153
|
+
}
|
|
10575
11154
|
w.closeMap(head, n);
|
|
10576
11155
|
},
|
|
10577
11156
|
read(r) {
|
|
@@ -10579,6 +11158,7 @@ export const SqlQuery = message('sql.Query', {
|
|
|
10579
11158
|
let $text;
|
|
10580
11159
|
let $values;
|
|
10581
11160
|
let $want;
|
|
11161
|
+
let $order;
|
|
10582
11162
|
for (let n = r.message(); n > 0; n--) {
|
|
10583
11163
|
switch (r.field()) {
|
|
10584
11164
|
case 1:
|
|
@@ -10599,12 +11179,21 @@ export const SqlQuery = message('sql.Query', {
|
|
|
10599
11179
|
case 4:
|
|
10600
11180
|
$want = r.str();
|
|
10601
11181
|
break;
|
|
11182
|
+
case 5: {
|
|
11183
|
+
const items0 = [];
|
|
11184
|
+
for (let i0 = r.array(); i0 > 0; i0--) {
|
|
11185
|
+
items0.push(SqlOrder.read(r));
|
|
11186
|
+
}
|
|
11187
|
+
r.leave();
|
|
11188
|
+
$order = items0;
|
|
11189
|
+
break;
|
|
11190
|
+
}
|
|
10602
11191
|
default:
|
|
10603
11192
|
r.skip();
|
|
10604
11193
|
}
|
|
10605
11194
|
}
|
|
10606
11195
|
r.leave();
|
|
10607
|
-
return { handle: $handle, text: $text, values: $values, want: $want };
|
|
11196
|
+
return { handle: $handle, text: $text, values: $values, want: $want, order: $order };
|
|
10608
11197
|
},
|
|
10609
11198
|
});
|
|
10610
11199
|
/**
|