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.
Files changed (157) hide show
  1. package/README.md +248 -28
  2. package/dist/client/client.config.d.ts +2 -0
  3. package/dist/client/client.config.js +13 -2
  4. package/dist/client/client.config.test.js +15 -2
  5. package/dist/client/client.connection-string.js +13 -1
  6. package/dist/client/client.connection-string.test.js +43 -1
  7. package/dist/client/client.connection.d.ts +33 -135
  8. package/dist/client/client.connection.js +190 -453
  9. package/dist/client/client.connection.test.js +244 -669
  10. package/dist/client/client.d.ts +4 -35
  11. package/dist/client/client.js +8 -101
  12. package/dist/client/client.operation.d.ts +120 -0
  13. package/dist/client/client.operation.js +428 -0
  14. package/dist/client/client.operation.test.d.ts +2 -0
  15. package/dist/client/client.operation.test.js +285 -0
  16. package/dist/client/client.socket.d.ts +92 -209
  17. package/dist/client/client.socket.js +1205 -981
  18. package/dist/client/client.socket.test.js +4865 -679
  19. package/dist/client/client.type.d.ts +65 -22
  20. package/dist/client/index.d.ts +1 -0
  21. package/dist/client/index.js +1 -0
  22. package/dist/client.e2e.js +3 -5
  23. package/dist/e2e/resource-options.e2e.d.ts +2 -0
  24. package/dist/{wire/stream/purge-stream.command.js → e2e/resource-options.e2e.js} +12 -20
  25. package/dist/e2e/resource-options.suite.d.ts +15 -0
  26. package/dist/e2e/resource-options.suite.js +272 -0
  27. package/dist/e2e/tcp.cluster.e2e.js +1 -0
  28. package/dist/e2e/tcp.consumer-stream.e2e.js +4 -0
  29. package/dist/e2e/tcp.parallel.e2e.js +5 -6
  30. package/dist/e2e/tcp.stream.e2e.js +0 -3
  31. package/dist/e2e/tcp.system.e2e.js +10 -1
  32. package/dist/e2e/tcp.token.e2e.js +8 -2
  33. package/dist/e2e/tcp.topic.e2e.js +0 -3
  34. package/dist/e2e/tcp.user.e2e.js +46 -3
  35. package/dist/e2e/tls.system.e2e.js +21 -12
  36. package/dist/index.d.ts +2 -1
  37. package/dist/index.js +1 -1
  38. package/dist/stream/consumer-stream.js +97 -12
  39. package/dist/wire/cluster/cluster.type.d.ts +2 -2
  40. package/dist/wire/cluster/cluster.utils.d.ts +1 -0
  41. package/dist/wire/cluster/cluster.utils.js +4 -1
  42. package/dist/wire/command-set.d.ts +8 -8
  43. package/dist/wire/command-set.js +18 -9
  44. package/dist/wire/command.code.d.ts +3 -10
  45. package/dist/wire/command.code.js +9 -11
  46. package/dist/wire/command.utils.d.ts +3 -2
  47. package/dist/wire/command.utils.js +3 -2
  48. package/dist/wire/error.code.js +17 -1
  49. package/dist/wire/error.code.test.js +28 -1
  50. package/dist/wire/error.utils.d.ts +4 -2
  51. package/dist/wire/error.utils.js +6 -3
  52. package/dist/wire/identifier.utils.d.ts +2 -0
  53. package/dist/wire/identifier.utils.js +2 -0
  54. package/dist/wire/index.d.ts +1 -0
  55. package/dist/wire/index.js +1 -0
  56. package/dist/wire/message/header.type.d.ts +1 -1
  57. package/dist/wire/message/message-batch.test.js +11 -5
  58. package/dist/wire/message/message.utils.d.ts +0 -10
  59. package/dist/wire/message/message.utils.js +1 -22
  60. package/dist/wire/message/poll-messages.command.d.ts +12 -1
  61. package/dist/wire/message/poll-messages.command.js +64 -16
  62. package/dist/wire/message/poll-messages.command.test.js +143 -5
  63. package/dist/wire/message/poll.utils.d.ts +4 -0
  64. package/dist/wire/message/poll.utils.js +6 -1
  65. package/dist/wire/message/send-messages.command.d.ts +3 -3
  66. package/dist/wire/message/send-messages.command.js +103 -3
  67. package/dist/wire/message/send-messages.command.test.js +113 -2
  68. package/dist/wire/offset/delete-offset.command.d.ts +11 -4
  69. package/dist/wire/offset/delete-offset.command.js +1 -1
  70. package/dist/wire/offset/get-offset.command.d.ts +1 -1
  71. package/dist/wire/offset/offset-write.command.test.d.ts +2 -0
  72. package/dist/wire/offset/offset-write.command.test.js +43 -0
  73. package/dist/wire/offset/offset.utils.js +10 -6
  74. package/dist/wire/offset/store-offset.command.d.ts +10 -0
  75. package/dist/wire/offset/store-offset.command.js +1 -1
  76. package/dist/wire/options.utils.d.ts +46 -0
  77. package/dist/wire/options.utils.js +57 -0
  78. package/dist/wire/partition/partition-route.d.ts +12 -0
  79. package/dist/wire/partition/partition-route.js +40 -0
  80. package/dist/wire/partition/partition-route.test.d.ts +2 -0
  81. package/dist/wire/partition/partition-route.test.js +42 -0
  82. package/dist/wire/session/login-with-token.command.d.ts +2 -2
  83. package/dist/wire/session/login-with-token.command.js +7 -2
  84. package/dist/wire/session/login.command.d.ts +2 -2
  85. package/dist/wire/session/login.command.js +7 -2
  86. package/dist/wire/stream/create-stream.command.d.ts +5 -2
  87. package/dist/wire/stream/create-stream.command.js +20 -2
  88. package/dist/wire/stream/index.d.ts +1 -1
  89. package/dist/wire/stream/index.js +1 -1
  90. package/dist/wire/stream/stream-options.d.ts +77 -0
  91. package/dist/wire/stream/stream-options.js +101 -0
  92. package/dist/wire/stream/stream-options.test.d.ts +2 -0
  93. package/dist/wire/stream/stream-options.test.js +103 -0
  94. package/dist/wire/stream/stream.utils.d.ts +9 -0
  95. package/dist/wire/stream/stream.utils.js +17 -3
  96. package/dist/wire/stream/update-stream.command.d.ts +23 -5
  97. package/dist/wire/stream/update-stream.command.js +10 -17
  98. package/dist/wire/system/describe-options.command.d.ts +23 -6
  99. package/dist/wire/system/describe-options.command.js +21 -2
  100. package/dist/wire/system/get-stats.command.d.ts +17 -0
  101. package/dist/wire/system/get-stats.command.js +69 -16
  102. package/dist/wire/system/get-stats.command.test.d.ts +2 -0
  103. package/dist/wire/system/get-stats.command.test.js +97 -0
  104. package/dist/wire/system/index.d.ts +2 -0
  105. package/dist/wire/system/index.js +2 -0
  106. package/dist/wire/system/snapshot.command.d.ts +64 -0
  107. package/dist/wire/system/snapshot.command.js +76 -0
  108. package/dist/wire/system/snapshot.command.test.d.ts +2 -0
  109. package/dist/wire/system/snapshot.command.test.js +86 -0
  110. package/dist/wire/system/update-resource.command.d.ts +53 -0
  111. package/dist/wire/system/update-resource.command.js +130 -0
  112. package/dist/wire/system/update-resource.command.test.d.ts +2 -0
  113. package/dist/wire/system/update-resource.command.test.js +497 -0
  114. package/dist/wire/token/create-token.command.d.ts +1 -1
  115. package/dist/wire/token/create-token.command.js +1 -1
  116. package/dist/wire/token/create-token.command.test.js +6 -0
  117. package/dist/wire/topic/create-topic.command.d.ts +20 -12
  118. package/dist/wire/topic/create-topic.command.js +11 -4
  119. package/dist/wire/topic/index.d.ts +1 -2
  120. package/dist/wire/topic/index.js +1 -2
  121. package/dist/wire/topic/topic.utils.d.ts +14 -5
  122. package/dist/wire/topic/topic.utils.js +26 -11
  123. package/dist/wire/topic/topic.utils.test.js +13 -13
  124. package/dist/wire/topic/update-topic.command.d.ts +22 -15
  125. package/dist/wire/topic/update-topic.command.js +12 -34
  126. package/dist/wire/user/create-user.command.d.ts +12 -2
  127. package/dist/wire/user/create-user.command.js +7 -3
  128. package/dist/wire/user/index.d.ts +1 -0
  129. package/dist/wire/user/index.js +1 -0
  130. package/dist/wire/user/update-user.command.d.ts +25 -7
  131. package/dist/wire/user/update-user.command.js +18 -31
  132. package/dist/wire/user/user.utils.d.ts +2 -0
  133. package/dist/wire/user/user.utils.js +5 -3
  134. package/dist/wire/vsr/header.d.ts +23 -8
  135. package/dist/wire/vsr/header.js +32 -10
  136. package/dist/wire/vsr/header.test.js +5 -1
  137. package/dist/wire/vsr/index.d.ts +8 -2
  138. package/dist/wire/vsr/index.js +44 -11
  139. package/dist/wire/vsr/operation.d.ts +18 -6
  140. package/dist/wire/vsr/operation.js +46 -16
  141. package/dist/wire/vsr/operation.test.js +32 -8
  142. package/dist/wire/vsr/register.d.ts +10 -6
  143. package/dist/wire/vsr/register.js +24 -7
  144. package/dist/wire/vsr/register.test.js +28 -8
  145. package/dist/wire/vsr/reply.d.ts +4 -1
  146. package/dist/wire/vsr/reply.js +42 -7
  147. package/dist/wire/vsr/reply.test.js +11 -1
  148. package/dist/wire/vsr/session.d.ts +9 -10
  149. package/dist/wire/vsr/session.js +32 -23
  150. package/dist/wire/vsr/session.test.js +33 -7
  151. package/dist/wire/vsr/vsr.test.js +57 -6
  152. package/package.json +6 -7
  153. package/dist/wire/message/flush-unsaved-buffers.command.d.ts +0 -26
  154. package/dist/wire/message/flush-unsaved-buffers.command.js +0 -36
  155. package/dist/wire/stream/purge-stream.command.d.ts +0 -22
  156. package/dist/wire/topic/purge-topic.command.d.ts +0 -24
  157. package/dist/wire/topic/purge-topic.command.js +0 -39
@@ -1,43 +1,12 @@
1
- import { type Pool } from 'generic-pool';
2
- import type { RawClient, ClientConfig, ClientConfigOrString } from "./client.type.js";
1
+ import type { RawClient, ClientConfig, ClientConfigOrString } from './client.type.js';
3
2
  import { CommandAPI } from '../wire/command-set.js';
4
- /**
5
- * Iggy client with connection pooling support.
6
- * Manages a pool of connections for efficient resource utilization.
7
- */
3
+ /** Every facade call shares one session and its independently multiplexed replica links. */
8
4
  export declare class Client extends CommandAPI {
9
- /** Client configuration */
10
- _config: ClientConfig;
11
- /** Connection pool instance */
12
- _pool: Pool<RawClient>;
13
- /**
14
- * Creates a new pooled client.
15
- *
16
- * @param config - Client configuration or connection string
17
- */
5
+ readonly _config: ClientConfig;
18
6
  constructor(config: ClientConfigOrString);
19
- /**
20
- * Destroys the client and drains all connections from the pool.
21
- */
22
7
  destroy(): Promise<void>;
23
8
  }
24
- /**
25
- * Iggy client that uses a single persistent connection.
26
- * Suitable for applications that don't need connection pooling.
27
- */
28
- export declare class SingleClient extends CommandAPI {
29
- /** Client configuration */
30
- _config: ClientConfig;
31
- /**
32
- * Creates a new single-connection client.
33
- *
34
- * @param config - Client configuration or connection string
35
- */
36
- constructor(config: ClientConfigOrString);
37
- /**
38
- * Destroys the client connection.
39
- */
40
- destroy(): Promise<void>;
9
+ export declare class SingleClient extends Client {
41
10
  }
42
11
  /**
43
12
  * Simple Iggy client wrapper around an existing RawClient.
@@ -14,116 +14,23 @@
14
14
  // KIND, either express or implied. See the License for the
15
15
  // specific language governing permissions and limitations
16
16
  // under the License.
17
- import { createPool } from 'generic-pool';
18
- import { getRawClient } from '../client/client.socket.js';
17
+ import { getRawClient } from './client.socket.js';
19
18
  import { CommandAPI } from '../wire/command-set.js';
20
- import { debug } from './client.debug.js';
21
19
  import { normalizeClientConfig } from './client.config.js';
22
- /**
23
- * Creates a client provider that uses connection pooling.
24
- * Automatically acquires and releases clients from the pool.
25
- *
26
- * @param config - Client configuration including pool size options
27
- * @returns Client provider and its connection pool
28
- */
29
- const createPooledClientProvider = (config) => {
30
- // Constructed eagerly rather than inside the factory: generic-pool never
31
- // rejects waiting acquires when a create fails, and keeps re-dispatching
32
- // the doomed factory, which hangs every command. Normalization already
33
- // pins this pool to exactly one pooled connection, so there is nothing
34
- // lazy to preserve.
35
- const client = getRawClient(config);
36
- const minPoolSize = config.poolSize?.min || 1;
37
- const maxPoolSize = config.poolSize?.max || 4;
38
- const pool = createPool({
39
- create: async function () {
40
- return client;
41
- },
42
- destroy: async function () {
43
- return client.destroy();
44
- }
45
- }, {
46
- min: minPoolSize,
47
- max: maxPoolSize
48
- });
49
- const clientProvider = async () => {
50
- const pooled = await pool.acquire();
51
- debug('client acquired from pool. pool size is', pool.size);
52
- pooled.once('finishQueue', () => {
53
- pool.release(pooled);
54
- debug('client released to pool. pool size is', pool.size);
55
- });
56
- return pooled;
57
- };
58
- return { clientProvider, pool };
59
- };
60
- /**
61
- * Iggy client with connection pooling support.
62
- * Manages a pool of connections for efficient resource utilization.
63
- */
20
+ /** Every facade call shares one session and its independently multiplexed replica links. */
64
21
  export class Client extends CommandAPI {
65
- /** Client configuration */
66
22
  _config;
67
- /** Connection pool instance */
68
- _pool;
69
- /**
70
- * Creates a new pooled client.
71
- *
72
- * @param config - Client configuration or connection string
73
- */
74
23
  constructor(config) {
75
- const normalizedConfig = normalizeClientConfig(config);
76
- const { clientProvider, pool } = createPooledClientProvider(normalizedConfig);
77
- super(clientProvider);
78
- this._config = normalizedConfig;
79
- this._pool = pool;
24
+ const normalized = normalizeClientConfig(config);
25
+ const client = getRawClient(normalized);
26
+ super(async () => client);
27
+ this._config = normalized;
80
28
  }
81
- /**
82
- * Destroys the client and drains all connections from the pool.
83
- */
84
29
  async destroy() {
85
- debug('destroying client pool. pool size is', this._pool.size);
86
- await this._pool.drain();
87
- await this._pool.clear();
88
- debug('destroyed client pool. pool size is', this._pool.size);
30
+ (await this.clientProvider()).destroy();
89
31
  }
90
32
  }
91
- /**
92
- * Creates a client provider that reuses a single connection.
93
- *
94
- * @param config - Client configuration
95
- * @returns Client provider function that always returns the same client
96
- */
97
- const createSingleClientProvider = (config) => {
98
- const client = getRawClient(config);
99
- return async function clientProvider() {
100
- return client;
101
- };
102
- };
103
- /**
104
- * Iggy client that uses a single persistent connection.
105
- * Suitable for applications that don't need connection pooling.
106
- */
107
- export class SingleClient extends CommandAPI {
108
- /** Client configuration */
109
- _config;
110
- /**
111
- * Creates a new single-connection client.
112
- *
113
- * @param config - Client configuration or connection string
114
- */
115
- constructor(config) {
116
- const normalizedConfig = normalizeClientConfig(config);
117
- super(createSingleClientProvider(normalizedConfig));
118
- this._config = normalizedConfig;
119
- }
120
- /**
121
- * Destroys the client connection.
122
- */
123
- async destroy() {
124
- const client = await this.clientProvider();
125
- client.destroy();
126
- }
33
+ export class SingleClient extends Client {
127
34
  }
128
35
  /**
129
36
  * Simple Iggy client wrapper around an existing RawClient.
@@ -0,0 +1,120 @@
1
+ import { type PartitionContext } from '../wire/vsr/header.js';
2
+ import type { VsrSession } from '../wire/vsr/index.js';
3
+ export declare const OPERATION_TIMEOUT_MS = 30000;
4
+ export declare class OperationUncertainError extends Error {
5
+ readonly operationId: bigint | undefined;
6
+ constructor(operationId: bigint | undefined, cause: unknown);
7
+ }
8
+ export declare class LaneBlockedError extends Error {
9
+ readonly operationId: bigint;
10
+ constructor(operationId: bigint);
11
+ }
12
+ /**
13
+ * The client has neither the operation nor a proved outcome for it, so the
14
+ * outcome can still be unknown. A session reset or an abandon came before a
15
+ * replay proved the outcome, or the proved outcome aged out.
16
+ */
17
+ export declare class OperationNotRetainedError extends Error {
18
+ readonly operationId: bigint;
19
+ constructor(operationId: bigint);
20
+ }
21
+ export declare class VsrResponseTimeoutError extends Error {
22
+ constructor(timeout: number);
23
+ }
24
+ /**
25
+ * Every replica link used its retry budget, or no endpoint accepted a dial.
26
+ * The client connects again on its own: each heartbeat restarts a link with a
27
+ * fresh budget, and the next call dials again.
28
+ */
29
+ export declare class NotConnectedError extends Error {
30
+ constructor(cause?: unknown);
31
+ }
32
+ export declare const waitWithin: <T>(pending: Promise<T>, deadline: number, signal?: AbortSignal) => Promise<T>;
33
+ export declare const pause: (milliseconds: number, signal?: AbortSignal, background?: boolean) => Promise<void>;
34
+ export declare class ChangeSignal {
35
+ private resolve;
36
+ promise: Promise<void>;
37
+ private next;
38
+ pulse(): void;
39
+ }
40
+ export declare class PermitPool {
41
+ private readonly capacity;
42
+ private active;
43
+ private readonly waiting;
44
+ constructor(capacity: number);
45
+ acquire(deadline: number, signal: AbortSignal): Promise<() => void>;
46
+ private release;
47
+ }
48
+ /** Writer aliases pin physical bytes after logical completion or abandonment. */
49
+ export declare class FrozenFrame {
50
+ private bytes;
51
+ private readonly released;
52
+ private references;
53
+ private ownerReleased;
54
+ constructor(bytes: Buffer | undefined, released: () => void);
55
+ get buffer(): Buffer;
56
+ retain(): void;
57
+ release(): void;
58
+ releaseOwner(): void;
59
+ }
60
+ export type ClientOperation = {
61
+ readonly lane: string;
62
+ readonly command: number;
63
+ context: PartitionContext;
64
+ frame: FrozenFrame;
65
+ id: bigint;
66
+ readonly retainable: boolean;
67
+ readonly lifetime: AbortController;
68
+ resolving: boolean;
69
+ retained: boolean;
70
+ uncertain: boolean;
71
+ /** An abandon frees the slot of a running replay before the replay ends. */
72
+ holdsSlot: boolean;
73
+ };
74
+ export declare class MutationLanes {
75
+ private readonly maxOperations;
76
+ private readonly maxBytes;
77
+ private readonly lanes;
78
+ private readonly operations;
79
+ /**
80
+ * The outcomes that replays proved, oldest first: the committed rejection,
81
+ * or `undefined` for a committed success. A reset keeps them, because
82
+ * operation ids never repeat within a client.
83
+ */
84
+ private readonly proved;
85
+ private readonly waiting;
86
+ private readonly capacityWaiting;
87
+ private readonly changed;
88
+ private count;
89
+ private bytes;
90
+ constructor(maxOperations: number, maxBytes: number);
91
+ enter(lane: string, command: number, body: Buffer, context: PartitionContext, retainable: boolean, session: VsrSession, deadline: number, signal: AbortSignal): Promise<ClientOperation>;
92
+ restart(operation: ClientOperation, body: Buffer, context: PartitionContext, session: VsrSession, deadline: number, signal: AbortSignal): Promise<void>;
93
+ private freeze;
94
+ throwIfRetained(lane: string): void;
95
+ retained(id: bigint): ClientOperation;
96
+ owns(operation: ClientOperation): boolean;
97
+ retain(operation: ClientOperation): void;
98
+ /** Completes a call that proved its outcome. A replay keeps the outcome for a later resolve. */
99
+ prove(operation: ClientOperation, rejection?: unknown): void;
100
+ /** Returns or throws the outcome that a replay proved for `id`. */
101
+ provedOutcome(id: bigint): void;
102
+ /**
103
+ * Drops the retained operation `id`, whose outcome stays unknown, and frees
104
+ * its slot. A running replay keeps the lane until it ends, so the lane stays
105
+ * FIFO.
106
+ */
107
+ abandon(id: bigint): void;
108
+ complete(operation: ClientOperation): void;
109
+ /**
110
+ * Drops the retained operations and ends their replays, because no other
111
+ * session can replay their frames. A call keeps the lane it holds and starts
112
+ * again under the next session, so the calls in a lane keep their order.
113
+ */
114
+ reset(): void;
115
+ private releaseSlot;
116
+ private wakeLane;
117
+ private wakeWaiting;
118
+ acquireResolution(operation: ClientOperation, deadline: number, signal: AbortSignal): Promise<() => void>;
119
+ }
120
+ //# sourceMappingURL=client.operation.d.ts.map