@tinyshed/tinystore 0.1.0-rc.5 → 0.1.0-rc.6
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 +37 -37
- package/bin/tinystore.js +12 -1
- package/dist/backup.d.ts +33 -0
- package/dist/backup.js +49 -0
- package/dist/blobs.d.ts +160 -79
- package/dist/blobs.js +510 -217
- package/dist/channels.d.ts +90 -0
- package/dist/channels.js +291 -0
- package/dist/clock.js +3 -3
- package/dist/config.d.ts +209 -86
- package/dist/config.js +581 -538
- package/dist/connection.d.ts +64 -2
- package/dist/connection.js +201 -16
- package/dist/console.d.ts +27 -3
- package/dist/console.js +165 -12
- package/dist/dotenv.d.ts +7 -0
- package/dist/dotenv.js +79 -0
- package/dist/errors.d.ts +61 -1
- package/dist/errors.js +81 -1
- package/dist/handles.d.ts +44 -2
- package/dist/handles.js +81 -2
- package/dist/index.d.ts +17 -11
- package/dist/index.js +5 -3
- package/dist/instruments.d.ts +177 -0
- package/dist/instruments.js +819 -0
- package/dist/jobs.d.ts +335 -239
- package/dist/jobs.js +716 -536
- package/dist/json.d.ts +2 -0
- package/dist/json.js +122 -0
- package/dist/kv.d.ts +130 -243
- package/dist/kv.js +273 -640
- package/dist/limits.d.ts +80 -0
- package/dist/limits.js +139 -0
- package/dist/locks.d.ts +62 -0
- package/dist/locks.js +237 -0
- package/dist/logger.d.ts +45 -9
- package/dist/logger.js +150 -38
- package/dist/metrics.d.ts +210 -209
- package/dist/metrics.js +319 -556
- package/dist/once.d.ts +19 -18
- package/dist/once.js +74 -63
- package/dist/query.d.ts +181 -0
- package/dist/query.js +788 -0
- package/dist/records.d.ts +241 -150
- package/dist/records.js +507 -291
- package/dist/runtime/addon.d.ts +14 -0
- package/dist/runtime/addon.js +69 -0
- package/dist/runtime/bun.js +5 -7
- package/dist/runtime/node.js +5 -7
- package/dist/runtime/pipe.d.ts +17 -0
- package/dist/runtime/pipe.js +133 -0
- package/dist/runtime/shared.d.ts +6 -0
- package/dist/runtime/shared.js +19 -0
- package/dist/runtime.d.ts +5 -2
- package/dist/search.d.ts +189 -0
- package/dist/search.js +281 -0
- package/dist/session.d.ts +31 -3
- package/dist/session.js +153 -41
- package/dist/sql.d.ts +228 -78
- package/dist/sql.js +745 -240
- package/dist/store.d.ts +244 -24
- package/dist/store.js +270 -67
- package/dist/time.d.ts +5 -1
- package/dist/time.js +22 -2
- package/dist/tx.d.ts +61 -0
- package/dist/tx.js +314 -0
- package/dist/wire/codec.d.ts +23 -7
- package/dist/wire/codec.js +56 -35
- package/dist/wire/frame.d.ts +2 -0
- package/dist/wire/frame.js +31 -14
- package/dist/wire/messages.d.ts +259 -0
- package/dist/wire/messages.js +22 -0
- package/dist/wire/msgpack.d.ts +49 -1
- package/dist/wire/msgpack.js +293 -56
- package/dist/wire/protocol.d.ts +2683 -0
- package/dist/wire/protocol.js +10846 -0
- package/package.json +39 -38
- package/src/backup.ts +81 -0
- package/src/blobs.ts +678 -301
- package/src/channels.ts +377 -0
- package/src/clock.ts +4 -4
- package/src/config.ts +902 -612
- package/src/connection.ts +279 -21
- package/src/console.ts +180 -12
- package/src/dotenv.ts +82 -0
- package/src/errors.ts +105 -0
- package/src/handles.ts +157 -8
- package/src/index.ts +158 -52
- package/src/instruments.ts +1042 -0
- package/src/jobs.ts +1017 -733
- package/src/json.ts +133 -0
- package/src/kv.ts +424 -847
- package/src/limits.ts +202 -0
- package/src/locks.ts +320 -0
- package/src/logger.ts +209 -40
- package/src/metrics.ts +557 -752
- package/src/once.ts +86 -83
- package/src/query.ts +1005 -0
- package/src/records.ts +795 -418
- package/src/runtime/addon.ts +99 -0
- package/src/runtime/bun.ts +5 -7
- package/src/runtime/node.ts +5 -7
- package/src/runtime/pipe.ts +178 -0
- package/src/runtime/shared.ts +20 -0
- package/src/runtime.ts +5 -2
- package/src/search.ts +480 -0
- package/src/session.ts +187 -41
- package/src/sql.ts +993 -306
- package/src/store.ts +473 -78
- package/src/time.ts +48 -3
- package/src/tx.ts +426 -0
- package/src/wire/codec.ts +78 -37
- package/src/wire/frame.ts +44 -14
- package/src/wire/messages.ts +25 -0
- package/src/wire/msgpack.ts +327 -56
- package/src/wire/protocol.ts +11709 -0
- package/dist/limiter.d.ts +0 -45
- package/dist/limiter.js +0 -68
- package/dist/quota.d.ts +0 -44
- package/dist/quota.js +0 -98
- package/src/limiter.ts +0 -99
- package/src/quota.ts +0 -137
package/dist/records.js
CHANGED
|
@@ -1,346 +1,562 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// Streams of events, as docs/guides/records/README.md has them, over the protocol: a
|
|
2
|
+
// stream opened by name, its events appended whole and read back by time and
|
|
3
|
+
// by what they hold, a page at a time, and every stream read together. A
|
|
4
|
+
// store's logger keeps its lines in a stream through the same append; a tail
|
|
5
|
+
// follows what is written from now on, and a writer of lines turns another
|
|
6
|
+
// program's output into events.
|
|
7
|
+
import { pieceOf } from './connection.js';
|
|
8
|
+
import { jsonOf } from './console.js';
|
|
9
|
+
import { ClosedError, InvalidError } from './errors.js';
|
|
10
|
+
import { checkName, handleOn, viaLink } from './handles.js';
|
|
11
|
+
import { parseJson } from './json.js';
|
|
12
|
+
import { encodeFields, newStoreLogger, } from './logger.js';
|
|
7
13
|
import { ms } from './time.js';
|
|
8
14
|
import { currentTrace } from './trace.js';
|
|
9
|
-
import { Empty, methods,
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
function idOf(id, bytes, what) {
|
|
35
|
-
if (id === undefined) {
|
|
36
|
-
return undefined;
|
|
15
|
+
import { Empty, Handle, methods, RecordsAggregateAsked, RecordsAppend, RecordsBatch, RecordsCount, RecordsDamage, RecordsDamages, RecordsDropped, RecordsFieldNamesAsked, RecordsNames, RecordsOpen, RecordsPage, RecordsPiece, RecordsPollAsked, RecordsQuery, RecordsRows, RecordsStreams, RecordsTailBatch, RecordsTopAsked, RecordsTops, } from './wire/protocol.js';
|
|
16
|
+
const newline = 0x0a;
|
|
17
|
+
/** What a writer of lines holds for the server at most: past it, lines are dropped and counted. */
|
|
18
|
+
const linesHeld = 1 << 20;
|
|
19
|
+
/** The bytes one event holds: a longer line is dropped whole, as the store drops one. */
|
|
20
|
+
const eventRoom = 256 << 10;
|
|
21
|
+
const encoder = new TextEncoder();
|
|
22
|
+
const levelNumbers = {
|
|
23
|
+
trace: -8,
|
|
24
|
+
debug: -4,
|
|
25
|
+
info: 0,
|
|
26
|
+
warn: 4,
|
|
27
|
+
error: 8,
|
|
28
|
+
fatal: 12,
|
|
29
|
+
};
|
|
30
|
+
const levelNames = ['trace', 'debug', 'info', 'warn', 'error', 'fatal'];
|
|
31
|
+
/** What every read takes: a stream's handle, or every stream without one. */
|
|
32
|
+
class Reads {
|
|
33
|
+
/** One page, from one moment of the file: `{ events, next }`. */
|
|
34
|
+
async list(query) {
|
|
35
|
+
const asked = queryOf(query);
|
|
36
|
+
const answer = await this.ask('records.list', handle => RecordsQuery.encode({ ...asked, handle }));
|
|
37
|
+
const page = RecordsPage.decode(answer);
|
|
38
|
+
const events = (page.events ?? []).map(eventOf);
|
|
39
|
+
return page.next === undefined ? { events } : { events, next: page.next };
|
|
37
40
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
/** Every event the query finds, a page after another. */
|
|
42
|
+
async *all(query) {
|
|
43
|
+
let after = query?.after;
|
|
44
|
+
for (;;) {
|
|
45
|
+
const page = await this.list(after === undefined ? query : { ...query, after });
|
|
46
|
+
yield* page.events;
|
|
47
|
+
if (page.next === undefined) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
after = page.next;
|
|
51
|
+
}
|
|
41
52
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return undefined;
|
|
53
|
+
/** How many events the query finds. */
|
|
54
|
+
async count(query) {
|
|
55
|
+
const asked = queryOf(query);
|
|
56
|
+
const answer = await this.ask('records.count', handle => RecordsQuery.encode({ ...asked, handle }));
|
|
57
|
+
return RecordsCount.decode(answer).count ?? 0;
|
|
48
58
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
/**
|
|
60
|
+
* A key's most frequent values and how many events hold each: ten unless
|
|
61
|
+
* `limit` asks for more, at most 1000. The key is a field's or a
|
|
62
|
+
* context's, or `stream`, `name` or `level`.
|
|
63
|
+
*/
|
|
64
|
+
async top(key, query) {
|
|
65
|
+
const asked = queryOf(query);
|
|
66
|
+
const answer = await this.ask('records.top', handle => RecordsTopAsked.encode({ query: { ...asked, handle }, key }));
|
|
67
|
+
return (RecordsTops.decode(answer).values ?? []).map(top => ({
|
|
68
|
+
value: parseJson(top.value ?? 'null'),
|
|
69
|
+
count: top.count ?? 0,
|
|
70
|
+
}));
|
|
57
71
|
}
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
/** A row for each span of `every` and each value of the keys of `by`, with its count. */
|
|
73
|
+
async aggregate(query = {}) {
|
|
74
|
+
const { every, by, stats, distinct, ...counted } = query;
|
|
75
|
+
const asked = queryOf(counted);
|
|
76
|
+
const answer = await this.ask('records.aggregate', handle => RecordsAggregateAsked.encode({
|
|
77
|
+
query: { ...asked, handle },
|
|
78
|
+
every: every === undefined ? undefined : ms(every),
|
|
79
|
+
by: by === undefined ? undefined : [...by],
|
|
80
|
+
stats: stats === undefined ? undefined : [...stats],
|
|
81
|
+
distinct: distinct === undefined ? undefined : [...distinct],
|
|
82
|
+
}));
|
|
83
|
+
return (RecordsRows.decode(answer).rows ?? []).map(row => ({
|
|
84
|
+
at: dateOf(row.at ?? 0n),
|
|
85
|
+
count: row.count ?? 0,
|
|
86
|
+
by: mapValues(row.by, json => parseJson(json)),
|
|
87
|
+
stats: mapValues(row.stats, kept => ({
|
|
88
|
+
samples: kept.samples ?? 0,
|
|
89
|
+
sum: parseJson(kept.sum ?? '0'),
|
|
90
|
+
min: parseJson(kept.min ?? '0'),
|
|
91
|
+
max: parseJson(kept.max ?? '0'),
|
|
92
|
+
avg: kept.avg ?? 0,
|
|
93
|
+
})),
|
|
94
|
+
distinct: mapValues(row.distinct, count => count),
|
|
95
|
+
}));
|
|
68
96
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
name: textOf(r.name),
|
|
76
|
-
level: r.level,
|
|
77
|
-
body: r.body,
|
|
78
|
-
traceId: r.traceId,
|
|
79
|
-
spanId: r.spanId,
|
|
80
|
-
context: pairs(r.context),
|
|
81
|
-
attrs: pairs(r.attrs),
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* A page's next: where the range moved, both ends as nanoseconds, so that a
|
|
86
|
-
* query over the last `since` continues the range it started with.
|
|
87
|
-
*
|
|
88
|
-
* from 1700000000000000000, open end → '1700000000000000000:'
|
|
89
|
-
*/
|
|
90
|
-
function cursorOf(from, to) {
|
|
91
|
-
return `${from ?? ''}:${to ?? ''}`;
|
|
92
|
-
}
|
|
93
|
-
function rangeOf(q) {
|
|
94
|
-
if (q?.after !== undefined) {
|
|
95
|
-
const ends = /^(-?\d*):(-?\d*)$/.exec(q.after);
|
|
96
|
-
if (ends === null) {
|
|
97
|
-
throw new InvalidError(`${JSON.stringify(q.after)} is no page's next`);
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
from: ends[1] === '' ? undefined : BigInt(ends[1]),
|
|
101
|
-
to: ends[2] === '' ? undefined : BigInt(ends[2]),
|
|
102
|
-
};
|
|
97
|
+
/** The keys the events hold, in fields and in context, sorted; `prefix` narrows them. */
|
|
98
|
+
async fieldNames(query) {
|
|
99
|
+
const { prefix, ...rest } = query ?? {};
|
|
100
|
+
const asked = queryOf(rest);
|
|
101
|
+
const answer = await this.ask('records.fieldNames', handle => RecordsFieldNamesAsked.encode({ query: { ...asked, handle }, prefix }));
|
|
102
|
+
return RecordsNames.decode(answer).names ?? [];
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
/**
|
|
105
|
+
* The events written from now on that the query finds, a batch as they
|
|
106
|
+
* are written: `{ events, missed }`. A reader slower than the writers
|
|
107
|
+
* skips what left the store's hold, and the batch after says how many.
|
|
108
|
+
* It ends when its loop is left, and when the server's store closes.
|
|
109
|
+
*/
|
|
110
|
+
async *tail(query) {
|
|
111
|
+
const asked = queryOf(query);
|
|
112
|
+
const stream = await this.opened('records.tail', handle => RecordsQuery.encode({ ...asked, handle }));
|
|
113
|
+
try {
|
|
114
|
+
for (;;) {
|
|
115
|
+
const event = await stream.next();
|
|
116
|
+
stream.consumed(event.body.length);
|
|
117
|
+
if (event.end) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const batch = RecordsTailBatch.decode(event.body);
|
|
121
|
+
yield { events: (batch.events ?? []).map(eventOf), missed: batch.missed ?? 0 };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
stream.cancel();
|
|
126
|
+
}
|
|
106
127
|
}
|
|
107
|
-
const from = q?.since !== undefined
|
|
108
|
-
? nanos(new Date(Date.now() - ms(q.since)))
|
|
109
|
-
: q?.from === undefined
|
|
110
|
-
? undefined
|
|
111
|
-
: nanos(q.from);
|
|
112
|
-
return { from, to: q?.to === undefined ? undefined : nanos(q.to) };
|
|
113
128
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
minLevel: q?.minLevel === undefined ? undefined : levelOf(q.minLevel),
|
|
120
|
-
traceId: idOf(q?.traceId, 16, 'trace'),
|
|
121
|
-
attrs: fieldsOf(q?.attrs),
|
|
122
|
-
context: fieldsOf(q?.context),
|
|
123
|
-
newest: q?.newest === true ? true : undefined,
|
|
124
|
-
limit: q?.limit,
|
|
125
|
-
budgetBlocks: q?.budget?.blocks,
|
|
126
|
-
budgetBytes: q?.budget?.bytes,
|
|
127
|
-
budgetRecords: q?.budget?.records,
|
|
128
|
-
search: q?.search === '' ? undefined : q?.search,
|
|
129
|
-
};
|
|
129
|
+
/** Opens a stream of events: lazily, at its first call on a connection. */
|
|
130
|
+
export function openEvents(link, stream, options) {
|
|
131
|
+
checkName(stream, 'stream');
|
|
132
|
+
const keep = options?.keep === undefined ? undefined : ms(options.keep);
|
|
133
|
+
return new Events(link, stream, RecordsOpen.encode({ stream, keep }));
|
|
130
134
|
}
|
|
131
|
-
|
|
135
|
+
/** A stream of events: written with `append`, which waits for the file, and read back. */
|
|
136
|
+
export class Events extends Reads {
|
|
137
|
+
stream;
|
|
132
138
|
#link;
|
|
133
|
-
#
|
|
134
|
-
|
|
139
|
+
#via;
|
|
140
|
+
#open;
|
|
141
|
+
/** Events come from `store.events(stream)`. */
|
|
142
|
+
constructor(link, stream, open) {
|
|
143
|
+
super();
|
|
144
|
+
this.stream = stream;
|
|
135
145
|
this.#link = link;
|
|
146
|
+
this.#via = viaLink(link);
|
|
147
|
+
this.#open = open;
|
|
136
148
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
logger(stream, options) {
|
|
142
|
-
const logger = newLogger(lines => this.#writeLines(lines), stream, options);
|
|
143
|
-
this.#loggers.push(logger);
|
|
144
|
-
return logger;
|
|
145
|
-
}
|
|
146
|
-
/** Hands over what every logger holds, as the store does when it closes. */
|
|
147
|
-
async stop() {
|
|
148
|
-
await Promise.all(this.#loggers.map(logger => logger.stop()));
|
|
149
|
+
async append(first, fields, options) {
|
|
150
|
+
const events = typeof first === 'string' ? [oneEvent(first, fields, options)] : first;
|
|
151
|
+
const encoded = events.map(newEventOf);
|
|
152
|
+
await this.#call('records.append', handle => RecordsAppend.encode({ handle, events: encoded }), 'write');
|
|
149
153
|
}
|
|
150
|
-
/**
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
* record of no trace of its own takes the one withTrace runs the call in.
|
|
154
|
-
*/
|
|
155
|
-
async append(records) {
|
|
156
|
-
const carried = currentTrace();
|
|
157
|
-
const list = Array.isArray(records) ? records : [records];
|
|
158
|
-
return this.#write(carried === undefined
|
|
159
|
-
? list
|
|
160
|
-
: list.map(r => r.traceId === undefined
|
|
161
|
-
? { ...r, traceId: carried.traceId, spanId: carried.spanId }
|
|
162
|
-
: r));
|
|
163
|
-
}
|
|
164
|
-
async #write(records) {
|
|
165
|
-
const now = BigInt(Date.now()) * nsPerMs;
|
|
166
|
-
await this.#send(records.map(r => ({
|
|
167
|
-
at: r.at === undefined ? now : nanos(r.at),
|
|
168
|
-
stream: r.stream,
|
|
169
|
-
name: r.name,
|
|
170
|
-
level: r.level === undefined ? undefined : levelOf(r.level),
|
|
171
|
-
body: r.body,
|
|
172
|
-
traceId: idOf(r.traceId, 16, 'trace'),
|
|
173
|
-
spanId: idOf(r.spanId, 8, 'span'),
|
|
174
|
-
context: fieldsOf(r.context),
|
|
175
|
-
attrs: fieldsOf(r.attrs),
|
|
176
|
-
})));
|
|
177
|
-
}
|
|
178
|
-
/** Appends a logger's lines, their fields already JSON and their traces taken as each was logged. */
|
|
179
|
-
async #writeLines(lines) {
|
|
180
|
-
await this.#send(lines.map(line => ({
|
|
181
|
-
at: nanos(line.at),
|
|
182
|
-
stream: line.stream,
|
|
154
|
+
/** A logger's lines, each an event of this stream. */
|
|
155
|
+
appendLines(lines) {
|
|
156
|
+
const events = lines.map(line => ({
|
|
183
157
|
name: line.event ?? 'log',
|
|
158
|
+
at: nanosOf(line.at),
|
|
184
159
|
level: line.level,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
})));
|
|
191
|
-
}
|
|
192
|
-
async #send(records) {
|
|
193
|
-
await this.#link.run('write', connection => connection.session.call(methods['records.append'], RecordsBatch.encode({ records })));
|
|
160
|
+
message: line.msg,
|
|
161
|
+
fields: objectOf(line.attrs),
|
|
162
|
+
context: objectOf(line.context),
|
|
163
|
+
...wireTrace(line.traceId, line.spanId),
|
|
164
|
+
}));
|
|
165
|
+
return this.#call('records.append', handle => RecordsAppend.encode({ handle, events }), 'write').then(() => { });
|
|
194
166
|
}
|
|
195
167
|
/**
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
168
|
+
* A writer of another program's output into this stream: each line it is
|
|
169
|
+
* given becomes an event at the time it arrived, a stack trace's or a JSON
|
|
170
|
+
* value's lines one, and a write never waits.
|
|
171
|
+
*
|
|
172
|
+
* const out = store.events('worker').lines()
|
|
173
|
+
* child.stdout.on('data', chunk => out.write(chunk))
|
|
174
|
+
* child.on('close', () => out.end())
|
|
199
175
|
*/
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return {
|
|
207
|
-
}
|
|
208
|
-
const moved = (end, sent) => end !== undefined ? BigInt(end) : sent !== undefined ? BigInt(sent) : undefined;
|
|
209
|
-
return { items, next: cursorOf(moved(page.from, asked.from), moved(page.to, asked.to)) };
|
|
176
|
+
lines() {
|
|
177
|
+
return new Lines(async () => {
|
|
178
|
+
const connection = await this.#link.connection();
|
|
179
|
+
const handle = await handleOn(connection, methods['records.open'], this.#open);
|
|
180
|
+
const body = Handle.encode({ handle });
|
|
181
|
+
const stream = await streamOf(connection, methods['records.lines'], body, false);
|
|
182
|
+
return { stream, piece: pieceOf(connection) };
|
|
183
|
+
});
|
|
210
184
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
185
|
+
ask(method, body) {
|
|
186
|
+
return this.#call(method, body, 'read');
|
|
187
|
+
}
|
|
188
|
+
opened(method, body) {
|
|
189
|
+
return this.#link.run('read', async (connection) => {
|
|
190
|
+
const handle = await handleOn(connection, methods['records.open'], this.#open);
|
|
191
|
+
return streamOf(connection, methods[method], body(handle), true);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
#call(method, body, idempotence) {
|
|
195
|
+
return this.#via.call(methods['records.open'], this.#open, methods[method], body, idempotence);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/** Every stream's events, to read: `store.events()`. */
|
|
199
|
+
export class AllEvents extends Reads {
|
|
200
|
+
#link;
|
|
201
|
+
/** AllEvents come from `store.events()`. */
|
|
202
|
+
constructor(link) {
|
|
203
|
+
super();
|
|
204
|
+
this.#link = link;
|
|
205
|
+
}
|
|
206
|
+
/** Every stream with events, by name, with what it keeps, where that begins and its newest event's time. */
|
|
207
|
+
async streams() {
|
|
208
|
+
const answer = await this.ask('records.streams', () => Empty.encode({}));
|
|
209
|
+
return (RecordsStreams.decode(answer).streams ?? []).map(stream => ({
|
|
210
|
+
name: stream.name ?? '',
|
|
211
|
+
keep: spelled(stream.keep ?? 0),
|
|
212
|
+
retainedFrom: dateOf(stream.retainedFrom ?? 0n),
|
|
213
|
+
newest: dateOf(stream.newest ?? 0n),
|
|
214
|
+
}));
|
|
219
215
|
}
|
|
220
216
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
* the cursor
|
|
217
|
+
* Every event once, a batch a call, from a cursor the program keeps, the
|
|
218
|
+
* oldest event kept without one: `{ events, cursor, expired }`. With no
|
|
219
|
+
* event past the cursor, the batch is empty and its cursor the one given.
|
|
224
220
|
*/
|
|
225
|
-
async
|
|
226
|
-
const
|
|
227
|
-
const
|
|
221
|
+
async poll(cursor, options) {
|
|
222
|
+
const answer = await this.ask('records.poll', () => RecordsPollAsked.encode({ cursor, limit: options?.limit }));
|
|
223
|
+
const batch = RecordsBatch.decode(answer);
|
|
228
224
|
return {
|
|
229
|
-
|
|
230
|
-
cursor:
|
|
231
|
-
expired:
|
|
225
|
+
events: (batch.events ?? []).map(eventOf),
|
|
226
|
+
cursor: batch.cursor ?? '',
|
|
227
|
+
expired: batch.expired ?? 0,
|
|
232
228
|
};
|
|
233
229
|
}
|
|
230
|
+
ask(method, body) {
|
|
231
|
+
return this.#link.run('read', connection => connection.session.call(methods[method], body(undefined)));
|
|
232
|
+
}
|
|
234
233
|
/**
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
* fields kept. What does not fit its buffer is dropped and counted.
|
|
234
|
+
* What reads met that no longer reads, which `drop` removes: each head
|
|
235
|
+
* row and segment with its stream and its events' times. What the store
|
|
236
|
+
* has not met since it opened is not listed.
|
|
239
237
|
*/
|
|
240
|
-
lines(stream, options) {
|
|
241
|
-
if (stream === '') {
|
|
242
|
-
throw new InvalidError('lines of no stream');
|
|
243
|
-
}
|
|
244
|
-
return new LinesWriter(this.#link, stream, options?.buffer ?? 1 << 20);
|
|
245
|
-
}
|
|
246
|
-
/** The rows the server's records have met that no longer read. */
|
|
247
238
|
async damaged() {
|
|
248
|
-
const
|
|
249
|
-
return (RecordsDamages.decode(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
239
|
+
const answer = await this.ask('records.damaged', () => Empty.encode({}));
|
|
240
|
+
return (RecordsDamages.decode(answer).damages ?? []).map(damage => ({
|
|
241
|
+
part: damage.part === 'segment' ? 'segment' : 'head row',
|
|
242
|
+
id: damage.id ?? 0,
|
|
243
|
+
stream: damage.stream ?? '',
|
|
244
|
+
first: dateOf(damage.first ?? 0n),
|
|
245
|
+
last: dateOf(damage.last ?? 0n),
|
|
246
|
+
error: damage.error ?? '',
|
|
256
247
|
}));
|
|
257
248
|
}
|
|
258
|
-
/**
|
|
249
|
+
/**
|
|
250
|
+
* Removes a head row or a segment that `damaged` listed, so that the
|
|
251
|
+
* reads over it work again; what still reads is refused.
|
|
252
|
+
*
|
|
253
|
+
* for (const damage of await store.events().damaged()) await store.events().drop(damage)
|
|
254
|
+
*/
|
|
259
255
|
async drop(damage) {
|
|
260
|
-
|
|
256
|
+
const body = RecordsDamage.encode({
|
|
257
|
+
...damage,
|
|
258
|
+
first: nanosOf(damage.first),
|
|
259
|
+
last: nanosOf(damage.last),
|
|
260
|
+
});
|
|
261
|
+
await this.#link.run('write', connection => connection.session.call(methods['records.drop'], body));
|
|
262
|
+
}
|
|
263
|
+
opened(method, body) {
|
|
264
|
+
return this.#link.run('read', connection => streamOf(connection, methods[method], body(undefined), true));
|
|
261
265
|
}
|
|
262
266
|
}
|
|
263
|
-
/** The most one DATA of lines carries. */
|
|
264
|
-
const linesChunk = 64 << 10;
|
|
265
267
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
* uploads on the next connection.
|
|
268
|
+
* A writer of another program's output into a stream, as `events.lines()`
|
|
269
|
+
* begins it: each line becomes an event, and a write never waits. It sends
|
|
270
|
+
* whole lines, so that what it has no room for, `dropped` counts as lines.
|
|
270
271
|
*/
|
|
271
|
-
export class
|
|
272
|
-
|
|
273
|
-
#
|
|
274
|
-
#
|
|
275
|
-
|
|
276
|
-
#
|
|
277
|
-
|
|
278
|
-
#
|
|
272
|
+
export class Lines {
|
|
273
|
+
/** whole lines not sent yet */
|
|
274
|
+
#queued = [];
|
|
275
|
+
#queuedBytes = 0;
|
|
276
|
+
/** a line not ended yet */
|
|
277
|
+
#partial = new Uint8Array(0);
|
|
278
|
+
/** the line being written is longer than an event holds: the rest of it goes too */
|
|
279
|
+
#discarding = false;
|
|
280
|
+
#dropped = 0;
|
|
279
281
|
#ended = false;
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
this.#
|
|
282
|
+
#failure;
|
|
283
|
+
#wake;
|
|
284
|
+
#sent;
|
|
285
|
+
/** Lines come from `events.lines()`. */
|
|
286
|
+
constructor(open) {
|
|
287
|
+
this.#sent = this.#send(open).catch((err) => {
|
|
288
|
+
this.#failure = err instanceof Error ? err : new Error(String(err));
|
|
289
|
+
for (const bytes of this.#queued.splice(0)) {
|
|
290
|
+
this.#dropped += linesIn(bytes);
|
|
291
|
+
}
|
|
292
|
+
this.#queuedBytes = 0;
|
|
293
|
+
});
|
|
286
294
|
}
|
|
287
|
-
/**
|
|
295
|
+
/** The lines dropped: past what the writer holds, and, once it ended, by the store. */
|
|
296
|
+
get dropped() {
|
|
297
|
+
return this.#dropped;
|
|
298
|
+
}
|
|
299
|
+
/** Takes a piece of output, cut anywhere; it never waits. */
|
|
288
300
|
write(chunk) {
|
|
289
301
|
if (this.#ended) {
|
|
290
|
-
throw new
|
|
302
|
+
throw new ClosedError('lines written after their end');
|
|
291
303
|
}
|
|
292
|
-
|
|
293
|
-
if (
|
|
294
|
-
|
|
304
|
+
let bytes = typeof chunk === 'string' ? encoder.encode(chunk) : chunk;
|
|
305
|
+
if (this.#discarding) {
|
|
306
|
+
const end = bytes.indexOf(newline);
|
|
307
|
+
if (end < 0) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
this.#discarding = false;
|
|
311
|
+
bytes = bytes.subarray(end + 1);
|
|
295
312
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
313
|
+
const joined = concat(this.#partial, bytes);
|
|
314
|
+
const cut = joined.lastIndexOf(newline) + 1;
|
|
315
|
+
this.#partial = joined.slice(cut);
|
|
316
|
+
if (this.#partial.length > eventRoom) {
|
|
317
|
+
this.#partial = new Uint8Array(0);
|
|
318
|
+
this.#discarding = true;
|
|
319
|
+
this.#dropped++;
|
|
299
320
|
}
|
|
300
|
-
|
|
301
|
-
|
|
321
|
+
this.#queue(joined.subarray(0, cut));
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Ends the writer: what it holds goes, a last line without its newline
|
|
325
|
+
* too, and it returns once the store wrote them.
|
|
326
|
+
*/
|
|
327
|
+
async end() {
|
|
328
|
+
if (!this.#ended) {
|
|
329
|
+
this.#ended = true;
|
|
330
|
+
this.#queue(this.#partial);
|
|
331
|
+
this.#partial = new Uint8Array(0);
|
|
332
|
+
this.#wake?.();
|
|
302
333
|
}
|
|
303
|
-
this.#
|
|
304
|
-
this.#
|
|
305
|
-
this.#
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
334
|
+
await this.#sent;
|
|
335
|
+
if (this.#failure !== undefined) {
|
|
336
|
+
throw this.#failure;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/** Holds bytes for the server, or drops and counts their lines when it holds no room. */
|
|
340
|
+
#queue(bytes) {
|
|
341
|
+
if (bytes.length === 0) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (this.#failure !== undefined || this.#queuedBytes + bytes.length > linesHeld) {
|
|
345
|
+
this.#dropped += linesIn(bytes);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
this.#queued.push(bytes);
|
|
349
|
+
this.#queuedBytes += bytes.length;
|
|
350
|
+
this.#wake?.();
|
|
351
|
+
}
|
|
352
|
+
/** Sends what is held as it comes, in pieces within the stream's credit, then the end. */
|
|
353
|
+
async #send(open) {
|
|
354
|
+
const { stream, piece } = await open();
|
|
355
|
+
for (;;) {
|
|
356
|
+
const bytes = this.#queued.shift();
|
|
357
|
+
if (bytes === undefined) {
|
|
358
|
+
if (this.#ended) {
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
await new Promise(resolve => {
|
|
362
|
+
this.#wake = resolve;
|
|
363
|
+
});
|
|
364
|
+
this.#wake = undefined;
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
this.#queuedBytes -= bytes.length;
|
|
368
|
+
for (let at = 0; at < bytes.length; at += piece) {
|
|
369
|
+
await stream.send(RecordsPiece.encode({ bytes: bytes.subarray(at, at + piece) }), false);
|
|
315
370
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
371
|
+
}
|
|
372
|
+
await stream.send(new Uint8Array(0), true);
|
|
373
|
+
for (;;) {
|
|
374
|
+
const event = await stream.next();
|
|
375
|
+
if (event.end) {
|
|
376
|
+
this.#dropped += RecordsDropped.decode(event.body).dropped ?? 0;
|
|
321
377
|
return;
|
|
322
378
|
}
|
|
323
|
-
this.#waiting.shift();
|
|
324
|
-
this.#held -= piece.length;
|
|
325
379
|
}
|
|
326
380
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
381
|
+
}
|
|
382
|
+
/** A stream of the method, open once its RESPONSE came; `end` leaves the client nothing to send. */
|
|
383
|
+
async function streamOf(connection, method, body, end) {
|
|
384
|
+
const stream = await connection.session.open(method, body, end);
|
|
385
|
+
await stream.next();
|
|
386
|
+
return stream;
|
|
387
|
+
}
|
|
388
|
+
function concat(a, b) {
|
|
389
|
+
if (a.length === 0) {
|
|
390
|
+
return b;
|
|
391
|
+
}
|
|
392
|
+
const joined = new Uint8Array(a.length + b.length);
|
|
393
|
+
joined.set(a);
|
|
394
|
+
joined.set(b, a.length);
|
|
395
|
+
return joined;
|
|
396
|
+
}
|
|
397
|
+
/** The lines bytes hold: one a newline ends, and one more past the last. */
|
|
398
|
+
function linesIn(bytes) {
|
|
399
|
+
let lines = bytes[bytes.length - 1] === newline ? 0 : 1;
|
|
400
|
+
for (const byte of bytes) {
|
|
401
|
+
if (byte === newline) {
|
|
402
|
+
lines++;
|
|
330
403
|
}
|
|
331
|
-
const connection = await this.#link.connection();
|
|
332
|
-
this.#upload = await connection.session.open(methods['records.lines'], RecordsStream.encode({ stream: this.#stream }), false);
|
|
333
|
-
return this.#upload;
|
|
334
404
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
405
|
+
return lines;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* A logger of `stream` that keeps its lines there through an append of their
|
|
409
|
+
* own, and what it declares its config `log` with.
|
|
410
|
+
*/
|
|
411
|
+
export function storeLogger(link, stream, options = {}) {
|
|
412
|
+
const { keep, ...told } = options;
|
|
413
|
+
const events = openEvents(link, stream, keep === undefined ? undefined : { keep });
|
|
414
|
+
return newStoreLogger(lines => events.appendLines(lines), stream, told);
|
|
415
|
+
}
|
|
416
|
+
/** The event an append of a name, its fields and its options writes. */
|
|
417
|
+
function oneEvent(name, fields, options) {
|
|
418
|
+
return fields === undefined ? { ...options, name } : { ...options, name, fields };
|
|
419
|
+
}
|
|
420
|
+
/** An event as the wire carries it, the current trace's ids when it gives none. */
|
|
421
|
+
function newEventOf(event, place) {
|
|
422
|
+
const named = `event ${place} ${JSON.stringify(event.name)}`;
|
|
423
|
+
if (typeof event.name !== 'string' || event.name === '') {
|
|
424
|
+
throw new InvalidError(`${named}: an event has a name`);
|
|
425
|
+
}
|
|
426
|
+
if (event.at !== undefined && Number.isNaN(event.at.getTime())) {
|
|
427
|
+
throw new InvalidError(`${named}: a time that is no date`);
|
|
428
|
+
}
|
|
429
|
+
const given = event.traceId === undefined
|
|
430
|
+
? traceOf(currentTrace())
|
|
431
|
+
: { traceId: event.traceId, spanId: event.spanId };
|
|
432
|
+
return {
|
|
433
|
+
name: event.name,
|
|
434
|
+
at: event.at === undefined ? undefined : nanosOf(event.at),
|
|
435
|
+
level: event.level === undefined ? undefined : levelNumber(event.level, named),
|
|
436
|
+
message: event.message,
|
|
437
|
+
fields: event.fields === undefined ? undefined : objectOf(encodeFields(event.fields, undefined)),
|
|
438
|
+
context: event.context === undefined ? undefined : objectOf(encodeFields(event.context, undefined)),
|
|
439
|
+
...wireTrace(given.traceId, given.spanId),
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
/** A query as the wire carries it; a condition given as undefined reads nothing it was not asked. */
|
|
443
|
+
function queryOf(query) {
|
|
444
|
+
const q = query ?? {};
|
|
445
|
+
for (const [key, value] of Object.entries(q)) {
|
|
446
|
+
if (value === undefined) {
|
|
447
|
+
throw new InvalidError(`a query's ${key} given as undefined: leave it out to read without it`);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const where = q.where === undefined ? undefined : Object.entries(q.where);
|
|
451
|
+
for (const [key, value] of where ?? []) {
|
|
452
|
+
if (value === undefined) {
|
|
453
|
+
throw new InvalidError(`a query's where ${JSON.stringify(key)} given as undefined`);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return {
|
|
457
|
+
since: q.since === undefined ? undefined : ms(q.since),
|
|
458
|
+
from: q.from === undefined ? undefined : nanosOf(q.from),
|
|
459
|
+
to: q.to === undefined ? undefined : nanosOf(q.to),
|
|
460
|
+
streams: q.streams === undefined ? undefined : [...q.streams],
|
|
461
|
+
names: q.names === undefined ? undefined : [...q.names],
|
|
462
|
+
minLevel: q.minLevel === undefined ? undefined : levelNumber(q.minLevel, 'minLevel'),
|
|
463
|
+
traceId: q.traceId === undefined ? undefined : idBytes(q.traceId, 16, 'traceId'),
|
|
464
|
+
where: where === undefined
|
|
465
|
+
? undefined
|
|
466
|
+
: Object.fromEntries(where.map(([key, value]) => [key, jsonOf(value)])),
|
|
467
|
+
search: q.search,
|
|
468
|
+
newest: q.newest,
|
|
469
|
+
limit: q.limit,
|
|
470
|
+
after: q.after,
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function eventOf(read) {
|
|
474
|
+
const event = {
|
|
475
|
+
at: dateOf(read.at ?? 0n),
|
|
476
|
+
stream: read.stream ?? '',
|
|
477
|
+
name: read.name ?? '',
|
|
478
|
+
fields: read.fields === undefined ? {} : parseJson(read.fields),
|
|
479
|
+
context: read.context === undefined ? {} : parseJson(read.context),
|
|
480
|
+
};
|
|
481
|
+
if (read.level !== undefined) {
|
|
482
|
+
event.level = levelNames[Math.min(5, Math.max(0, Math.floor(read.level / 4) + 2))];
|
|
483
|
+
}
|
|
484
|
+
if (read.message !== undefined) {
|
|
485
|
+
event.message = read.message;
|
|
486
|
+
}
|
|
487
|
+
if (read.traceId !== undefined) {
|
|
488
|
+
event.traceId = Buffer.from(read.traceId).toString('hex');
|
|
489
|
+
}
|
|
490
|
+
if (read.spanId !== undefined) {
|
|
491
|
+
event.spanId = Buffer.from(read.spanId).toString('hex');
|
|
492
|
+
}
|
|
493
|
+
return event;
|
|
494
|
+
}
|
|
495
|
+
/** Key, JSON, key, JSON… as the JSON object they spell; none for no field. */
|
|
496
|
+
function objectOf(flat) {
|
|
497
|
+
if (flat.length === 0) {
|
|
498
|
+
return undefined;
|
|
499
|
+
}
|
|
500
|
+
const pairs = [];
|
|
501
|
+
for (let at = 0; at < flat.length; at += 2) {
|
|
502
|
+
pairs.push(`${JSON.stringify(flat[at])}:${flat[at + 1]}`);
|
|
503
|
+
}
|
|
504
|
+
return `{${pairs.join(',')}}`;
|
|
505
|
+
}
|
|
506
|
+
function levelNumber(level, what) {
|
|
507
|
+
if (typeof level === 'number') {
|
|
508
|
+
if (!Number.isInteger(level)) {
|
|
509
|
+
throw new InvalidError(`${what}: the level ${level}, where slog counts whole numbers`);
|
|
510
|
+
}
|
|
511
|
+
return level;
|
|
512
|
+
}
|
|
513
|
+
const number = levelNumbers[level];
|
|
514
|
+
if (number === undefined) {
|
|
515
|
+
throw new InvalidError(`${what}: the level ${JSON.stringify(level)}, not one of ${levelNames.join(', ')}`);
|
|
516
|
+
}
|
|
517
|
+
return number;
|
|
518
|
+
}
|
|
519
|
+
/** A trace's ids as hex, when the trace has both. */
|
|
520
|
+
function traceOf(trace) {
|
|
521
|
+
if (trace === undefined) {
|
|
522
|
+
return {};
|
|
523
|
+
}
|
|
524
|
+
const hex = (id) => typeof id === 'string' || id === undefined ? id : Buffer.from(id).toString('hex');
|
|
525
|
+
return { traceId: hex(trace.traceId), spanId: hex(trace.spanId) };
|
|
526
|
+
}
|
|
527
|
+
/** A trace and its span as the wire carries them: both, or neither, since the store keeps a span with its trace. */
|
|
528
|
+
function wireTrace(traceId, spanId) {
|
|
529
|
+
if (traceId === undefined || spanId === undefined) {
|
|
530
|
+
return {};
|
|
531
|
+
}
|
|
532
|
+
return { traceId: idBytes(traceId, 16, 'traceId'), spanId: idBytes(spanId, 8, 'spanId') };
|
|
533
|
+
}
|
|
534
|
+
function idBytes(hex, size, what) {
|
|
535
|
+
if (!new RegExp(`^[0-9a-fA-F]{${2 * size}}$`).test(hex)) {
|
|
536
|
+
throw new InvalidError(`${what} ${JSON.stringify(hex)}: ${2 * size} hex digits`);
|
|
537
|
+
}
|
|
538
|
+
return Uint8Array.from(Buffer.from(hex, 'hex'));
|
|
539
|
+
}
|
|
540
|
+
function nanosOf(date) {
|
|
541
|
+
return BigInt(date.getTime()) * 1000000n;
|
|
542
|
+
}
|
|
543
|
+
function dateOf(nanos) {
|
|
544
|
+
return new Date(Number(nanos / 1000000n));
|
|
545
|
+
}
|
|
546
|
+
function mapValues(map, read) {
|
|
547
|
+
return Object.fromEntries(Object.entries(map ?? {}).map(([key, value]) => [key, read(value)]));
|
|
548
|
+
}
|
|
549
|
+
/** Milliseconds as a span is written: '30d', '12h', '90s', '250ms'. */
|
|
550
|
+
function spelled(millis) {
|
|
551
|
+
for (const [unit, size] of [
|
|
552
|
+
['d', 86_400_000],
|
|
553
|
+
['h', 3_600_000],
|
|
554
|
+
['m', 60_000],
|
|
555
|
+
['s', 1000],
|
|
556
|
+
]) {
|
|
557
|
+
if (millis >= size && millis % size === 0) {
|
|
558
|
+
return `${millis / size}${unit}`;
|
|
342
559
|
}
|
|
343
|
-
await upload.send(new Uint8Array(0), true);
|
|
344
|
-
await upload.next();
|
|
345
560
|
}
|
|
561
|
+
return `${millis}ms`;
|
|
346
562
|
}
|