@dokebi/websocket-hub 0.2.0 → 0.3.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/AI.md +21 -16
- package/README.md +17 -10
- package/dist/delivery.d.ts +13 -47
- package/dist/delivery.js +19 -177
- package/dist/event-queue.d.ts +6 -0
- package/dist/event-queue.js +21 -3
- package/dist/eviction.d.ts +9 -0
- package/dist/eviction.js +57 -0
- package/dist/index.js +14 -3
- package/dist/leader.d.ts +3 -1
- package/dist/leader.js +203 -67
- package/dist/local.d.ts +7 -7
- package/dist/local.js +77 -96
- package/dist/log.d.ts +24 -0
- package/dist/log.js +101 -0
- package/dist/node.js +78 -16
- package/dist/options.d.ts +8 -5
- package/dist/options.js +13 -8
- package/dist/peer-client.d.ts +13 -4
- package/dist/peer-client.js +288 -170
- package/dist/protocol.d.ts +6 -0
- package/dist/protocol.js +6 -0
- package/dist/status-cli.js +7 -2
- package/dist/store.js +11 -6
- package/dist/types.d.ts +18 -5
- package/dist/types.js +2 -2
- package/dist/wire.d.ts +8 -1
- package/dist/wire.js +14 -3
- package/options.schema.json +8 -12
- package/package.json +3 -3
package/dist/options.js
CHANGED
|
@@ -24,6 +24,16 @@ export function integer(v, min, max) {
|
|
|
24
24
|
throw new HubError('INVALID_OPTIONS');
|
|
25
25
|
return v;
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Options of 0.2 that D-0057 removed with client ACKs. A dokebi.yaml that still has them starts:
|
|
29
|
+
* the hub logs warn `OPTION_REMOVED` once per key and ignores the value.
|
|
30
|
+
*/
|
|
31
|
+
export const REMOVED_OPTIONS = Object.freeze([
|
|
32
|
+
'deliveryTimeoutMs',
|
|
33
|
+
'retryMs',
|
|
34
|
+
'maxDeliveries',
|
|
35
|
+
'deliveryBytes',
|
|
36
|
+
]);
|
|
27
37
|
export function parseOptions(input) {
|
|
28
38
|
const v = object(input);
|
|
29
39
|
keys(v, [
|
|
@@ -48,10 +58,7 @@ export function parseOptions(input) {
|
|
|
48
58
|
'maxTotalConnections',
|
|
49
59
|
'maxPending',
|
|
50
60
|
'queueBytes',
|
|
51
|
-
|
|
52
|
-
'retryMs',
|
|
53
|
-
'maxDeliveries',
|
|
54
|
-
'deliveryBytes',
|
|
61
|
+
...REMOVED_OPTIONS,
|
|
55
62
|
]);
|
|
56
63
|
const id = (key) => {
|
|
57
64
|
const x = v[key];
|
|
@@ -113,10 +120,8 @@ export function parseOptions(input) {
|
|
|
113
120
|
maxOwners: num('maxOwners', 64, 1, 1024),
|
|
114
121
|
maxTotalConnections: num('maxTotalConnections', 8192, 1, 100000),
|
|
115
122
|
maxPending: num('maxPending', 128, 1, 4096),
|
|
116
|
-
deliveryTimeoutMs: num('deliveryTimeoutMs', 60000, 1000, 120000),
|
|
117
|
-
retryMs: num('retryMs', 1000, 100, 5000),
|
|
118
|
-
maxDeliveries: num('maxDeliveries', 10000, 1, 100000),
|
|
119
|
-
deliveryBytes: num('deliveryBytes', 67108864, 16384, 268435456),
|
|
120
123
|
queueBytes: num('queueBytes', 4194304, maxFrameBytes, 67108864),
|
|
124
|
+
// Not validated: the value is ignored whatever it is.
|
|
125
|
+
removedOptions: Object.freeze(REMOVED_OPTIONS.filter((key) => v[key] !== undefined)),
|
|
121
126
|
};
|
|
122
127
|
}
|
package/dist/peer-client.d.ts
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
|
+
import { type Logger } from '@dokebi/core';
|
|
1
2
|
import { EventQueue } from './event-queue.js';
|
|
2
3
|
import type { HubOptions } from './options.js';
|
|
3
|
-
import { type HubConnection, type HubLeader, type HubQuery, type HubReceipt, type HubRecord, type HubRegistration, type HubSnapshot } from './types.js';
|
|
4
|
+
import { type HubConnection, type HubKickReceipt, type HubLeader, type HubQuery, type HubReceipt, type HubRecord, type HubRegistration, type HubSnapshot } from './types.js';
|
|
4
5
|
export declare class PeerClient {
|
|
5
6
|
#private;
|
|
6
7
|
readonly options: HubOptions;
|
|
8
|
+
/** The hub node passes the plugin logger; the console default keeps failures visible. */
|
|
9
|
+
readonly logger: Logger;
|
|
7
10
|
readonly ownerEpoch: `${string}-${string}-${string}-${string}-${string}`;
|
|
8
11
|
/** Session of the last hello; the owner record in Redis carries the same value. */
|
|
9
12
|
get session(): string | undefined;
|
|
10
13
|
readonly events: EventQueue;
|
|
11
|
-
constructor(options: HubOptions,
|
|
14
|
+
constructor(options: HubOptions,
|
|
15
|
+
/** The hub node passes the plugin logger; the console default keeps failures visible. */
|
|
16
|
+
logger?: Logger);
|
|
12
17
|
get ready(): boolean;
|
|
13
18
|
get leader(): HubLeader | undefined;
|
|
14
19
|
get connections(): Map<string, HubRecord>;
|
|
15
20
|
connect(leader: HubLeader): Promise<void>;
|
|
16
21
|
register(input: HubRegistration): Promise<HubConnection>;
|
|
17
22
|
list(input: HubQuery): Promise<HubSnapshot>;
|
|
23
|
+
/**
|
|
24
|
+
* One request to the leader, answered once the leader has written the message frames
|
|
25
|
+
* (D-0057). Never resent: not connected is RECOVERING at once, a drop after sending is
|
|
26
|
+
* OUTCOME_UNKNOWN, and the caller decides whether to send again.
|
|
27
|
+
*/
|
|
18
28
|
broadcast(input: HubQuery, data: Uint8Array): Promise<HubReceipt>;
|
|
19
|
-
|
|
20
|
-
kick(input: HubQuery, code?: number, reason?: string): Promise<HubReceipt>;
|
|
29
|
+
kick(input: HubQuery, code?: number, reason?: string): Promise<HubKickReceipt>;
|
|
21
30
|
close(): Promise<void>;
|
|
22
31
|
disconnect(): void;
|
|
23
32
|
whenReady(timeoutMs: number): Promise<boolean>;
|