@dokebi/websocket-hub 0.2.0 → 0.4.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 +96 -49
- package/README.md +71 -43
- package/dist/delivery.d.ts +13 -47
- package/dist/delivery.js +19 -177
- package/dist/dependency.d.ts +4 -0
- package/dist/dependency.js +14 -0
- 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/hub-index.d.ts +29 -0
- package/dist/hub-index.js +146 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +25 -18
- package/dist/leader.d.ts +3 -1
- package/dist/leader.js +215 -76
- package/dist/local.d.ts +11 -7
- package/dist/local.js +94 -107
- package/dist/node.d.ts +2 -2
- package/dist/node.js +83 -21
- package/dist/options.d.ts +32 -34
- package/dist/options.js +115 -120
- package/dist/peer-client.d.ts +13 -4
- package/dist/peer-client.js +290 -172
- package/dist/protocol.d.ts +6 -0
- package/dist/protocol.js +7 -1
- package/dist/status-cli.js +7 -2
- package/dist/store.js +12 -7
- package/dist/types.d.ts +25 -8
- package/dist/types.js +22 -5
- package/dist/values.d.ts +4 -0
- package/dist/values.js +32 -0
- package/dist/wire.d.ts +8 -1
- package/dist/wire.js +14 -3
- package/options.schema.json +113 -36
- package/package.json +35 -11
package/dist/protocol.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { types } from 'node:util';
|
|
2
|
-
import { integer, keys, object } from './options.js';
|
|
3
2
|
import { HubError } from './types.js';
|
|
3
|
+
import { integer, keys, object } from './values.js';
|
|
4
|
+
/**
|
|
5
|
+
* Version of the frames hub servers exchange, sent in hello (D-0057). 2: broadcasts without
|
|
6
|
+
* client ACKs (no `accepted`, `ack` or resend). A leader refuses another version with
|
|
7
|
+
* PROTOCOL_MISMATCH; a 0.2 leader answers without it and is refused by the peer.
|
|
8
|
+
*/
|
|
9
|
+
export const PROTOCOL = 2;
|
|
4
10
|
const decoder = new TextDecoder('utf-8', { fatal: true });
|
|
5
11
|
export function encode(value, limit) {
|
|
6
12
|
try {
|
package/dist/status-cli.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { resolve } from 'node:path';
|
|
6
6
|
import { parseArgs } from 'node:util';
|
|
7
7
|
import { Application, ConsoleLogger, loadConfig } from '@dokebi/core';
|
|
8
|
+
import { diagnostics } from '@dokebi/core/libraries';
|
|
8
9
|
import { createPlugin as createRedis } from '@dokebi/redis';
|
|
9
10
|
import { parseOptions } from './options.js';
|
|
10
11
|
import { hubStatus } from './status.js';
|
|
@@ -71,11 +72,15 @@ async function main() {
|
|
|
71
72
|
await app.start();
|
|
72
73
|
lease = await new HubStore(app.get(redis).connection(options.redisConnection), options).inspect();
|
|
73
74
|
}
|
|
74
|
-
catch {
|
|
75
|
+
catch (error) {
|
|
76
|
+
// Reported as `unreachable` (exit code 1); the cause goes to stderr, stdout stays parseable.
|
|
77
|
+
process.stderr.write(`Redis unreachable (code STATUS_UNREACHABLE): ${diagnostics.describeError(error)}\n`);
|
|
75
78
|
lease = 'unreachable';
|
|
76
79
|
}
|
|
77
80
|
finally {
|
|
78
|
-
await app.stop().catch(() => {
|
|
81
|
+
await app.stop().catch((error) => {
|
|
82
|
+
process.stderr.write(`Redis client stop failed (code STOP_FAILED): ${diagnostics.describeError(error)}\n`);
|
|
83
|
+
});
|
|
79
84
|
}
|
|
80
85
|
// This process is not a hub: state/role describe the asker, so they are left neutral.
|
|
81
86
|
status = hubStatus({ mode: 'cluster', state: 'closed', role: 'standby', lease });
|
package/dist/store.js
CHANGED
|
@@ -74,7 +74,7 @@ export class HubStore {
|
|
|
74
74
|
// D-0042: broadcasts live in leader memory; servers of the Redis-outbox version must
|
|
75
75
|
// not share a namespace with this one.
|
|
76
76
|
'delivery-memory-v2',
|
|
77
|
-
options.secret,
|
|
77
|
+
options.secret ?? '',
|
|
78
78
|
options.leaseMs,
|
|
79
79
|
options.ownerTtlMs,
|
|
80
80
|
options.maxConnections,
|
|
@@ -82,9 +82,13 @@ export class HubStore {
|
|
|
82
82
|
options.maxTotalConnections,
|
|
83
83
|
options.maxFrameBytes,
|
|
84
84
|
options.maxPayloadBytes,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
// D-0057 removed deliveryTimeoutMs, maxDeliveries and deliveryBytes. Their 0.2
|
|
86
|
+
// defaults stay here so 0.2 and 0.3 servers with the same settings pass this check
|
|
87
|
+
// during a rolling restart: the hello protocol check then refuses the other version
|
|
88
|
+
// (PROTOCOL_MISMATCH, retried) instead of CONFIG_MISMATCH failing startup at once.
|
|
89
|
+
60000,
|
|
90
|
+
10000,
|
|
91
|
+
67108864,
|
|
88
92
|
]))
|
|
89
93
|
.digest('hex');
|
|
90
94
|
}
|
|
@@ -101,7 +105,8 @@ export class HubStore {
|
|
|
101
105
|
catch (error) {
|
|
102
106
|
if (error instanceof HubError)
|
|
103
107
|
throw error;
|
|
104
|
-
|
|
108
|
+
// The Redis error is kept as the cause so the caller's error log can say why.
|
|
109
|
+
throw new HubError('STORE_UNAVAILABLE', { cause: error });
|
|
105
110
|
}
|
|
106
111
|
}
|
|
107
112
|
/**
|
|
@@ -141,8 +146,8 @@ export class HubStore {
|
|
|
141
146
|
PX: Math.max(1, ttlSeconds) * 1000,
|
|
142
147
|
});
|
|
143
148
|
}
|
|
144
|
-
catch {
|
|
145
|
-
throw new HubError('STORE_UNAVAILABLE');
|
|
149
|
+
catch (error) {
|
|
150
|
+
throw new HubError('STORE_UNAVAILABLE', { cause: error });
|
|
146
151
|
}
|
|
147
152
|
}
|
|
148
153
|
async discover() {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { DokebiError, type DokebiErrorOptions } from '@dokebi/core';
|
|
2
|
+
/**
|
|
3
|
+
* Errors of @dokebi/websocket-hub (D-0063): a DokebiError with `plugin: 'dokebi-websocket-hub'`
|
|
4
|
+
* and the message `WebSocket hub: <code>`. Classify by `code`, never with `instanceof` alone.
|
|
5
|
+
*/
|
|
6
|
+
export declare class HubError extends DokebiError {
|
|
7
|
+
constructor(code: string, options?: DokebiErrorOptions);
|
|
4
8
|
}
|
|
5
9
|
export interface HubRegistration {
|
|
6
10
|
readonly tenant: string;
|
|
@@ -35,8 +39,17 @@ export interface HubSnapshot {
|
|
|
35
39
|
readonly revision: number;
|
|
36
40
|
readonly connections: readonly HubRecord[];
|
|
37
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* What `broadcast` resolves with (D-0057): the message was handed out, at most once. `recipients`
|
|
44
|
+
* are the identities of the connections that matched when it was sent, not a confirmation that
|
|
45
|
+
* they received it.
|
|
46
|
+
*/
|
|
38
47
|
export interface HubReceipt {
|
|
39
|
-
readonly
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly recipients: readonly string[];
|
|
50
|
+
}
|
|
51
|
+
/** What `kick` resolves with: the close request was handed to the servers of the connections. */
|
|
52
|
+
export interface HubKickReceipt {
|
|
40
53
|
readonly authorityEpoch: string;
|
|
41
54
|
readonly id: string;
|
|
42
55
|
}
|
|
@@ -45,7 +58,6 @@ export type HubEvent = {
|
|
|
45
58
|
readonly id: string;
|
|
46
59
|
readonly connections: readonly string[];
|
|
47
60
|
readonly data: Uint8Array;
|
|
48
|
-
readonly expiresAt: number;
|
|
49
61
|
} | {
|
|
50
62
|
readonly kind: 'kick';
|
|
51
63
|
readonly id: string;
|
|
@@ -96,7 +108,7 @@ export interface HubStatus {
|
|
|
96
108
|
readonly servers?: number;
|
|
97
109
|
readonly connections?: number;
|
|
98
110
|
}
|
|
99
|
-
/** One-time nonce store for sealed frames (structurally the @dokebi/
|
|
111
|
+
/** One-time nonce store for sealed frames (structurally the @dokebi/seal NonceStore · D-0038, D-0059). */
|
|
100
112
|
export interface HubNonceStore {
|
|
101
113
|
setIfNotExists(key: string, ttlSeconds: number): Promise<boolean>;
|
|
102
114
|
/** true only when every server of the namespace shares it (cluster mode). */
|
|
@@ -109,9 +121,14 @@ export interface HubApi {
|
|
|
109
121
|
readonly leader: HubLeader | undefined;
|
|
110
122
|
register(value: HubRegistration): Promise<HubConnection>;
|
|
111
123
|
list(query: HubQuery): Promise<HubSnapshot>;
|
|
124
|
+
/**
|
|
125
|
+
* Hands `data` to every connection that matches `query`, at most once (D-0057): no receipt
|
|
126
|
+
* from clients, no resend. Fails at once with `RECOVERING` (no leader connection), `BUSY`
|
|
127
|
+
* (maxPending broadcasts in flight) or `OUTCOME_UNKNOWN` (the connection dropped after the
|
|
128
|
+
* request was sent: it may have been delivered). The caller decides whether to send again.
|
|
129
|
+
*/
|
|
112
130
|
broadcast(query: HubQuery, data: Uint8Array): Promise<HubReceipt>;
|
|
113
|
-
|
|
114
|
-
kick(query: HubQuery, code?: number, reason?: string): Promise<HubReceipt>;
|
|
131
|
+
kick(query: HubQuery, code?: number, reason?: string): Promise<HubKickReceipt>;
|
|
115
132
|
events(): AsyncIterableIterator<HubEvent>;
|
|
116
133
|
/**
|
|
117
134
|
* Resolves true once the hub is ready (now, or after a reconnect such as a leader change),
|
package/dist/types.js
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { DokebiError } from '@dokebi/core';
|
|
2
|
+
/** Repair advice of the codes a developer or operator fixes (the others are runtime outcomes). */
|
|
3
|
+
const FIXES = Object.freeze({
|
|
4
|
+
LOCAL_IN_CLUSTER: 'Use mode: cluster (Redis) in options.dokebi-websocket-hub, or set allowInCluster: true to give every worker its own hub.',
|
|
5
|
+
LISTEN_FAILED: 'Free options.dokebi-websocket-hub.port on host (or use port 0), and check that host is an address of this machine.',
|
|
6
|
+
STARTUP_TIMEOUT: 'Check that Redis (redisConnection) answers and that peers reach advertiseHost:port; raise startupTimeoutMs for slow networks.',
|
|
7
|
+
UNAUTHORIZED: 'Give every server of the namespace the same options.dokebi-websocket-hub.secret.',
|
|
8
|
+
PROTOCOL_MISMATCH: 'Run the same @dokebi/websocket-hub version on every server of a namespace (finish the rolling restart).',
|
|
9
|
+
CONFIG_MISMATCH: 'Servers of one namespace need the same secret, leaseMs, ownerTtlMs and size limits; use another namespace for different settings.',
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* Errors of @dokebi/websocket-hub (D-0063): a DokebiError with `plugin: 'dokebi-websocket-hub'`
|
|
13
|
+
* and the message `WebSocket hub: <code>`. Classify by `code`, never with `instanceof` alone.
|
|
14
|
+
*/
|
|
15
|
+
export class HubError extends DokebiError {
|
|
16
|
+
constructor(code, options = {}) {
|
|
17
|
+
const fix = options.fix ?? FIXES[code];
|
|
18
|
+
super(code, `WebSocket hub: ${code}`, {
|
|
19
|
+
...options,
|
|
20
|
+
plugin: options.plugin ?? 'dokebi-websocket-hub',
|
|
21
|
+
...(fix === undefined ? {} : { fix }),
|
|
22
|
+
});
|
|
6
23
|
this.name = 'HubError';
|
|
7
24
|
}
|
|
8
25
|
}
|
package/dist/values.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Own enumerable data properties of a plain object; Proxies and accessors are refused. */
|
|
2
|
+
export declare function object(value: unknown): Record<string, unknown>;
|
|
3
|
+
export declare function keys(value: Record<string, unknown>, allowed: readonly string[]): void;
|
|
4
|
+
export declare function integer(v: unknown, min: number, max: number): number;
|
package/dist/values.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { types } from 'node:util';
|
|
2
|
+
import { HubError } from './types.js';
|
|
3
|
+
/*
|
|
4
|
+
* Checks of values in hub frames and API calls. They lived in the 0.3 hand option parser, whose
|
|
5
|
+
* code they keep: a refused value is `INVALID_OPTIONS` on the wire as before (peers of the same
|
|
6
|
+
* protocol compare that code). Options themselves are parsed by the declaration in options.ts.
|
|
7
|
+
*/
|
|
8
|
+
/** Own enumerable data properties of a plain object; Proxies and accessors are refused. */
|
|
9
|
+
export function object(value) {
|
|
10
|
+
if (!value ||
|
|
11
|
+
typeof value !== 'object' ||
|
|
12
|
+
types.isProxy(value) ||
|
|
13
|
+
![Object.prototype, null].includes(Object.getPrototypeOf(value)))
|
|
14
|
+
throw new HubError('INVALID_OPTIONS');
|
|
15
|
+
const result = Object.create(null);
|
|
16
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
17
|
+
const desc = Object.getOwnPropertyDescriptor(value, key);
|
|
18
|
+
if (typeof key !== 'string' || !desc || !('value' in desc) || !desc.enumerable)
|
|
19
|
+
throw new HubError('INVALID_OPTIONS');
|
|
20
|
+
result[key] = desc.value;
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
export function keys(value, allowed) {
|
|
25
|
+
if (Object.keys(value).some((k) => !allowed.includes(k)))
|
|
26
|
+
throw new HubError('INVALID_OPTIONS');
|
|
27
|
+
}
|
|
28
|
+
export function integer(v, min, max) {
|
|
29
|
+
if (typeof v !== 'number' || !Number.isSafeInteger(v) || v < min || v > max)
|
|
30
|
+
throw new HubError('INVALID_OPTIONS');
|
|
31
|
+
return v;
|
|
32
|
+
}
|
package/dist/wire.d.ts
CHANGED
|
@@ -4,7 +4,14 @@ export declare class Wire {
|
|
|
4
4
|
readonly socket: Socket;
|
|
5
5
|
readonly limit: number;
|
|
6
6
|
readonly queueBytes: number;
|
|
7
|
-
constructor(socket: Socket, limit: number, queueBytes: number, onFrame: (frame: Record<string, unknown>) => void, onClose: () => void
|
|
7
|
+
constructor(socket: Socket, limit: number, queueBytes: number, onFrame: (frame: Record<string, unknown>) => void, onClose: () => void,
|
|
8
|
+
/**
|
|
9
|
+
* Told why the socket failed (`PEER_SOCKET_ERROR`) or a frame was refused and the socket
|
|
10
|
+
* dropped (`PEER_FRAME_REJECTED`); the owner logs it (D-0047). `close` always follows.
|
|
11
|
+
*/
|
|
12
|
+
onError?: (code: string, error: unknown) => void);
|
|
8
13
|
send(value: unknown): void;
|
|
9
14
|
close(): void;
|
|
15
|
+
/** Sends what is queued, then FIN; destroyed after `graceMs` if the peer does not close. */
|
|
16
|
+
end(graceMs: number): void;
|
|
10
17
|
}
|
package/dist/wire.js
CHANGED
|
@@ -7,12 +7,17 @@ export class Wire {
|
|
|
7
7
|
#chunks = [];
|
|
8
8
|
#bytes = 0;
|
|
9
9
|
#closed = false;
|
|
10
|
-
constructor(socket, limit, queueBytes, onFrame, onClose
|
|
10
|
+
constructor(socket, limit, queueBytes, onFrame, onClose,
|
|
11
|
+
/**
|
|
12
|
+
* Told why the socket failed (`PEER_SOCKET_ERROR`) or a frame was refused and the socket
|
|
13
|
+
* dropped (`PEER_FRAME_REJECTED`); the owner logs it (D-0047). `close` always follows.
|
|
14
|
+
*/
|
|
15
|
+
onError = () => { }) {
|
|
11
16
|
this.socket = socket;
|
|
12
17
|
this.limit = limit;
|
|
13
18
|
this.queueBytes = queueBytes;
|
|
14
19
|
socket.setNoDelay(true);
|
|
15
|
-
socket.on('error', () =>
|
|
20
|
+
socket.on('error', (error) => onError('PEER_SOCKET_ERROR', error));
|
|
16
21
|
socket.on('data', (data) => {
|
|
17
22
|
try {
|
|
18
23
|
let start = 0;
|
|
@@ -29,7 +34,8 @@ export class Wire {
|
|
|
29
34
|
}
|
|
30
35
|
this.#append(data.subarray(start));
|
|
31
36
|
}
|
|
32
|
-
catch {
|
|
37
|
+
catch (error) {
|
|
38
|
+
onError('PEER_FRAME_REJECTED', error);
|
|
33
39
|
socket.destroy();
|
|
34
40
|
}
|
|
35
41
|
});
|
|
@@ -59,4 +65,9 @@ export class Wire {
|
|
|
59
65
|
close() {
|
|
60
66
|
this.socket.destroy();
|
|
61
67
|
}
|
|
68
|
+
/** Sends what is queued, then FIN; destroyed after `graceMs` if the peer does not close. */
|
|
69
|
+
end(graceMs) {
|
|
70
|
+
this.socket.end();
|
|
71
|
+
setTimeout(() => this.socket.destroy(), graceMs).unref();
|
|
72
|
+
}
|
|
62
73
|
}
|
package/options.schema.json
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
"properties": {
|
|
6
6
|
"mode": {
|
|
7
7
|
"type": "string",
|
|
8
|
-
"enum": [
|
|
8
|
+
"enum": [
|
|
9
|
+
"local",
|
|
10
|
+
"cluster"
|
|
11
|
+
],
|
|
9
12
|
"default": "local",
|
|
10
13
|
"description": "local: one process, in memory (no Redis/NATS). cluster: several processes or servers share presence through Redis (D-0029)."
|
|
11
14
|
},
|
|
@@ -17,34 +20,44 @@
|
|
|
17
20
|
"namespace": {
|
|
18
21
|
"type": "string",
|
|
19
22
|
"minLength": 1,
|
|
20
|
-
"maxLength": 64
|
|
23
|
+
"maxLength": 64,
|
|
24
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",
|
|
25
|
+
"default": "local"
|
|
21
26
|
},
|
|
22
27
|
"serverId": {
|
|
23
28
|
"type": "string",
|
|
24
29
|
"minLength": 1,
|
|
25
|
-
"maxLength": 64
|
|
30
|
+
"maxLength": 64,
|
|
31
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",
|
|
32
|
+
"default": "local"
|
|
26
33
|
},
|
|
27
34
|
"redisConnection": {
|
|
28
35
|
"type": "string",
|
|
29
36
|
"minLength": 1,
|
|
30
37
|
"maxLength": 64,
|
|
38
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",
|
|
31
39
|
"description": "Required in cluster mode."
|
|
32
40
|
},
|
|
33
41
|
"natsConnection": {
|
|
34
42
|
"type": "string",
|
|
35
43
|
"minLength": 1,
|
|
36
44
|
"maxLength": 64,
|
|
37
|
-
"
|
|
45
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",
|
|
46
|
+
"description": "Optional in cluster mode: leader-change notifications; without it peers notice by Redis polling (pollIntervalMs)."
|
|
38
47
|
},
|
|
39
48
|
"host": {
|
|
40
49
|
"type": "string",
|
|
41
50
|
"minLength": 1,
|
|
42
|
-
"maxLength": 253
|
|
51
|
+
"maxLength": 253,
|
|
52
|
+
"pattern": "^[^\\s\\x00-\\x1f]+$",
|
|
53
|
+
"default": "127.0.0.1"
|
|
43
54
|
},
|
|
44
55
|
"advertiseHost": {
|
|
45
56
|
"type": "string",
|
|
46
57
|
"minLength": 1,
|
|
47
|
-
"maxLength": 253
|
|
58
|
+
"maxLength": 253,
|
|
59
|
+
"pattern": "^[^\\s\\x00-\\x1f]+$",
|
|
60
|
+
"default": "127.0.0.1"
|
|
48
61
|
},
|
|
49
62
|
"secret": {
|
|
50
63
|
"type": "string",
|
|
@@ -65,24 +78,38 @@
|
|
|
65
78
|
"maximum": 60000,
|
|
66
79
|
"default": 3000
|
|
67
80
|
},
|
|
68
|
-
"
|
|
81
|
+
"pollIntervalMs": {
|
|
69
82
|
"type": "integer",
|
|
70
83
|
"minimum": 25,
|
|
71
84
|
"maximum": 10000,
|
|
72
85
|
"default": 500
|
|
73
86
|
},
|
|
87
|
+
"pollMs": {
|
|
88
|
+
"type": "integer",
|
|
89
|
+
"minimum": 25,
|
|
90
|
+
"maximum": 10000,
|
|
91
|
+
"deprecated": true,
|
|
92
|
+
"description": "Deprecated name of pollIntervalMs; use that key."
|
|
93
|
+
},
|
|
74
94
|
"ownerTtlMs": {
|
|
75
95
|
"type": "integer",
|
|
76
96
|
"minimum": 1500,
|
|
77
97
|
"maximum": 120000,
|
|
78
98
|
"default": 15000
|
|
79
99
|
},
|
|
80
|
-
"
|
|
100
|
+
"startupTimeoutMs": {
|
|
81
101
|
"type": "integer",
|
|
82
102
|
"minimum": 1000,
|
|
83
103
|
"maximum": 120000,
|
|
84
104
|
"default": 15000
|
|
85
105
|
},
|
|
106
|
+
"startupMs": {
|
|
107
|
+
"type": "integer",
|
|
108
|
+
"minimum": 1000,
|
|
109
|
+
"maximum": 120000,
|
|
110
|
+
"deprecated": true,
|
|
111
|
+
"description": "Deprecated name of startupTimeoutMs; use that key."
|
|
112
|
+
},
|
|
86
113
|
"maxFrameBytes": {
|
|
87
114
|
"type": "integer",
|
|
88
115
|
"minimum": 16384,
|
|
@@ -119,52 +146,102 @@
|
|
|
119
146
|
"maximum": 4096,
|
|
120
147
|
"default": 128
|
|
121
148
|
},
|
|
122
|
-
"
|
|
149
|
+
"maxPendingBytes": {
|
|
123
150
|
"type": "integer",
|
|
124
151
|
"minimum": 16384,
|
|
125
152
|
"maximum": 67108864,
|
|
126
153
|
"default": 4194304
|
|
127
154
|
},
|
|
155
|
+
"queueBytes": {
|
|
156
|
+
"type": "integer",
|
|
157
|
+
"minimum": 16384,
|
|
158
|
+
"maximum": 67108864,
|
|
159
|
+
"deprecated": true,
|
|
160
|
+
"description": "Deprecated name of maxPendingBytes; use that key."
|
|
161
|
+
},
|
|
128
162
|
"deliveryTimeoutMs": {
|
|
129
163
|
"type": "integer",
|
|
130
|
-
"
|
|
131
|
-
"
|
|
132
|
-
"default": 60000
|
|
164
|
+
"deprecated": true,
|
|
165
|
+
"description": "Removed in 0.3.0 with client ACKs (D-0057). Ignored: the hub logs warn OPTION_REMOVED once and starts. Delete it from dokebi.yaml."
|
|
133
166
|
},
|
|
134
167
|
"retryMs": {
|
|
135
168
|
"type": "integer",
|
|
136
|
-
"
|
|
137
|
-
"
|
|
138
|
-
"default": 1000
|
|
169
|
+
"deprecated": true,
|
|
170
|
+
"description": "Removed in 0.3.0 with client ACKs (D-0057). Ignored: the hub logs warn OPTION_REMOVED once and starts. Delete it from dokebi.yaml."
|
|
139
171
|
},
|
|
140
172
|
"maxDeliveries": {
|
|
141
173
|
"type": "integer",
|
|
142
|
-
"
|
|
143
|
-
"
|
|
144
|
-
"default": 10000
|
|
174
|
+
"deprecated": true,
|
|
175
|
+
"description": "Removed in 0.3.0 with client ACKs (D-0057). Ignored: the hub logs warn OPTION_REMOVED once and starts. Delete it from dokebi.yaml."
|
|
145
176
|
},
|
|
146
177
|
"deliveryBytes": {
|
|
147
178
|
"type": "integer",
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
"default": 67108864
|
|
179
|
+
"deprecated": true,
|
|
180
|
+
"description": "Removed in 0.3.0 with client ACKs (D-0057). Ignored: the hub logs warn OPTION_REMOVED once and starts. Delete it from dokebi.yaml."
|
|
151
181
|
}
|
|
152
182
|
},
|
|
153
|
-
"
|
|
154
|
-
|
|
155
|
-
"
|
|
156
|
-
"
|
|
183
|
+
"allOf": [
|
|
184
|
+
{
|
|
185
|
+
"if": {
|
|
186
|
+
"properties": {
|
|
187
|
+
"mode": {
|
|
188
|
+
"const": "cluster"
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"required": [
|
|
192
|
+
"mode"
|
|
193
|
+
]
|
|
194
|
+
},
|
|
195
|
+
"then": {
|
|
196
|
+
"properties": {
|
|
197
|
+
"namespace": true,
|
|
198
|
+
"serverId": true
|
|
199
|
+
},
|
|
200
|
+
"required": [
|
|
201
|
+
"namespace",
|
|
202
|
+
"serverId"
|
|
203
|
+
]
|
|
157
204
|
}
|
|
158
205
|
},
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
206
|
+
{
|
|
207
|
+
"if": {
|
|
208
|
+
"properties": {
|
|
209
|
+
"mode": {
|
|
210
|
+
"const": "cluster"
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
"required": [
|
|
214
|
+
"mode"
|
|
215
|
+
]
|
|
216
|
+
},
|
|
217
|
+
"then": {
|
|
218
|
+
"properties": {
|
|
219
|
+
"redisConnection": true
|
|
220
|
+
},
|
|
221
|
+
"required": [
|
|
222
|
+
"redisConnection"
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"if": {
|
|
228
|
+
"properties": {
|
|
229
|
+
"mode": {
|
|
230
|
+
"const": "cluster"
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
"required": [
|
|
234
|
+
"mode"
|
|
235
|
+
]
|
|
236
|
+
},
|
|
237
|
+
"then": {
|
|
238
|
+
"properties": {
|
|
239
|
+
"secret": true
|
|
240
|
+
},
|
|
241
|
+
"required": [
|
|
242
|
+
"secret"
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
]
|
|
170
247
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dokebi/websocket-hub",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "WebSocket hub for Dokebi: connection roster, rooms, broadcast and kick across workers and servers.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dokebi",
|
|
7
|
+
"dokebi-plugin",
|
|
8
|
+
"websocket",
|
|
9
|
+
"hub",
|
|
10
|
+
"realtime"
|
|
11
|
+
],
|
|
4
12
|
"private": false,
|
|
5
13
|
"type": "module",
|
|
6
14
|
"license": "MIT",
|
|
@@ -13,6 +21,10 @@
|
|
|
13
21
|
".": {
|
|
14
22
|
"types": "./dist/index.d.ts",
|
|
15
23
|
"import": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./dependency": {
|
|
26
|
+
"types": "./dist/dependency.d.ts",
|
|
27
|
+
"import": "./dist/dependency.js"
|
|
16
28
|
}
|
|
17
29
|
},
|
|
18
30
|
"files": [
|
|
@@ -26,32 +38,32 @@
|
|
|
26
38
|
"node": ">=24.0.0"
|
|
27
39
|
},
|
|
28
40
|
"scripts": {
|
|
29
|
-
"build": "tsc -p tsconfig.json",
|
|
41
|
+
"build": "tsc -p tsconfig.json && node -e \"import('./dist/options.js').then(async (m) => { const { renderOptionsSchema } = await import('@dokebi/core'); process.stdout.write(renderOptionsSchema(m.options)); })\" > options.schema.json",
|
|
30
42
|
"typecheck": "tsc -p tsconfig.test.json --noEmit",
|
|
31
|
-
"test": "tsc -p tsconfig.test.json && node --test \".tmp/tests/tests/*.test.js\""
|
|
43
|
+
"test": "node -e \"require('node:fs').rmSync('.tmp/tests',{recursive:true,force:true})\" && tsc -p tsconfig.test.json && node --test \".tmp/tests/tests/*.test.js\""
|
|
32
44
|
},
|
|
33
45
|
"peerDependencies": {
|
|
34
|
-
"@dokebi/core": "^0.
|
|
35
|
-
"@dokebi/nats": "^0.
|
|
36
|
-
"@dokebi/redis": "^0.
|
|
46
|
+
"@dokebi/core": "^0.4.0",
|
|
47
|
+
"@dokebi/nats": "^0.4.0",
|
|
48
|
+
"@dokebi/redis": "^0.4.0"
|
|
37
49
|
},
|
|
38
50
|
"devDependencies": {
|
|
39
|
-
"@dokebi/nats": "0.
|
|
40
|
-
"@dokebi/redis": "0.
|
|
51
|
+
"@dokebi/nats": "0.4.0",
|
|
52
|
+
"@dokebi/redis": "0.4.0"
|
|
41
53
|
},
|
|
42
54
|
"dokebi": {
|
|
43
55
|
"schemaVersion": 2,
|
|
44
56
|
"id": "dokebi-websocket-hub",
|
|
45
|
-
"core": "^0.
|
|
57
|
+
"core": "^0.4.0",
|
|
46
58
|
"dependencies": [
|
|
47
59
|
{
|
|
48
60
|
"name": "dokebi-redis",
|
|
49
|
-
"version": "^0.
|
|
61
|
+
"version": "^0.4.0",
|
|
50
62
|
"optional": true
|
|
51
63
|
},
|
|
52
64
|
{
|
|
53
65
|
"name": "dokebi-nats",
|
|
54
|
-
"version": "^0.
|
|
66
|
+
"version": "^0.4.0",
|
|
55
67
|
"optional": true
|
|
56
68
|
}
|
|
57
69
|
],
|
|
@@ -59,6 +71,18 @@
|
|
|
59
71
|
"documentation": "AI.md",
|
|
60
72
|
"installModule": "dist/install.js"
|
|
61
73
|
},
|
|
74
|
+
"dokebiCatalog": {
|
|
75
|
+
"kind": "plugin",
|
|
76
|
+
"summary": "Hub of WebSocket clients, rooms, broadcast and kick (usually used through @dokebi/websocket)",
|
|
77
|
+
"maturity": "preview",
|
|
78
|
+
"provides": [
|
|
79
|
+
"realtime.hub"
|
|
80
|
+
],
|
|
81
|
+
"doesNot": [
|
|
82
|
+
"No delivery ACK or redelivery"
|
|
83
|
+
],
|
|
84
|
+
"recipes": []
|
|
85
|
+
},
|
|
62
86
|
"publishConfig": {
|
|
63
87
|
"access": "public",
|
|
64
88
|
"registry": "https://registry.npmjs.org/"
|