@isoloop/bus 0.1.0-next.7 → 0.1.0-next.9
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/bus-worker.js +35 -9
- package/dist/index.d.ts +60 -10
- package/dist/index.js +35 -7
- package/dist/{standard-schema-DnJtEmJw.js → standard-schema-BtwRaC9-.js} +2 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/{topic-BgqMD0WA.d.ts → topic-CGu03SkJ.d.ts} +19 -5
- package/package.json +3 -3
package/dist/bus-worker.js
CHANGED
|
@@ -707,6 +707,8 @@ function bigint(v) {
|
|
|
707
707
|
* §6.1). Strings count two bytes per UTF-16 unit, numbers eight, object keys
|
|
708
708
|
* like strings, plus a little per entry. Cycles count once. Cheap rather than
|
|
709
709
|
* exact: it only has to tell a 1 KiB record from a 1 MiB one.
|
|
710
|
+
*
|
|
711
|
+
* @internal
|
|
710
712
|
*/
|
|
711
713
|
function estimateSize(value, limit = Infinity) {
|
|
712
714
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -891,6 +893,8 @@ const segmentKey = (s) => typeof s === "object" ? s.key : s;
|
|
|
891
893
|
/**
|
|
892
894
|
* Maps schema issues to the cloneable `{ message, path }[]` sent with `invalid`
|
|
893
895
|
* (ADR 0003, decision 10). Symbol keys become their description.
|
|
896
|
+
*
|
|
897
|
+
* @internal
|
|
894
898
|
*/
|
|
895
899
|
function toIssues(issues) {
|
|
896
900
|
return issues.map((i) => ({
|
|
@@ -902,11 +906,19 @@ function toIssues(issues) {
|
|
|
902
906
|
}));
|
|
903
907
|
}
|
|
904
908
|
const isRecord = (x) => typeof x === "object" && x !== null;
|
|
905
|
-
/**
|
|
909
|
+
/**
|
|
910
|
+
* True for a value built by `contracts()`, from any copy of this package.
|
|
911
|
+
*
|
|
912
|
+
* @internal
|
|
913
|
+
*/
|
|
906
914
|
function isContracts(x) {
|
|
907
915
|
return isRecord(x) && x["~isoloop"] === "contracts";
|
|
908
916
|
}
|
|
909
|
-
/**
|
|
917
|
+
/**
|
|
918
|
+
* The structured-cloneable part of a topic, sent at `boot` for the contracts check (ADR 0003, decision 5).
|
|
919
|
+
*
|
|
920
|
+
* @internal
|
|
921
|
+
*/
|
|
910
922
|
function topicConfig(t) {
|
|
911
923
|
return topicConfigOf(t);
|
|
912
924
|
}
|
|
@@ -934,7 +946,11 @@ function hash(s) {
|
|
|
934
946
|
return h >>> 0;
|
|
935
947
|
}
|
|
936
948
|
const reqKey = (topic, offset) => `${topic}\u0000${offset}`;
|
|
937
|
-
/**
|
|
949
|
+
/**
|
|
950
|
+
* A message's `(epoch, seq)`, when it carries both as numbers.
|
|
951
|
+
*
|
|
952
|
+
* @internal
|
|
953
|
+
*/
|
|
938
954
|
function publishId(p) {
|
|
939
955
|
const { epoch, seq } = p;
|
|
940
956
|
return typeof epoch === "number" && typeof seq === "number" ? {
|
|
@@ -953,6 +969,8 @@ const DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
|
953
969
|
* and consumer groups, delivers from the log under credit, and routes
|
|
954
970
|
* request replies. Knows nothing about workers; the bus worker entry wires
|
|
955
971
|
* ports to it.
|
|
972
|
+
*
|
|
973
|
+
* @internal
|
|
956
974
|
*/
|
|
957
975
|
var Broker = class {
|
|
958
976
|
#engine;
|
|
@@ -2112,7 +2130,11 @@ function validate(schema, value) {
|
|
|
2112
2130
|
return r.then((x) => x, (thrown) => ({ thrown }));
|
|
2113
2131
|
}
|
|
2114
2132
|
// src/engine/memory-storage.ts
|
|
2115
|
-
/**
|
|
2133
|
+
/**
|
|
2134
|
+
* Storage that keeps nothing. Every topic behaves as `memory`.
|
|
2135
|
+
*
|
|
2136
|
+
* @internal
|
|
2137
|
+
*/
|
|
2116
2138
|
var MemoryStorage = class {
|
|
2117
2139
|
kind = "memory";
|
|
2118
2140
|
open() {
|
|
@@ -2147,7 +2169,9 @@ var MemoryStorage = class {
|
|
|
2147
2169
|
* Engines call this from `createTopic`: the durability a topic actually gets.
|
|
2148
2170
|
* A `persistent` topic on storage that keeps nothing (no OPFS, or another tab
|
|
2149
2171
|
* holds it) behaves as `memory`; the kernel reports that as
|
|
2150
|
-
* `bus:
|
|
2172
|
+
* `bus:durability_degraded` (ADR 0007, decision 6).
|
|
2173
|
+
*
|
|
2174
|
+
* @internal
|
|
2151
2175
|
*/
|
|
2152
2176
|
function effectiveDurability(cfg, storage) {
|
|
2153
2177
|
if (cfg.durability !== "persistent") return "memory";
|
|
@@ -2266,6 +2290,8 @@ const DIRTY_MIN = 1024;
|
|
|
2266
2290
|
* The TypeScript `LogEngine` (design §6.2). Each topic is an array of
|
|
2267
2291
|
* fixed-size chunks, so dropping old records frees a whole chunk at a time:
|
|
2268
2292
|
* O(1) per chunk. Compacted topics keep a key → latest-offset index.
|
|
2293
|
+
*
|
|
2294
|
+
* @internal
|
|
2269
2295
|
*/
|
|
2270
2296
|
var TsEngine = class {
|
|
2271
2297
|
name = "ts";
|
|
@@ -4093,11 +4119,11 @@ function serve(scope, opts = {}) {
|
|
|
4093
4119
|
else if (!persistent) storage = new MemoryStorage();
|
|
4094
4120
|
else if (!OpfsStorage.available()) {
|
|
4095
4121
|
storage = new MemoryStorage();
|
|
4096
|
-
degraded = "
|
|
4122
|
+
degraded = "no_sync_access";
|
|
4097
4123
|
} else if (await takeBusLock(p.restart ? RESTART_LOCK_WAIT_MS : 0)) storage = new OpfsStorage();
|
|
4098
4124
|
else {
|
|
4099
4125
|
storage = new MemoryStorage();
|
|
4100
|
-
degraded = "
|
|
4126
|
+
degraded = "another_tab";
|
|
4101
4127
|
}
|
|
4102
4128
|
let quarantined;
|
|
4103
4129
|
let stored;
|
|
@@ -4108,7 +4134,7 @@ function serve(scope, opts = {}) {
|
|
|
4108
4134
|
console.warn("[isoloop] persistent topics are in memory: storage failed to open", e);
|
|
4109
4135
|
storage = new MemoryStorage();
|
|
4110
4136
|
stored = await storage.open();
|
|
4111
|
-
degraded = "
|
|
4137
|
+
degraded = "open_failed";
|
|
4112
4138
|
}
|
|
4113
4139
|
let built;
|
|
4114
4140
|
try {
|
|
@@ -4129,7 +4155,7 @@ function serve(scope, opts = {}) {
|
|
|
4129
4155
|
console.warn("[isoloop] persistent topics are in memory: reading them back failed", e);
|
|
4130
4156
|
storage = new MemoryStorage();
|
|
4131
4157
|
built = await build(list, storage, await storage.open(), dev);
|
|
4132
|
-
degraded = "
|
|
4158
|
+
degraded = "open_failed";
|
|
4133
4159
|
}
|
|
4134
4160
|
const { b, restored } = built;
|
|
4135
4161
|
broker = b;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { _ as unchecked, a as InputOf, c as ReplyOutputOf, d as TopicDef, f as contracts, g as topicConfig, h as topic, i as DEFAULT_MAX_RECORD_BYTES, l as Retention, m as isUnchecked, n as Contracts, o as OutputOf, p as isContracts, r as ContractsError, s as ReplyInputOf, t as AnyTopicDef, u as ToolSpec, v as StandardSchemaV1, y as toIssues } from "./topic-
|
|
1
|
+
import { _ as unchecked, a as InputOf, c as ReplyOutputOf, d as TopicDef, f as contracts, g as topicConfig, h as topic, i as DEFAULT_MAX_RECORD_BYTES, l as Retention, m as isUnchecked, n as Contracts, o as OutputOf, p as isContracts, r as ContractsError, s as ReplyInputOf, t as AnyTopicDef, u as ToolSpec, v as StandardSchemaV1, y as toIssues } from "./topic-CGu03SkJ.js";
|
|
2
2
|
import { BusRecord, BusToIsolate, CallError, CallResult, ErrorCode, Grants, JSON_SCHEMA_TARGET, JsonSchema, JsonSchemaPair, JsonSchemaResult, NotExportableReason, RequestVia, SeedEvent, StandardJSONSchemaV1, TopicConfig, TopicJsonSchemas, TopicJsonSchemasResult, hasJsonSchema, jsonSchemaOf, topicJsonSchemas } from "@isoloop/protocol";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* A record before the engine gives it an offset.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
4
8
|
type NewRecord = Omit<BusRecord, "offset">;
|
|
5
9
|
/** A publish's instance and counter, for deduplicating re-sends (ADR 0007, step 5). */
|
|
6
10
|
type AppendId = {
|
|
@@ -15,6 +19,8 @@ type AppendId = {
|
|
|
15
19
|
* Retention: `last-n` is applied on append; `time` and `compacted` on
|
|
16
20
|
* `compact()`, which the broker calls on a timer. An engine may also compact
|
|
17
21
|
* a `compacted` topic on its own once enough records are superseded.
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
18
24
|
*/
|
|
19
25
|
interface LogEngine {
|
|
20
26
|
/** Throws if the topic exists. */
|
|
@@ -74,14 +80,22 @@ interface LogEngine {
|
|
|
74
80
|
/** Pages evicted records from `fromOffset` back in from disk, so `read` sees them. */
|
|
75
81
|
page(topic: string, fromOffset: number): Promise<void>;
|
|
76
82
|
}
|
|
77
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Options every engine takes.
|
|
85
|
+
*
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
78
88
|
type EngineOptions = {
|
|
79
89
|
/** Clock for `time` retention. Default `Date.now`. */
|
|
80
90
|
now?: () => number;
|
|
81
91
|
/** Default `MemoryStorage`. */
|
|
82
92
|
storage?: LogStorage;
|
|
83
93
|
};
|
|
84
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* What a storage found on open: per topic, the offsets it holds; per topic and consumer, commits.
|
|
96
|
+
*
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
85
99
|
type StoredState = {
|
|
86
100
|
topics: {
|
|
87
101
|
topic: string;
|
|
@@ -94,6 +108,8 @@ type StoredState = {
|
|
|
94
108
|
* Durable storage under the engine, for `durability: 'persistent'` topics
|
|
95
109
|
* (design §6.2, ADR 0007). M2 ships `MemoryStorage`, which keeps nothing;
|
|
96
110
|
* M2b adds `OpfsStorage`.
|
|
111
|
+
*
|
|
112
|
+
* @internal
|
|
97
113
|
*/
|
|
98
114
|
interface LogStorage {
|
|
99
115
|
/** `memory` keeps nothing; reported in the bus `ready` message. */
|
|
@@ -128,7 +144,11 @@ interface LogStorage {
|
|
|
128
144
|
/** Safe mode: moves the newest segments aside and returns their names. */
|
|
129
145
|
quarantineNewest(): Promise<string[]>;
|
|
130
146
|
}
|
|
131
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* Storage that keeps nothing. Every topic behaves as `memory`.
|
|
149
|
+
*
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
132
152
|
export declare class MemoryStorage implements LogStorage {
|
|
133
153
|
readonly kind: "memory";
|
|
134
154
|
open(): Promise<StoredState>;
|
|
@@ -146,9 +166,12 @@ export declare class MemoryStorage implements LogStorage {
|
|
|
146
166
|
* Engines call this from `createTopic`: the durability a topic actually gets.
|
|
147
167
|
* A `persistent` topic on storage that keeps nothing (no OPFS, or another tab
|
|
148
168
|
* holds it) behaves as `memory`; the kernel reports that as
|
|
149
|
-
* `bus:
|
|
169
|
+
* `bus:durability_degraded` (ADR 0007, decision 6).
|
|
170
|
+
*
|
|
171
|
+
* @internal
|
|
150
172
|
*/
|
|
151
173
|
export declare function effectiveDurability(cfg: TopicConfig, storage: LogStorage): "memory" | "persistent";
|
|
174
|
+
/** @internal */
|
|
152
175
|
type TsEngineOptions = EngineOptions & {
|
|
153
176
|
/** Records per chunk. Default 4,096; tests use small chunks to cross boundaries often. */
|
|
154
177
|
chunkSize?: number;
|
|
@@ -165,6 +188,8 @@ type TsEngineOptions = EngineOptions & {
|
|
|
165
188
|
* The TypeScript `LogEngine` (design §6.2). Each topic is an array of
|
|
166
189
|
* fixed-size chunks, so dropping old records frees a whole chunk at a time:
|
|
167
190
|
* O(1) per chunk. Compacted topics keep a key → latest-offset index.
|
|
191
|
+
*
|
|
192
|
+
* @internal
|
|
168
193
|
*/
|
|
169
194
|
export declare class TsEngine implements LogEngine {
|
|
170
195
|
#private;
|
|
@@ -207,6 +232,8 @@ export declare class TsEngine implements LogEngine {
|
|
|
207
232
|
/**
|
|
208
233
|
* One isolate's bus connection, as the broker sees it. The bus worker wraps a
|
|
209
234
|
* `MessagePort`; tests use in-memory ports.
|
|
235
|
+
*
|
|
236
|
+
* @internal
|
|
210
237
|
*/
|
|
211
238
|
export interface BusPort {
|
|
212
239
|
post(msg: BusToIsolate): void;
|
|
@@ -214,10 +241,15 @@ export interface BusPort {
|
|
|
214
241
|
onMessage(handler: (msg: unknown) => void): void;
|
|
215
242
|
close(): void;
|
|
216
243
|
}
|
|
217
|
-
/**
|
|
244
|
+
/**
|
|
245
|
+
* Timer functions, injectable for tests.
|
|
246
|
+
*
|
|
247
|
+
* @internal
|
|
248
|
+
*/
|
|
218
249
|
export type Timers = {
|
|
219
250
|
set(fn: () => void, ms: number): void;
|
|
220
251
|
};
|
|
252
|
+
/** @internal */
|
|
221
253
|
export type BrokerOptions = {
|
|
222
254
|
contracts: Contracts;
|
|
223
255
|
engine: LogEngine;
|
|
@@ -256,9 +288,15 @@ export type BrokerOptions = {
|
|
|
256
288
|
/**
|
|
257
289
|
* Gets each record appended to a tapped topic (ADR 0020, decision 3), with
|
|
258
290
|
* its estimated size. A tap is not a consumer: it has no cursor or credit.
|
|
291
|
+
*
|
|
292
|
+
* @internal
|
|
259
293
|
*/
|
|
260
294
|
export type TapSink = (topic: string, rec: BusRecord, bytes: number) => void;
|
|
261
|
-
/**
|
|
295
|
+
/**
|
|
296
|
+
* Who is publishing: an isolate (grants apply), the host (`kernel.publish`), or the kernel itself (system topics).
|
|
297
|
+
*
|
|
298
|
+
* @internal
|
|
299
|
+
*/
|
|
262
300
|
export type Publisher = {
|
|
263
301
|
kind: "isolate";
|
|
264
302
|
isolateId: string;
|
|
@@ -267,7 +305,11 @@ export type Publisher = {
|
|
|
267
305
|
} | {
|
|
268
306
|
kind: "kernel";
|
|
269
307
|
};
|
|
270
|
-
/**
|
|
308
|
+
/**
|
|
309
|
+
* Cumulative counters for metrics (design §6.3); the bus worker turns them into rates.
|
|
310
|
+
*
|
|
311
|
+
* @internal
|
|
312
|
+
*/
|
|
271
313
|
export type BrokerStats = {
|
|
272
314
|
/** `head` and `retained` are the engine's, at the time of the sample (ADR 0020, decision 2). */
|
|
273
315
|
topics: {
|
|
@@ -287,7 +329,11 @@ export type BrokerStats = {
|
|
|
287
329
|
/** Rejected publishes and requests, by error code. */
|
|
288
330
|
rejected: Partial<Record<ErrorCode, number>>;
|
|
289
331
|
};
|
|
290
|
-
/**
|
|
332
|
+
/**
|
|
333
|
+
* A message's `(epoch, seq)`, when it carries both as numbers.
|
|
334
|
+
*
|
|
335
|
+
* @internal
|
|
336
|
+
*/
|
|
291
337
|
export declare function publishId(p: {
|
|
292
338
|
epoch?: unknown;
|
|
293
339
|
seq?: unknown;
|
|
@@ -303,6 +349,8 @@ export declare const DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
|
303
349
|
* and consumer groups, delivers from the log under credit, and routes
|
|
304
350
|
* request replies. Knows nothing about workers; the bus worker entry wires
|
|
305
351
|
* ports to it.
|
|
352
|
+
*
|
|
353
|
+
* @internal
|
|
306
354
|
*/
|
|
307
355
|
export declare class Broker {
|
|
308
356
|
#private;
|
|
@@ -398,6 +446,8 @@ export declare class Broker {
|
|
|
398
446
|
* §6.1). Strings count two bytes per UTF-16 unit, numbers eight, object keys
|
|
399
447
|
* like strings, plus a little per entry. Cycles count once. Cheap rather than
|
|
400
448
|
* exact: it only has to tell a 1 KiB record from a 1 MiB one.
|
|
449
|
+
*
|
|
450
|
+
* @internal
|
|
401
451
|
*/
|
|
402
452
|
export declare function estimateSize(value: unknown, limit?: number): number;
|
|
403
453
|
export { AnyTopicDef, Contracts, ContractsError, DEFAULT_MAX_RECORD_BYTES, type EngineOptions, InputOf, JSON_SCHEMA_TARGET, type JsonSchema, type JsonSchemaPair, type JsonSchemaResult, type LogEngine, type LogStorage, type NewRecord, type NotExportableReason, OutputOf, ReplyInputOf, ReplyOutputOf, type Retention, type StandardJSONSchemaV1, StandardSchemaV1, type StoredState, type ToolSpec, TopicDef, type TopicJsonSchemas, type TopicJsonSchemasResult, type TsEngineOptions, contracts, hasJsonSchema, isContracts, isUnchecked, jsonSchemaOf, toIssues, topic, topicConfig, topicJsonSchemas, unchecked };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as toIssues } from "./standard-schema-
|
|
1
|
+
import { t as toIssues } from "./standard-schema-BtwRaC9-.js";
|
|
2
2
|
import { JSON_SCHEMA_TARGET, SYSTEM_TOPICS, UNCHECKED_VENDOR, hasJsonSchema, isIsolateToBus, isRequestVia, isSystemTopic, jsonSchemaOf, matchAny, topicConfigOf, topicJsonSchemas } from "@isoloop/protocol";
|
|
3
3
|
import { CodecError, decode, encode } from "@isoloop/codec";
|
|
4
4
|
// src/topic.ts
|
|
@@ -22,7 +22,11 @@ function unchecked() {
|
|
|
22
22
|
validate: (value) => ({ value })
|
|
23
23
|
} };
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* True if the schema came from `unchecked()`.
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
26
30
|
function isUnchecked(schema) {
|
|
27
31
|
return schema["~standard"].vendor === UNCHECKED_VENDOR;
|
|
28
32
|
}
|
|
@@ -118,16 +122,28 @@ function seedCycle(byName) {
|
|
|
118
122
|
}
|
|
119
123
|
}
|
|
120
124
|
}
|
|
121
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* True for a value built by `contracts()`, from any copy of this package.
|
|
127
|
+
*
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
122
130
|
function isContracts(x) {
|
|
123
131
|
return isRecord(x) && x["~isoloop"] === "contracts";
|
|
124
132
|
}
|
|
125
|
-
/**
|
|
133
|
+
/**
|
|
134
|
+
* The structured-cloneable part of a topic, sent at `boot` for the contracts check (ADR 0003, decision 5).
|
|
135
|
+
*
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
126
138
|
function topicConfig(t) {
|
|
127
139
|
return topicConfigOf(t);
|
|
128
140
|
}
|
|
129
141
|
// src/engine/memory-storage.ts
|
|
130
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* Storage that keeps nothing. Every topic behaves as `memory`.
|
|
144
|
+
*
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
131
147
|
var MemoryStorage = class {
|
|
132
148
|
kind = "memory";
|
|
133
149
|
open() {
|
|
@@ -162,7 +178,9 @@ var MemoryStorage = class {
|
|
|
162
178
|
* Engines call this from `createTopic`: the durability a topic actually gets.
|
|
163
179
|
* A `persistent` topic on storage that keeps nothing (no OPFS, or another tab
|
|
164
180
|
* holds it) behaves as `memory`; the kernel reports that as
|
|
165
|
-
* `bus:
|
|
181
|
+
* `bus:durability_degraded` (ADR 0007, decision 6).
|
|
182
|
+
*
|
|
183
|
+
* @internal
|
|
166
184
|
*/
|
|
167
185
|
function effectiveDurability(cfg, storage) {
|
|
168
186
|
if (cfg.durability !== "persistent") return "memory";
|
|
@@ -263,6 +281,8 @@ const DIRTY_MIN = 1024;
|
|
|
263
281
|
* The TypeScript `LogEngine` (design §6.2). Each topic is an array of
|
|
264
282
|
* fixed-size chunks, so dropping old records frees a whole chunk at a time:
|
|
265
283
|
* O(1) per chunk. Compacted topics keep a key → latest-offset index.
|
|
284
|
+
*
|
|
285
|
+
* @internal
|
|
266
286
|
*/
|
|
267
287
|
var TsEngine = class {
|
|
268
288
|
name = "ts";
|
|
@@ -730,6 +750,8 @@ function remember(t, producer, id, offset) {
|
|
|
730
750
|
* §6.1). Strings count two bytes per UTF-16 unit, numbers eight, object keys
|
|
731
751
|
* like strings, plus a little per entry. Cycles count once. Cheap rather than
|
|
732
752
|
* exact: it only has to tell a 1 KiB record from a 1 MiB one.
|
|
753
|
+
*
|
|
754
|
+
* @internal
|
|
733
755
|
*/
|
|
734
756
|
function estimateSize(value, limit = Infinity) {
|
|
735
757
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -933,7 +955,11 @@ function hash(s) {
|
|
|
933
955
|
return h >>> 0;
|
|
934
956
|
}
|
|
935
957
|
const reqKey = (topic, offset) => `${topic}\u0000${offset}`;
|
|
936
|
-
/**
|
|
958
|
+
/**
|
|
959
|
+
* A message's `(epoch, seq)`, when it carries both as numbers.
|
|
960
|
+
*
|
|
961
|
+
* @internal
|
|
962
|
+
*/
|
|
937
963
|
function publishId(p) {
|
|
938
964
|
const { epoch, seq } = p;
|
|
939
965
|
return typeof epoch === "number" && typeof seq === "number" ? {
|
|
@@ -952,6 +978,8 @@ const DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
|
952
978
|
* and consumer groups, delivers from the log under credit, and routes
|
|
953
979
|
* request replies. Knows nothing about workers; the bus worker entry wires
|
|
954
980
|
* ports to it.
|
|
981
|
+
*
|
|
982
|
+
* @internal
|
|
955
983
|
*/
|
|
956
984
|
var Broker = class {
|
|
957
985
|
#engine;
|
|
@@ -3,6 +3,8 @@ const segmentKey = (s) => typeof s === "object" ? s.key : s;
|
|
|
3
3
|
/**
|
|
4
4
|
* Maps schema issues to the cloneable `{ message, path }[]` sent with `invalid`
|
|
5
5
|
* (ADR 0003, decision 10). Symbol keys become their description.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
6
8
|
*/
|
|
7
9
|
function toIssues(issues) {
|
|
8
10
|
return issues.map((i) => ({
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as Contracts } from "./topic-
|
|
1
|
+
import { n as Contracts } from "./topic-CGu03SkJ.js";
|
|
2
2
|
import { Issue } from "@isoloop/protocol";
|
|
3
3
|
/** Sample values for one topic. An array is shorthand for `{ values }`. */
|
|
4
4
|
export type TopicSamples = readonly unknown[] | {
|
package/dist/testing.js
CHANGED
|
@@ -39,6 +39,8 @@ declare namespace StandardSchemaV1 {
|
|
|
39
39
|
/**
|
|
40
40
|
* Maps schema issues to the cloneable `{ message, path }[]` sent with `invalid`
|
|
41
41
|
* (ADR 0003, decision 10). Symbol keys become their description.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
42
44
|
*/
|
|
43
45
|
declare function toIssues(issues: ReadonlyArray<StandardSchemaV1.Issue>): Issue$1[];
|
|
44
46
|
/** Default `maxRecordBytes`: 256 KiB (design §6.1). */
|
|
@@ -54,7 +56,7 @@ type TopicDef<In, Out = In, RIn = never, ROut = RIn> = {
|
|
|
54
56
|
readonly name: string;
|
|
55
57
|
/** Required. `unchecked<T>()` is the explicit opt-out. */
|
|
56
58
|
readonly schema: StandardSchemaV1<In, Out>;
|
|
57
|
-
/** Required for `bus.request`. */
|
|
59
|
+
/** Required for `bus.request`. @experimental */
|
|
58
60
|
readonly reply?: StandardSchemaV1<RIn, ROut>;
|
|
59
61
|
readonly retention: Retention$1;
|
|
60
62
|
/** Rough structured size limit per record. Default 256 KiB. */
|
|
@@ -63,7 +65,7 @@ type TopicDef<In, Out = In, RIn = never, ROut = RIn> = {
|
|
|
63
65
|
* Default `memory`. `persistent` keeps the topic in OPFS (ADR 0007): it
|
|
64
66
|
* survives a bus crash and a reload. Where OPFS isn't available, or another
|
|
65
67
|
* tab holds it, it behaves as `memory` and the kernel emits
|
|
66
|
-
* `bus:
|
|
68
|
+
* `bus:durability_degraded`.
|
|
67
69
|
*/
|
|
68
70
|
readonly durability?: "memory" | "persistent";
|
|
69
71
|
/**
|
|
@@ -103,7 +105,11 @@ declare function topic<In, Out = In, RIn = never, ROut = RIn>(name: string, def:
|
|
|
103
105
|
* (ADR 0003, decision 2). Tools list topics that use it.
|
|
104
106
|
*/
|
|
105
107
|
declare function unchecked<T>(): StandardSchemaV1<T, T>;
|
|
106
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* True if the schema came from `unchecked()`.
|
|
110
|
+
*
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
107
113
|
declare function isUnchecked(schema: StandardSchemaV1): boolean;
|
|
108
114
|
/**
|
|
109
115
|
* The default export of a contracts module (ADR 0003, decision 4). Built only
|
|
@@ -128,8 +134,16 @@ declare class ContractsError extends Error {
|
|
|
128
134
|
* which belong to the kernel (ADR 0003, decisions 4 and 6).
|
|
129
135
|
*/
|
|
130
136
|
declare function contracts(...topics: AnyTopicDef[]): Contracts;
|
|
131
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* True for a value built by `contracts()`, from any copy of this package.
|
|
139
|
+
*
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
132
142
|
declare function isContracts(x: unknown): x is Contracts;
|
|
133
|
-
/**
|
|
143
|
+
/**
|
|
144
|
+
* The structured-cloneable part of a topic, sent at `boot` for the contracts check (ADR 0003, decision 5).
|
|
145
|
+
*
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
134
148
|
declare function topicConfig(t: AnyTopicDef): TopicConfig;
|
|
135
149
|
export { unchecked as _, InputOf as a, ReplyOutputOf as c, TopicDef as d, contracts as f, topicConfig as g, topic as h, DEFAULT_MAX_RECORD_BYTES as i, Retention as l, isUnchecked as m, Contracts as n, OutputOf as o, isContracts as p, ContractsError as r, ReplyInputOf as s, AnyTopicDef as t, ToolSpec as u, StandardSchemaV1 as v, toIssues as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isoloop/bus",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.9",
|
|
4
4
|
"description": "Log bus that runs in its own worker: topics, schemas, offsets, replay.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@isoloop/codec": "0.1.0-next.
|
|
31
|
-
"@isoloop/protocol": "0.1.0-next.
|
|
30
|
+
"@isoloop/codec": "0.1.0-next.9",
|
|
31
|
+
"@isoloop/protocol": "0.1.0-next.9"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"fast-check": "4.10.2",
|