apache-iggy 0.8.1-edge.1 → 0.8.1-edge.3
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/LICENSE +1 -1
- package/README.md +62 -1
- package/dist/client/client.config.d.ts +6 -0
- package/dist/client/client.config.js +40 -0
- package/dist/client/client.config.test.d.ts +2 -0
- package/dist/client/client.config.test.js +68 -0
- package/dist/client/client.connection.d.ts +29 -26
- package/dist/client/client.connection.js +249 -97
- package/dist/client/client.connection.test.d.ts +2 -0
- package/dist/client/client.connection.test.js +385 -0
- package/dist/client/client.d.ts +4 -22
- package/dist/client/client.debug.d.ts +0 -18
- package/dist/client/client.debug.js +17 -18
- package/dist/client/client.frame.d.ts +31 -0
- package/dist/client/client.frame.js +168 -0
- package/dist/client/client.frame.test.d.ts +2 -0
- package/dist/client/client.frame.test.js +110 -0
- package/dist/client/client.js +52 -52
- package/dist/client/client.socket.d.ts +28 -25
- package/dist/client/client.socket.js +313 -62
- package/dist/client/client.socket.test.d.ts +2 -0
- package/dist/client/client.socket.test.js +509 -0
- package/dist/client/client.type.d.ts +17 -19
- package/dist/client/client.type.js +17 -18
- package/dist/client/client.utils.d.ts +0 -18
- package/dist/client/client.utils.js +17 -18
- package/dist/client/client.utils.test.d.ts +0 -18
- package/dist/client/client.utils.test.js +17 -18
- package/dist/client/index.d.ts +1 -18
- package/dist/client/index.js +18 -18
- package/dist/client.e2e.d.ts +0 -18
- package/dist/client.e2e.js +17 -18
- package/dist/debug-send.d.ts +0 -18
- package/dist/debug-send.js +17 -18
- package/dist/debug.d.ts +0 -18
- package/dist/debug.js +17 -18
- package/dist/e2e/tcp.client.e2e.d.ts +0 -18
- package/dist/e2e/tcp.client.e2e.js +17 -18
- package/dist/e2e/tcp.cluster.e2e.d.ts +0 -18
- package/dist/e2e/tcp.cluster.e2e.js +17 -18
- package/dist/e2e/tcp.consumer-group.e2e.d.ts +0 -18
- package/dist/e2e/tcp.consumer-group.e2e.js +23 -20
- package/dist/e2e/tcp.consumer-stream.e2e.d.ts +0 -18
- package/dist/e2e/tcp.consumer-stream.e2e.js +22 -19
- package/dist/e2e/tcp.parallel.e2e.d.ts +0 -18
- package/dist/e2e/tcp.parallel.e2e.js +17 -18
- package/dist/e2e/tcp.raw.e2e.d.ts +2 -0
- package/dist/e2e/tcp.raw.e2e.js +54 -0
- package/dist/e2e/tcp.send-message.e2e.d.ts +0 -18
- package/dist/e2e/tcp.send-message.e2e.js +17 -18
- package/dist/e2e/tcp.stream.e2e.d.ts +0 -18
- package/dist/e2e/tcp.stream.e2e.js +17 -18
- package/dist/e2e/tcp.system.e2e.d.ts +0 -18
- package/dist/e2e/tcp.system.e2e.js +17 -18
- package/dist/e2e/tcp.token.e2e.d.ts +0 -18
- package/dist/e2e/tcp.token.e2e.js +17 -18
- package/dist/e2e/tcp.topic.e2e.d.ts +0 -18
- package/dist/e2e/tcp.topic.e2e.js +17 -18
- package/dist/e2e/tcp.user.e2e.d.ts +0 -18
- package/dist/e2e/tcp.user.e2e.js +51 -21
- package/dist/e2e/test-client.utils.d.ts +0 -18
- package/dist/e2e/test-client.utils.js +19 -18
- package/dist/e2e/tls.system.e2e.d.ts +0 -18
- package/dist/e2e/tls.system.e2e.js +17 -18
- package/dist/index.d.ts +3 -18
- package/dist/index.js +20 -18
- package/dist/stream/consumer-stream.d.ts +0 -18
- package/dist/stream/consumer-stream.js +22 -18
- package/dist/stream/index.d.ts +0 -18
- package/dist/stream/index.js +17 -18
- package/dist/tcp.e2e.d.ts +0 -18
- package/dist/tcp.e2e.js +17 -18
- package/dist/tcp.sm.utils.d.ts +0 -18
- package/dist/tcp.sm.utils.js +17 -18
- package/dist/tls.system.e2e.d.ts +0 -18
- package/dist/tls.system.e2e.js +17 -18
- package/dist/type.utils.d.ts +0 -18
- package/dist/type.utils.js +17 -18
- package/dist/wire/client/client.utils.d.ts +0 -18
- package/dist/wire/client/client.utils.js +17 -18
- package/dist/wire/client/get-client.command.d.ts +0 -18
- package/dist/wire/client/get-client.command.js +17 -18
- package/dist/wire/client/get-clients.command.d.ts +0 -18
- package/dist/wire/client/get-clients.command.js +17 -18
- package/dist/wire/client/get-me.command.d.ts +0 -18
- package/dist/wire/client/get-me.command.js +17 -18
- package/dist/wire/client/index.d.ts +0 -18
- package/dist/wire/client/index.js +17 -18
- package/dist/wire/cluster/cluster.type.d.ts +2 -20
- package/dist/wire/cluster/cluster.type.js +17 -18
- package/dist/wire/cluster/cluster.utils.d.ts +0 -18
- package/dist/wire/cluster/cluster.utils.js +17 -18
- package/dist/wire/cluster/get-cluster-metadata.command.d.ts +0 -18
- package/dist/wire/cluster/get-cluster-metadata.command.js +17 -18
- package/dist/wire/cluster/index.d.ts +0 -18
- package/dist/wire/cluster/index.js +17 -18
- package/dist/wire/command-set.d.ts +14 -23
- package/dist/wire/command-set.js +42 -19
- package/dist/wire/command-set.test.d.ts +2 -0
- package/dist/wire/command-set.test.js +95 -0
- package/dist/wire/command.code.d.ts +5 -18
- package/dist/wire/command.code.js +23 -19
- package/dist/wire/command.utils.d.ts +0 -18
- package/dist/wire/command.utils.js +22 -19
- package/dist/wire/command.utils.test.d.ts +2 -0
- package/dist/wire/command.utils.test.js +35 -0
- package/dist/wire/consumer-group/create-group.command.d.ts +0 -18
- package/dist/wire/consumer-group/create-group.command.js +17 -18
- package/dist/wire/consumer-group/create-group.command.test.d.ts +0 -18
- package/dist/wire/consumer-group/create-group.command.test.js +17 -18
- package/dist/wire/consumer-group/delete-group.command.d.ts +4 -31
- package/dist/wire/consumer-group/delete-group.command.js +18 -19
- package/dist/wire/consumer-group/ensure-group.virtual.command.d.ts +0 -18
- package/dist/wire/consumer-group/ensure-group.virtual.command.js +17 -18
- package/dist/wire/consumer-group/get-group.command.d.ts +4 -32
- package/dist/wire/consumer-group/get-group.command.js +17 -18
- package/dist/wire/consumer-group/get-groups.command.d.ts +0 -18
- package/dist/wire/consumer-group/get-groups.command.js +17 -18
- package/dist/wire/consumer-group/group.command.test.d.ts +0 -18
- package/dist/wire/consumer-group/group.command.test.js +17 -18
- package/dist/wire/consumer-group/group.utils.d.ts +6 -18
- package/dist/wire/consumer-group/group.utils.js +17 -18
- package/dist/wire/consumer-group/index.d.ts +1 -18
- package/dist/wire/consumer-group/index.js +18 -18
- package/dist/wire/consumer-group/join-group.command.d.ts +4 -31
- package/dist/wire/consumer-group/join-group.command.js +18 -19
- package/dist/wire/consumer-group/leave-group.command.d.ts +4 -31
- package/dist/wire/consumer-group/leave-group.command.js +18 -19
- package/dist/wire/consumer-group/sync-group.command.d.ts +17 -0
- package/dist/wire/consumer-group/sync-group.command.js +45 -0
- package/dist/wire/consumer-group/sync-group.command.test.d.ts +2 -0
- package/dist/wire/consumer-group/sync-group.command.test.js +71 -0
- package/dist/wire/error.code.d.ts +0 -18
- package/dist/wire/error.code.js +27 -40
- package/dist/wire/error.code.test.d.ts +2 -0
- package/dist/wire/error.code.test.js +33 -0
- package/dist/wire/error.utils.d.ts +6 -19
- package/dist/wire/error.utils.js +30 -20
- package/dist/wire/identifier.utils.d.ts +0 -18
- package/dist/wire/identifier.utils.js +17 -18
- package/dist/wire/identifier.utils.test.d.ts +0 -18
- package/dist/wire/identifier.utils.test.js +17 -18
- package/dist/wire/index.d.ts +0 -18
- package/dist/wire/index.js +17 -18
- package/dist/wire/message/flush-unsaved-buffers.command.d.ts +0 -18
- package/dist/wire/message/flush-unsaved-buffers.command.js +17 -18
- package/dist/wire/message/header.type.d.ts +1 -19
- package/dist/wire/message/header.type.js +17 -18
- package/dist/wire/message/header.utils.d.ts +0 -18
- package/dist/wire/message/header.utils.js +17 -18
- package/dist/wire/message/header.utils.test.d.ts +0 -18
- package/dist/wire/message/header.utils.test.js +17 -18
- package/dist/wire/message/iggy-header.utils.d.ts +0 -18
- package/dist/wire/message/iggy-header.utils.js +17 -18
- package/dist/wire/message/index.d.ts +0 -18
- package/dist/wire/message/index.js +17 -18
- package/dist/wire/message/message.utils.d.ts +0 -18
- package/dist/wire/message/message.utils.js +17 -18
- package/dist/wire/message/partitioning.utils.d.ts +0 -18
- package/dist/wire/message/partitioning.utils.js +17 -18
- package/dist/wire/message/poll-messages.command.d.ts +5 -21
- package/dist/wire/message/poll-messages.command.js +168 -20
- package/dist/wire/message/poll-messages.command.test.d.ts +2 -0
- package/dist/wire/message/poll-messages.command.test.js +301 -0
- package/dist/wire/message/poll.utils.d.ts +0 -18
- package/dist/wire/message/poll.utils.js +17 -18
- package/dist/wire/message/send-messages.command.d.ts +0 -18
- package/dist/wire/message/send-messages.command.js +17 -18
- package/dist/wire/message/send-messages.command.test.d.ts +0 -18
- package/dist/wire/message/send-messages.command.test.js +17 -18
- package/dist/wire/number.utils.d.ts +0 -18
- package/dist/wire/number.utils.js +17 -18
- package/dist/wire/offset/delete-offset.command.d.ts +0 -18
- package/dist/wire/offset/delete-offset.command.js +17 -18
- package/dist/wire/offset/get-offset.command.d.ts +1 -19
- package/dist/wire/offset/get-offset.command.js +17 -18
- package/dist/wire/offset/index.d.ts +0 -18
- package/dist/wire/offset/index.js +17 -18
- package/dist/wire/offset/offset.utils.d.ts +2 -20
- package/dist/wire/offset/offset.utils.js +19 -20
- package/dist/wire/offset/store-offset.command.d.ts +1 -19
- package/dist/wire/offset/store-offset.command.js +17 -18
- package/dist/wire/partition/create-partition.command.d.ts +0 -18
- package/dist/wire/partition/create-partition.command.js +17 -18
- package/dist/wire/partition/delete-partition.command.d.ts +0 -18
- package/dist/wire/partition/delete-partition.command.js +17 -18
- package/dist/wire/partition/index.d.ts +0 -18
- package/dist/wire/partition/index.js +17 -18
- package/dist/wire/partition/partition.utils.d.ts +0 -18
- package/dist/wire/partition/partition.utils.js +17 -18
- package/dist/wire/partition/partition.utils.test.d.ts +0 -18
- package/dist/wire/partition/partition.utils.test.js +17 -18
- package/dist/wire/segment/delete-segments.command.d.ts +0 -18
- package/dist/wire/segment/delete-segments.command.js +17 -18
- package/dist/wire/segment/index.d.ts +0 -18
- package/dist/wire/segment/index.js +17 -18
- package/dist/wire/segment/segment.utils.d.ts +0 -18
- package/dist/wire/segment/segment.utils.js +17 -18
- package/dist/wire/serialize.utils.d.ts +0 -18
- package/dist/wire/serialize.utils.js +17 -18
- package/dist/wire/session/index.d.ts +0 -18
- package/dist/wire/session/index.js +17 -18
- package/dist/wire/session/login-with-token.command.d.ts +0 -18
- package/dist/wire/session/login-with-token.command.js +17 -18
- package/dist/wire/session/login-with-token.command.test.d.ts +0 -18
- package/dist/wire/session/login-with-token.command.test.js +17 -18
- package/dist/wire/session/login.command.d.ts +0 -18
- package/dist/wire/session/login.command.js +17 -18
- package/dist/wire/session/login.command.test.d.ts +0 -18
- package/dist/wire/session/login.command.test.js +17 -18
- package/dist/wire/session/login.utils.d.ts +0 -18
- package/dist/wire/session/login.utils.js +17 -18
- package/dist/wire/session/logout.command.d.ts +0 -18
- package/dist/wire/session/logout.command.js +17 -18
- package/dist/wire/stream/create-stream.command.d.ts +0 -18
- package/dist/wire/stream/create-stream.command.js +17 -18
- package/dist/wire/stream/create-stream.command.test.d.ts +0 -18
- package/dist/wire/stream/create-stream.command.test.js +17 -18
- package/dist/wire/stream/delete-stream.command.d.ts +0 -18
- package/dist/wire/stream/delete-stream.command.js +17 -18
- package/dist/wire/stream/ensure-stream.virtual.command.d.ts +0 -18
- package/dist/wire/stream/ensure-stream.virtual.command.js +17 -18
- package/dist/wire/stream/get-stream.command.d.ts +0 -18
- package/dist/wire/stream/get-stream.command.js +17 -18
- package/dist/wire/stream/get-streams.command.d.ts +0 -18
- package/dist/wire/stream/get-streams.command.js +17 -18
- package/dist/wire/stream/index.d.ts +0 -18
- package/dist/wire/stream/index.js +17 -18
- package/dist/wire/stream/purge-stream.command.d.ts +0 -18
- package/dist/wire/stream/purge-stream.command.js +17 -18
- package/dist/wire/stream/stream.utils.d.ts +0 -18
- package/dist/wire/stream/stream.utils.js +17 -18
- package/dist/wire/stream/update-stream.command.d.ts +0 -18
- package/dist/wire/stream/update-stream.command.js +17 -18
- package/dist/wire/system/get-stats.command.d.ts +0 -18
- package/dist/wire/system/get-stats.command.js +17 -18
- package/dist/wire/system/index.d.ts +0 -18
- package/dist/wire/system/index.js +17 -18
- package/dist/wire/system/ping.command.d.ts +0 -18
- package/dist/wire/system/ping.command.js +17 -18
- package/dist/wire/token/create-token.command.d.ts +0 -18
- package/dist/wire/token/create-token.command.js +17 -18
- package/dist/wire/token/create-token.command.test.d.ts +0 -18
- package/dist/wire/token/create-token.command.test.js +17 -18
- package/dist/wire/token/delete-token.command.d.ts +0 -18
- package/dist/wire/token/delete-token.command.js +17 -18
- package/dist/wire/token/delete-token.command.test.d.ts +0 -18
- package/dist/wire/token/delete-token.command.test.js +17 -18
- package/dist/wire/token/get-tokens.command.d.ts +0 -18
- package/dist/wire/token/get-tokens.command.js +17 -18
- package/dist/wire/token/index.d.ts +0 -18
- package/dist/wire/token/index.js +17 -18
- package/dist/wire/token/token.utils.d.ts +0 -18
- package/dist/wire/token/token.utils.js +17 -18
- package/dist/wire/topic/create-topic.command.d.ts +0 -18
- package/dist/wire/topic/create-topic.command.js +17 -18
- package/dist/wire/topic/create-topic.command.test.d.ts +0 -18
- package/dist/wire/topic/create-topic.command.test.js +17 -18
- package/dist/wire/topic/delete-topic.command.d.ts +0 -18
- package/dist/wire/topic/delete-topic.command.js +17 -18
- package/dist/wire/topic/ensure-topic.virtual.command.d.ts +0 -18
- package/dist/wire/topic/ensure-topic.virtual.command.js +17 -18
- package/dist/wire/topic/get-topic.command.d.ts +0 -18
- package/dist/wire/topic/get-topic.command.js +17 -18
- package/dist/wire/topic/get-topics.command.d.ts +0 -18
- package/dist/wire/topic/get-topics.command.js +17 -18
- package/dist/wire/topic/index.d.ts +0 -18
- package/dist/wire/topic/index.js +17 -18
- package/dist/wire/topic/purge-topic.command.d.ts +0 -18
- package/dist/wire/topic/purge-topic.command.js +17 -18
- package/dist/wire/topic/topic.utils.d.ts +0 -18
- package/dist/wire/topic/topic.utils.js +19 -20
- package/dist/wire/topic/topic.utils.test.d.ts +2 -0
- package/dist/wire/topic/topic.utils.test.js +42 -0
- package/dist/wire/topic/update-topic.command.d.ts +0 -18
- package/dist/wire/topic/update-topic.command.js +17 -18
- package/dist/wire/user/change-password.command.d.ts +0 -18
- package/dist/wire/user/change-password.command.js +17 -18
- package/dist/wire/user/create-user.command.d.ts +0 -18
- package/dist/wire/user/create-user.command.js +25 -21
- package/dist/wire/user/create-user.command.test.d.ts +0 -18
- package/dist/wire/user/create-user.command.test.js +45 -22
- package/dist/wire/user/delete-user.command.d.ts +0 -18
- package/dist/wire/user/delete-user.command.js +17 -18
- package/dist/wire/user/get-user.command.d.ts +0 -18
- package/dist/wire/user/get-user.command.js +17 -18
- package/dist/wire/user/get-users.command.d.ts +0 -18
- package/dist/wire/user/get-users.command.js +17 -18
- package/dist/wire/user/index.d.ts +0 -18
- package/dist/wire/user/index.js +17 -18
- package/dist/wire/user/permissions.utils.d.ts +2 -21
- package/dist/wire/user/permissions.utils.js +48 -48
- package/dist/wire/user/permissions.utils.test.d.ts +0 -18
- package/dist/wire/user/permissions.utils.test.js +106 -36
- package/dist/wire/user/update-permissions.command.d.ts +0 -18
- package/dist/wire/user/update-permissions.command.js +17 -18
- package/dist/wire/user/update-user.command.d.ts +0 -18
- package/dist/wire/user/update-user.command.js +17 -18
- package/dist/wire/user/user.utils.d.ts +0 -18
- package/dist/wire/user/user.utils.js +17 -18
- package/dist/wire/uuid.utils.d.ts +0 -18
- package/dist/wire/uuid.utils.js +17 -18
- package/dist/wire/vsr/header.d.ts +108 -0
- package/dist/wire/vsr/header.js +121 -0
- package/dist/wire/vsr/header.test.d.ts +2 -0
- package/dist/wire/vsr/header.test.js +75 -0
- package/dist/wire/vsr/index.d.ts +18 -0
- package/dist/wire/vsr/index.js +120 -0
- package/dist/wire/vsr/namespace.d.ts +19 -0
- package/dist/wire/vsr/namespace.js +177 -0
- package/dist/wire/vsr/namespace.test.d.ts +2 -0
- package/dist/wire/vsr/namespace.test.js +133 -0
- package/dist/wire/vsr/operation.d.ts +65 -0
- package/dist/wire/vsr/operation.js +144 -0
- package/dist/wire/vsr/operation.test.d.ts +2 -0
- package/dist/wire/vsr/operation.test.js +92 -0
- package/dist/wire/vsr/register.d.ts +27 -0
- package/dist/wire/vsr/register.js +90 -0
- package/dist/wire/vsr/register.test.d.ts +2 -0
- package/dist/wire/vsr/register.test.js +67 -0
- package/dist/wire/vsr/reply.d.ts +32 -0
- package/dist/wire/vsr/reply.js +151 -0
- package/dist/wire/vsr/reply.test.d.ts +2 -0
- package/dist/wire/vsr/reply.test.js +120 -0
- package/dist/wire/vsr/session.d.ts +38 -0
- package/dist/wire/vsr/session.js +105 -0
- package/dist/wire/vsr/session.test.d.ts +2 -0
- package/dist/wire/vsr/session.test.js +60 -0
- package/dist/wire/vsr/vsr.test.d.ts +2 -0
- package/dist/wire/vsr/vsr.test.js +72 -0
- package/package.json +14 -12
package/LICENSE
CHANGED
|
@@ -198,4 +198,4 @@
|
|
|
198
198
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
199
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
200
|
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -30,6 +30,66 @@ npm i --save apache-iggy
|
|
|
30
30
|
|
|
31
31
|
## basic usage
|
|
32
32
|
|
|
33
|
+
### Response frame limit
|
|
34
|
+
|
|
35
|
+
**Compatibility note:** response frames larger than `maxResponseFrameSize` (default 64 MiB) are now rejected and close the connection under both framing modes. This is a behavior change for existing classic-framing clients. Raise the limit in the client configuration when polling very large batches.
|
|
36
|
+
|
|
37
|
+
### VSR framing
|
|
38
|
+
|
|
39
|
+
Classic framing remains the default. Select VSR explicitly when connecting to
|
|
40
|
+
an Iggy VSR server:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { SimpleClient, getRawClient } from "apache-iggy";
|
|
44
|
+
|
|
45
|
+
const config = {
|
|
46
|
+
protocol: "vsr" as const,
|
|
47
|
+
transport: "TCP" as const,
|
|
48
|
+
options: { host: "127.0.0.1", port: 8090 },
|
|
49
|
+
credentials: { username: "iggy", password: "iggy" },
|
|
50
|
+
};
|
|
51
|
+
const client = new SimpleClient(getRawClient(config));
|
|
52
|
+
const stats = await client.system.getStats();
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
VSR is a runtime protocol choice in Node.js, not a build feature. Codes absent
|
|
56
|
+
from the SDK command table use `Operation::NonReplicated` and carry the command
|
|
57
|
+
code in the request header's reserved field. The server remains authoritative
|
|
58
|
+
for classifying or rejecting extension commands.
|
|
59
|
+
|
|
60
|
+
The same npm package supports both framing modes. VSR currently supports TCP
|
|
61
|
+
only and restricts `Client` to one pooled connection because authentication,
|
|
62
|
+
request sequencing, and consumer-group assignments belong to one consensus
|
|
63
|
+
session. Configurations requesting VSR over TLS or more than one pooled
|
|
64
|
+
connection fail before a socket is opened.
|
|
65
|
+
|
|
66
|
+
VSR authentication translates the existing password and personal-access-token
|
|
67
|
+
login APIs into the register handshake required by the consensus protocol. A
|
|
68
|
+
disconnect or eviction invalidates the session, and later work must register a
|
|
69
|
+
new session. Transient not-committed responses retry the exact encoded request
|
|
70
|
+
within one bounded deadline. A disconnected mutation is never replayed under a
|
|
71
|
+
new session.
|
|
72
|
+
|
|
73
|
+
When the server's `[heartbeat]` eviction is enabled, configure the client's `heartbeatInterval` below the server heartbeat interval. Client heartbeats are disabled when `heartbeatInterval` is unset.
|
|
74
|
+
|
|
75
|
+
`sendBinaryRequest(code, payload)` has the same signature under classic and VSR framing. Known replicated commands use their registered operation, while unknown codes reach the server as non-replicated requests and are rejected by servers that do not register them. Classic request bytes remain unchanged.
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { ResponseError } from "apache-iggy";
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
await client.sendBinaryRequest(60_000, Buffer.from("opaque request"));
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if (error instanceof ResponseError) {
|
|
84
|
+
console.error(error.commandCode, error.errorCode);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The client includes its npm package version and the binary protocol crate
|
|
90
|
+
version in VSR registration. An incompatible server rejects registration with
|
|
91
|
+
a protocol-version error instead of accepting a mismatched wire contract.
|
|
92
|
+
|
|
33
93
|
```ts
|
|
34
94
|
import { Client } from "apache-iggy";
|
|
35
95
|
|
|
@@ -60,7 +120,8 @@ npm run build
|
|
|
60
120
|
|
|
61
121
|
### test
|
|
62
122
|
|
|
63
|
-
note: use env var `IGGY_TCP_ADDRESS="host:port"` to set server
|
|
123
|
+
note: use env var `IGGY_TCP_ADDRESS="host:port"` to set the server
|
|
124
|
+
address for bdd and e2e tests.
|
|
64
125
|
|
|
65
126
|
#### unit tests
|
|
66
127
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ClientConfig, Protocol } from './client.type.js';
|
|
2
|
+
export declare const DEFAULT_MAX_RESPONSE_FRAME_SIZE: number;
|
|
3
|
+
export declare const normalizeClientConfig: (config: ClientConfig) => ClientConfig & {
|
|
4
|
+
protocol: Protocol;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=client.config.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
|
3
|
+
// distributed with this work for additional information
|
|
4
|
+
// regarding copyright ownership. The ASF licenses this file
|
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
|
6
|
+
// "License"); you may not use this file except in compliance
|
|
7
|
+
// with the License. You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the License is distributed on an
|
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
// KIND, either express or implied. See the License for the
|
|
15
|
+
// specific language governing permissions and limitations
|
|
16
|
+
// under the License.
|
|
17
|
+
export const DEFAULT_MAX_RESPONSE_FRAME_SIZE = 64 * 1024 * 1024;
|
|
18
|
+
const isProtocol = (value) => value === 'classic' || value === 'vsr';
|
|
19
|
+
export const normalizeClientConfig = (config) => {
|
|
20
|
+
const protocol = config.protocol ?? 'classic';
|
|
21
|
+
if (!isProtocol(protocol))
|
|
22
|
+
throw new TypeError(`unsupported wire protocol: ${String(protocol)}`);
|
|
23
|
+
const maxResponseFrameSize = config.maxResponseFrameSize ?? DEFAULT_MAX_RESPONSE_FRAME_SIZE;
|
|
24
|
+
if (!Number.isSafeInteger(maxResponseFrameSize) ||
|
|
25
|
+
maxResponseFrameSize < 256)
|
|
26
|
+
throw new TypeError('maxResponseFrameSize must be a safe integer of at least 256 bytes');
|
|
27
|
+
if (protocol === 'vsr' && config.transport === 'TLS')
|
|
28
|
+
throw new TypeError('VSR framing currently supports the TCP transport only');
|
|
29
|
+
if (protocol === 'vsr' &&
|
|
30
|
+
((config.poolSize?.min ?? 1) > 1 || (config.poolSize?.max ?? 1) > 1))
|
|
31
|
+
throw new TypeError('VSR clients currently support exactly one pooled connection');
|
|
32
|
+
return {
|
|
33
|
+
...config,
|
|
34
|
+
protocol,
|
|
35
|
+
options: { ...config.options },
|
|
36
|
+
maxResponseFrameSize,
|
|
37
|
+
...(protocol === 'vsr' ? { poolSize: { min: 1, max: 1 } } : {})
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=client.config.js.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
|
3
|
+
// distributed with this work for additional information
|
|
4
|
+
// regarding copyright ownership. The ASF licenses this file
|
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
|
6
|
+
// "License"); you may not use this file except in compliance
|
|
7
|
+
// with the License. You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
|
12
|
+
// software distributed under the License is distributed on an
|
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
// KIND, either express or implied. See the License for the
|
|
15
|
+
// specific language governing permissions and limitations
|
|
16
|
+
// under the License.
|
|
17
|
+
import assert from 'node:assert/strict';
|
|
18
|
+
import { describe, it } from 'node:test';
|
|
19
|
+
import { DEFAULT_MAX_RESPONSE_FRAME_SIZE, normalizeClientConfig } from './client.config.js';
|
|
20
|
+
const config = () => ({
|
|
21
|
+
transport: 'TCP',
|
|
22
|
+
options: { host: '127.0.0.1', port: 8090 },
|
|
23
|
+
credentials: { username: 'iggy', password: 'iggy' }
|
|
24
|
+
});
|
|
25
|
+
describe('normalizeClientConfig', () => {
|
|
26
|
+
it('defaults to classic without changing classic pool sizing', () => {
|
|
27
|
+
const normalized = normalizeClientConfig({
|
|
28
|
+
...config(),
|
|
29
|
+
poolSize: { min: 2, max: 4 }
|
|
30
|
+
});
|
|
31
|
+
assert.equal(normalized.protocol, 'classic');
|
|
32
|
+
assert.deepEqual(normalized.poolSize, { min: 2, max: 4 });
|
|
33
|
+
assert.equal(normalized.maxResponseFrameSize, DEFAULT_MAX_RESPONSE_FRAME_SIZE);
|
|
34
|
+
});
|
|
35
|
+
it('restricts VSR to one pooled connection', () => {
|
|
36
|
+
const normalized = normalizeClientConfig({
|
|
37
|
+
...config(),
|
|
38
|
+
protocol: 'vsr'
|
|
39
|
+
});
|
|
40
|
+
assert.deepEqual(normalized.poolSize, { min: 1, max: 1 });
|
|
41
|
+
assert.throws(() => normalizeClientConfig({
|
|
42
|
+
...config(),
|
|
43
|
+
protocol: 'vsr',
|
|
44
|
+
poolSize: { max: 2 }
|
|
45
|
+
}), /exactly one pooled connection/);
|
|
46
|
+
});
|
|
47
|
+
it('rejects invalid protocols before opening a socket', () => {
|
|
48
|
+
assert.throws(() => normalizeClientConfig({
|
|
49
|
+
...config(),
|
|
50
|
+
protocol: 'auto'
|
|
51
|
+
}), /unsupported wire protocol/);
|
|
52
|
+
});
|
|
53
|
+
it('rejects VSR over an untested TLS transport', () => {
|
|
54
|
+
assert.throws(() => normalizeClientConfig({
|
|
55
|
+
...config(),
|
|
56
|
+
protocol: 'vsr',
|
|
57
|
+
transport: 'TLS'
|
|
58
|
+
}), /TCP transport only/);
|
|
59
|
+
});
|
|
60
|
+
it('rejects unsafe response frame limits', () => {
|
|
61
|
+
for (const maxResponseFrameSize of [0, 255, 1.5, Number.MAX_VALUE])
|
|
62
|
+
assert.throws(() => normalizeClientConfig({
|
|
63
|
+
...config(),
|
|
64
|
+
maxResponseFrameSize
|
|
65
|
+
}), /maxResponseFrameSize/);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=client.config.test.js.map
|
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
1
|
import { EventEmitter } from 'node:events';
|
|
20
2
|
import type { Socket } from 'node:net';
|
|
21
3
|
import type { ClientConfig } from "./client.type.js";
|
|
@@ -34,34 +16,54 @@ export declare class IggyConnection extends EventEmitter {
|
|
|
34
16
|
connecting: boolean;
|
|
35
17
|
/** Whether the connection is being intentionally closed */
|
|
36
18
|
ending: boolean;
|
|
37
|
-
/** Whether waiting for more data to complete a response */
|
|
38
|
-
private waitingResponseEnd;
|
|
39
19
|
/** Reconnection configuration */
|
|
40
20
|
private reconnectOption;
|
|
41
21
|
/** Number of reconnection attempts made */
|
|
42
22
|
private reconnectCount;
|
|
43
|
-
/**
|
|
44
|
-
private
|
|
23
|
+
/** Shared promise for concurrent callers waiting on one connection attempt */
|
|
24
|
+
private connectPromise?;
|
|
25
|
+
/** Shared promise for callers waiting on automatic reconnection */
|
|
26
|
+
private reconnectPromise?;
|
|
27
|
+
/** Endpoint the client was configured with, kept across leader redirects */
|
|
28
|
+
private readonly seedOptions;
|
|
29
|
+
/** Incremental response frame decoder */
|
|
30
|
+
private responseDecoder;
|
|
45
31
|
/**
|
|
46
32
|
* Creates a new IggyConnection.
|
|
47
33
|
*
|
|
48
34
|
* @param config - Client configuration
|
|
49
35
|
*/
|
|
50
36
|
constructor(config: ClientConfig);
|
|
37
|
+
/**
|
|
38
|
+
* Attaches the lifecycle listeners exactly once per socket instance.
|
|
39
|
+
* Attaching them in `connect()` would stack duplicate handlers whenever a
|
|
40
|
+
* failed attempt is retried on the same socket.
|
|
41
|
+
*/
|
|
42
|
+
private _installSocket;
|
|
51
43
|
/**
|
|
52
44
|
* Establishes the connection to the server.
|
|
53
|
-
* Sets up event handlers for data, errors, and disconnection.
|
|
54
45
|
*
|
|
55
46
|
* @returns Promise that resolves when connected
|
|
56
47
|
*/
|
|
57
|
-
connect(): Promise<
|
|
48
|
+
connect(): Promise<this>;
|
|
49
|
+
private _waitForConnection;
|
|
58
50
|
/**
|
|
59
51
|
* Attempts to reconnect to the server.
|
|
60
52
|
* Respects maxRetries limit and emits error when exceeded.
|
|
61
53
|
*
|
|
62
54
|
* @param err - Optional error that triggered the reconnection
|
|
63
55
|
*/
|
|
64
|
-
reconnect(err?: Error): Promise<
|
|
56
|
+
reconnect(err?: Error): Promise<this | undefined>;
|
|
57
|
+
private _reconnectUntilConnected;
|
|
58
|
+
/**
|
|
59
|
+
* Alternates reconnect dials between the current endpoint and the
|
|
60
|
+
* configured seed. After a leader redirect the current endpoint may die
|
|
61
|
+
* with the leader, and the seed is the way back to the rest of the cluster.
|
|
62
|
+
*/
|
|
63
|
+
private _reconnectTarget;
|
|
64
|
+
redirect(host: string, port: number): Promise<void>;
|
|
65
|
+
abort(): void;
|
|
66
|
+
isConnectedTo(host: string, port: number): boolean;
|
|
65
67
|
/**
|
|
66
68
|
* Destroys the connection and marks it as ending.
|
|
67
69
|
*/
|
|
@@ -84,6 +86,7 @@ export declare class IggyConnection extends EventEmitter {
|
|
|
84
86
|
* @param payload - Command payload
|
|
85
87
|
* @returns True if the write was successful
|
|
86
88
|
*/
|
|
87
|
-
writeCommand(command: number, payload: Buffer):
|
|
89
|
+
writeCommand(command: number, payload: Buffer): void;
|
|
90
|
+
writeFrame(frame: Buffer): void;
|
|
88
91
|
}
|
|
89
92
|
//# sourceMappingURL=client.connection.d.ts.map
|