apache-iggy 0.10.0 → 0.10.1-edge.2
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 +248 -28
- package/dist/client/client.config.d.ts +2 -0
- package/dist/client/client.config.js +13 -2
- package/dist/client/client.config.test.js +15 -2
- package/dist/client/client.connection-string.js +13 -1
- package/dist/client/client.connection-string.test.js +43 -1
- package/dist/client/client.connection.d.ts +33 -135
- package/dist/client/client.connection.js +190 -453
- package/dist/client/client.connection.test.js +244 -669
- package/dist/client/client.d.ts +4 -35
- package/dist/client/client.js +8 -101
- package/dist/client/client.operation.d.ts +120 -0
- package/dist/client/client.operation.js +428 -0
- package/dist/client/client.operation.test.d.ts +2 -0
- package/dist/client/client.operation.test.js +285 -0
- package/dist/client/client.socket.d.ts +92 -209
- package/dist/client/client.socket.js +1205 -981
- package/dist/client/client.socket.test.js +4865 -679
- package/dist/client/client.type.d.ts +65 -22
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +1 -0
- package/dist/client.e2e.js +3 -5
- package/dist/e2e/resource-options.e2e.d.ts +2 -0
- package/dist/{wire/stream/purge-stream.command.js → e2e/resource-options.e2e.js} +12 -20
- package/dist/e2e/resource-options.suite.d.ts +15 -0
- package/dist/e2e/resource-options.suite.js +272 -0
- package/dist/e2e/tcp.cluster.e2e.js +1 -0
- package/dist/e2e/tcp.consumer-stream.e2e.js +4 -0
- package/dist/e2e/tcp.parallel.e2e.js +5 -6
- package/dist/e2e/tcp.stream.e2e.js +0 -3
- package/dist/e2e/tcp.system.e2e.js +10 -1
- package/dist/e2e/tcp.token.e2e.js +8 -2
- package/dist/e2e/tcp.topic.e2e.js +0 -3
- package/dist/e2e/tcp.user.e2e.js +46 -3
- package/dist/e2e/tls.system.e2e.js +21 -12
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/stream/consumer-stream.js +97 -12
- package/dist/wire/cluster/cluster.type.d.ts +2 -2
- package/dist/wire/cluster/cluster.utils.d.ts +1 -0
- package/dist/wire/cluster/cluster.utils.js +4 -1
- package/dist/wire/command-set.d.ts +8 -8
- package/dist/wire/command-set.js +18 -9
- package/dist/wire/command.code.d.ts +3 -10
- package/dist/wire/command.code.js +9 -11
- package/dist/wire/command.utils.d.ts +3 -2
- package/dist/wire/command.utils.js +3 -2
- package/dist/wire/error.code.js +17 -1
- package/dist/wire/error.code.test.js +28 -1
- package/dist/wire/error.utils.d.ts +4 -2
- package/dist/wire/error.utils.js +6 -3
- package/dist/wire/identifier.utils.d.ts +2 -0
- package/dist/wire/identifier.utils.js +2 -0
- package/dist/wire/index.d.ts +1 -0
- package/dist/wire/index.js +1 -0
- package/dist/wire/message/header.type.d.ts +1 -1
- package/dist/wire/message/message-batch.test.js +11 -5
- package/dist/wire/message/message.utils.d.ts +0 -10
- package/dist/wire/message/message.utils.js +1 -22
- package/dist/wire/message/poll-messages.command.d.ts +12 -1
- package/dist/wire/message/poll-messages.command.js +64 -16
- package/dist/wire/message/poll-messages.command.test.js +143 -5
- package/dist/wire/message/poll.utils.d.ts +4 -0
- package/dist/wire/message/poll.utils.js +6 -1
- package/dist/wire/message/send-messages.command.d.ts +3 -3
- package/dist/wire/message/send-messages.command.js +103 -3
- package/dist/wire/message/send-messages.command.test.js +113 -2
- package/dist/wire/offset/delete-offset.command.d.ts +11 -4
- package/dist/wire/offset/delete-offset.command.js +1 -1
- package/dist/wire/offset/get-offset.command.d.ts +1 -1
- package/dist/wire/offset/offset-write.command.test.d.ts +2 -0
- package/dist/wire/offset/offset-write.command.test.js +43 -0
- package/dist/wire/offset/offset.utils.js +10 -6
- package/dist/wire/offset/store-offset.command.d.ts +10 -0
- package/dist/wire/offset/store-offset.command.js +1 -1
- package/dist/wire/options.utils.d.ts +46 -0
- package/dist/wire/options.utils.js +57 -0
- package/dist/wire/partition/partition-route.d.ts +12 -0
- package/dist/wire/partition/partition-route.js +40 -0
- package/dist/wire/partition/partition-route.test.d.ts +2 -0
- package/dist/wire/partition/partition-route.test.js +42 -0
- package/dist/wire/session/login-with-token.command.d.ts +2 -2
- package/dist/wire/session/login-with-token.command.js +7 -2
- package/dist/wire/session/login.command.d.ts +2 -2
- package/dist/wire/session/login.command.js +7 -2
- package/dist/wire/stream/create-stream.command.d.ts +5 -2
- package/dist/wire/stream/create-stream.command.js +20 -2
- package/dist/wire/stream/index.d.ts +1 -1
- package/dist/wire/stream/index.js +1 -1
- package/dist/wire/stream/stream-options.d.ts +77 -0
- package/dist/wire/stream/stream-options.js +101 -0
- package/dist/wire/stream/stream-options.test.d.ts +2 -0
- package/dist/wire/stream/stream-options.test.js +103 -0
- package/dist/wire/stream/stream.utils.d.ts +9 -0
- package/dist/wire/stream/stream.utils.js +17 -3
- package/dist/wire/stream/update-stream.command.d.ts +23 -5
- package/dist/wire/stream/update-stream.command.js +10 -17
- package/dist/wire/system/describe-options.command.d.ts +23 -6
- package/dist/wire/system/describe-options.command.js +21 -2
- package/dist/wire/system/get-stats.command.d.ts +17 -0
- package/dist/wire/system/get-stats.command.js +69 -16
- package/dist/wire/system/get-stats.command.test.d.ts +2 -0
- package/dist/wire/system/get-stats.command.test.js +97 -0
- package/dist/wire/system/index.d.ts +2 -0
- package/dist/wire/system/index.js +2 -0
- package/dist/wire/system/snapshot.command.d.ts +64 -0
- package/dist/wire/system/snapshot.command.js +76 -0
- package/dist/wire/system/snapshot.command.test.d.ts +2 -0
- package/dist/wire/system/snapshot.command.test.js +86 -0
- package/dist/wire/system/update-resource.command.d.ts +53 -0
- package/dist/wire/system/update-resource.command.js +130 -0
- package/dist/wire/system/update-resource.command.test.d.ts +2 -0
- package/dist/wire/system/update-resource.command.test.js +497 -0
- package/dist/wire/token/create-token.command.d.ts +1 -1
- package/dist/wire/token/create-token.command.js +1 -1
- package/dist/wire/token/create-token.command.test.js +6 -0
- package/dist/wire/topic/create-topic.command.d.ts +20 -12
- package/dist/wire/topic/create-topic.command.js +11 -4
- package/dist/wire/topic/index.d.ts +1 -2
- package/dist/wire/topic/index.js +1 -2
- package/dist/wire/topic/topic.utils.d.ts +14 -5
- package/dist/wire/topic/topic.utils.js +26 -11
- package/dist/wire/topic/topic.utils.test.js +13 -13
- package/dist/wire/topic/update-topic.command.d.ts +22 -15
- package/dist/wire/topic/update-topic.command.js +12 -34
- package/dist/wire/user/create-user.command.d.ts +12 -2
- package/dist/wire/user/create-user.command.js +7 -3
- package/dist/wire/user/index.d.ts +1 -0
- package/dist/wire/user/index.js +1 -0
- package/dist/wire/user/update-user.command.d.ts +25 -7
- package/dist/wire/user/update-user.command.js +18 -31
- package/dist/wire/user/user.utils.d.ts +2 -0
- package/dist/wire/user/user.utils.js +5 -3
- package/dist/wire/vsr/header.d.ts +23 -8
- package/dist/wire/vsr/header.js +32 -10
- package/dist/wire/vsr/header.test.js +5 -1
- package/dist/wire/vsr/index.d.ts +8 -2
- package/dist/wire/vsr/index.js +44 -11
- package/dist/wire/vsr/operation.d.ts +18 -6
- package/dist/wire/vsr/operation.js +46 -16
- package/dist/wire/vsr/operation.test.js +32 -8
- package/dist/wire/vsr/register.d.ts +10 -6
- package/dist/wire/vsr/register.js +24 -7
- package/dist/wire/vsr/register.test.js +28 -8
- package/dist/wire/vsr/reply.d.ts +4 -1
- package/dist/wire/vsr/reply.js +42 -7
- package/dist/wire/vsr/reply.test.js +11 -1
- package/dist/wire/vsr/session.d.ts +9 -10
- package/dist/wire/vsr/session.js +32 -23
- package/dist/wire/vsr/session.test.js +33 -7
- package/dist/wire/vsr/vsr.test.js +57 -6
- package/package.json +6 -7
- package/dist/wire/message/flush-unsaved-buffers.command.d.ts +0 -26
- package/dist/wire/message/flush-unsaved-buffers.command.js +0 -36
- package/dist/wire/stream/purge-stream.command.d.ts +0 -22
- package/dist/wire/topic/purge-topic.command.d.ts +0 -24
- package/dist/wire/topic/purge-topic.command.js +0 -39
|
@@ -1,153 +1,51 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
2
|
import type { Socket } from 'node:net';
|
|
3
3
|
import type { ClientConfig } from "./client.type.js";
|
|
4
|
-
|
|
4
|
+
import { type FrozenFrame } from './client.operation.js';
|
|
5
5
|
export type Endpoint = {
|
|
6
6
|
host: string;
|
|
7
7
|
port: number;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*/
|
|
9
|
+
export declare const DIAL_TIMEOUT_MS = 2000;
|
|
10
|
+
export declare const LINK_WRITE_QUEUE = 32;
|
|
11
|
+
export declare const MAX_PENDING_PER_LINK = 256;
|
|
12
|
+
/** A connected socket was lost; a later bootstrap can bind it again. */
|
|
13
|
+
export declare class ConnectionClosedError extends Error {
|
|
14
|
+
constructor(cause?: Error);
|
|
15
|
+
}
|
|
16
|
+
export type LinkAttempt = {
|
|
17
|
+
response?: Buffer;
|
|
18
|
+
error?: unknown;
|
|
19
|
+
started: boolean;
|
|
20
|
+
};
|
|
21
|
+
/** One physical endpoint, with independent reader framing and a bounded writer. */
|
|
13
22
|
export declare class IggyConnection extends EventEmitter {
|
|
14
|
-
|
|
15
|
-
config: ClientConfig;
|
|
16
|
-
/** Underlying socket connection */
|
|
23
|
+
readonly config: ClientConfig;
|
|
17
24
|
socket: Socket;
|
|
18
|
-
/** Whether the connection is established */
|
|
19
25
|
connected: boolean;
|
|
20
|
-
/** Whether a connection attempt is in progress */
|
|
21
|
-
connecting: boolean;
|
|
22
|
-
/** Whether the connection is being intentionally closed */
|
|
23
26
|
ending: boolean;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* caller submitted is in doubt: work waiting to be sent belongs on the node
|
|
28
|
-
* the client moves to, not in an error.
|
|
29
|
-
*/
|
|
30
|
-
redirecting: boolean;
|
|
31
|
-
/** Reconnection configuration */
|
|
32
|
-
private reconnectOption;
|
|
33
|
-
/**
|
|
34
|
-
* Number of passes made over the known endpoints. One pass dials the
|
|
35
|
-
* endpoint the client is on, the endpoint it was configured with, and every
|
|
36
|
-
* node the roster named.
|
|
37
|
-
*/
|
|
38
|
-
private reconnectCount;
|
|
39
|
-
/** Shared promise for concurrent callers waiting on one connection attempt */
|
|
27
|
+
failure?: unknown;
|
|
28
|
+
readonly closed: Promise<void>;
|
|
29
|
+
private close;
|
|
40
30
|
private connectPromise?;
|
|
41
|
-
|
|
42
|
-
private
|
|
43
|
-
|
|
44
|
-
private readonly
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
* connection was still healthy.
|
|
50
|
-
*/
|
|
51
|
-
private rosterEndpoints;
|
|
52
|
-
/** Incremental response frame decoder */
|
|
53
|
-
private responseDecoder;
|
|
54
|
-
/**
|
|
55
|
-
* Creates a new IggyConnection.
|
|
56
|
-
*
|
|
57
|
-
* @param config - Client configuration
|
|
58
|
-
*/
|
|
31
|
+
private readonly decoder;
|
|
32
|
+
private readonly pending;
|
|
33
|
+
private readonly writes;
|
|
34
|
+
private readonly changed;
|
|
35
|
+
private readonly admissions;
|
|
36
|
+
private writing;
|
|
37
|
+
private frameTimer?;
|
|
38
|
+
private failed;
|
|
59
39
|
constructor(config: ClientConfig);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
private
|
|
66
|
-
|
|
67
|
-
* Establishes the connection to the server.
|
|
68
|
-
*
|
|
69
|
-
* @returns Promise that resolves when connected
|
|
70
|
-
*/
|
|
71
|
-
connect(boundDial?: boolean): Promise<this>;
|
|
72
|
-
/**
|
|
73
|
-
* Waits for one dial, bounded while other endpoints are queued behind it.
|
|
74
|
-
*
|
|
75
|
-
* A socket has no connect deadline of its own and there is no 'timeout'
|
|
76
|
-
* listener on it, so a node whose syns are dropped holds the pass for the
|
|
77
|
-
* whole OS connect timeout -- and it leads every pass, because the current
|
|
78
|
-
* endpoint only moves on success. The bound covers the TLS handshake too,
|
|
79
|
-
* which is what `_readyEvent()` waits for and has no deadline of its own
|
|
80
|
-
* either. It matches the Rust, Go and C# SDKs'.
|
|
81
|
-
*/
|
|
82
|
-
private _dialWithin;
|
|
83
|
-
/**
|
|
84
|
-
* The event that says a socket can carry a request.
|
|
85
|
-
*
|
|
86
|
-
* On TLS that is 'secureConnect', not 'connect': the latter fires as soon as
|
|
87
|
-
* the TCP handshake completes, so waiting on it would treat a peer that
|
|
88
|
-
* never answers the ClientHello as connected and leave the handshake with no
|
|
89
|
-
* deadline at all.
|
|
90
|
-
*/
|
|
91
|
-
private _readyEvent;
|
|
92
|
-
private _waitForConnection;
|
|
93
|
-
/**
|
|
94
|
-
* Attempts to reconnect to the server.
|
|
95
|
-
* Respects maxRetries limit and emits error when exceeded.
|
|
96
|
-
*
|
|
97
|
-
* @param err - Optional error that triggered the reconnection
|
|
98
|
-
*/
|
|
99
|
-
reconnect(err?: Error): Promise<this | undefined>;
|
|
100
|
-
private _reconnectUntilConnected;
|
|
101
|
-
/**
|
|
102
|
-
* Records the cluster roster as redial candidates.
|
|
103
|
-
*
|
|
104
|
-
* Replaced wholesale rather than merged: the roster is the cluster's own
|
|
105
|
-
* answer about where its nodes are, so a node it dropped stops being
|
|
106
|
-
* dialed. The configured seed is kept separately and outlives it.
|
|
107
|
-
*/
|
|
108
|
-
rememberRoster(endpoints: Endpoint[]): void;
|
|
109
|
-
/**
|
|
110
|
-
* The roster endpoint after the one this connection is on, for a request
|
|
111
|
-
* the current node keeps refusing to admit. Metadata and partition
|
|
112
|
-
* consensus groups elect independently, so the metadata leader can hold a
|
|
113
|
-
* follower replica of the partition a request targets, and only walking
|
|
114
|
-
* the roster reaches that group's primary. `undefined` when the roster
|
|
115
|
-
* names nowhere else to go.
|
|
116
|
-
*/
|
|
117
|
-
nextRosterEndpoint(visited: Set<string>): Endpoint | undefined;
|
|
118
|
-
/**
|
|
119
|
-
* Endpoints a redial rotates through, likeliest first: where the client
|
|
120
|
-
* currently is, the endpoint it was configured with, then the roster it
|
|
121
|
-
* learned while connected. After a leader redirect the current endpoint may
|
|
122
|
-
* die with the leader, and the rest of the list is the way back to the
|
|
123
|
-
* cluster.
|
|
124
|
-
*
|
|
125
|
-
* Duplicates are dropped by spelling: the loopback aliases and an
|
|
126
|
-
* IPv4-mapped IPv6 address collapse onto one endpoint. Names are not
|
|
127
|
-
* resolved, so a seed given as a DNS name and the roster's IP for the same
|
|
128
|
-
* node still count as two candidates -- one wasted dial per pass, not a
|
|
129
|
-
* correctness problem.
|
|
130
|
-
*/
|
|
131
|
-
_redialCandidates(): ClientConfig['options'][];
|
|
132
|
-
redirect(host: string, port: number): Promise<void>;
|
|
133
|
-
abort(): void;
|
|
40
|
+
connect(signal?: AbortSignal): Promise<this>;
|
|
41
|
+
private dial;
|
|
42
|
+
exchange(frame: () => Buffer, deadline: number, signal: AbortSignal, owner?: FrozenFrame): Promise<LinkAttempt>;
|
|
43
|
+
private writeFrames;
|
|
44
|
+
private onData;
|
|
45
|
+
private finish;
|
|
46
|
+
private fail;
|
|
134
47
|
isConnectedTo(host: string, port: number): boolean;
|
|
135
|
-
/**
|
|
136
|
-
* Destroys the connection and marks it as ending.
|
|
137
|
-
*/
|
|
138
48
|
_destroy(): void;
|
|
139
|
-
/**
|
|
140
|
-
* Clears the response buffer and resets the waiting state.
|
|
141
|
-
*/
|
|
142
|
-
_endResponseWait(): void;
|
|
143
|
-
/**
|
|
144
|
-
* Handles incoming data from the socket.
|
|
145
|
-
* Buffers incomplete responses and emits complete ones.
|
|
146
|
-
*
|
|
147
|
-
* @param data - Incoming data buffer
|
|
148
|
-
*/
|
|
149
|
-
_onData(data: Buffer): void;
|
|
150
|
-
writeFrame(frame: Buffer): void;
|
|
151
49
|
}
|
|
152
50
|
export declare const endpointKey: (endpoint: Endpoint) => string;
|
|
153
51
|
//# sourceMappingURL=client.connection.d.ts.map
|