@platformatic/kafka 1.31.0 → 1.32.1
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/dist/clients/producer/index.d.ts +1 -0
- package/dist/clients/producer/index.js +1 -0
- package/dist/clients/producer/partitioners.d.ts +3 -0
- package/dist/clients/producer/partitioners.js +8 -0
- package/dist/clients/producer/producer.js +6 -4
- package/dist/clients/producer/types.d.ts +1 -1
- package/dist/protocol/sasl/scram-sha.js +9 -2
- package/dist/typescript-4/dist/clients/producer/index.d.ts +1 -0
- package/dist/typescript-4/dist/clients/producer/partitioners.d.ts +3 -0
- package/dist/typescript-4/dist/clients/producer/types.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type MessageToProduce } from '../../protocol/records.ts';
|
|
2
|
+
export declare function defaultPartitioner<Key = Buffer, Value = Buffer, HeaderKey = Buffer, HeaderValue = Buffer>(_: MessageToProduce<Key, Value, HeaderKey, HeaderValue>, key?: Buffer | undefined): number;
|
|
3
|
+
export declare function compatibilityPartitioner<Key = Buffer, Value = Buffer, HeaderKey = Buffer, HeaderValue = Buffer>(_: MessageToProduce<Key, Value, HeaderKey, HeaderValue>, key?: Buffer | undefined): number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { murmur2 } from "../../protocol/murmur2.js";
|
|
2
|
+
const compatibilityMurmur2Mask = 0x7fffffff;
|
|
3
|
+
export function defaultPartitioner(_, key) {
|
|
4
|
+
return Buffer.isBuffer(key) ? murmur2(key) >>> 0 : 0;
|
|
5
|
+
}
|
|
6
|
+
export function compatibilityPartitioner(_, key) {
|
|
7
|
+
return Buffer.isBuffer(key) ? murmur2(key) & compatibilityMurmur2Mask : 0;
|
|
8
|
+
}
|
|
@@ -3,13 +3,13 @@ import { createPromisifiedCallback, kCallbackPromise, runConcurrentCallbacks } f
|
|
|
3
3
|
import { FindCoordinatorKeyTypes, ProduceAcks } from "../../apis/enumerations.js";
|
|
4
4
|
import { createDiagnosticContext, producerInitIdempotentChannel, producerSendsChannel, producerTransactionsChannel } from "../../diagnostic.js";
|
|
5
5
|
import { GenericError, UserError } from "../../errors.js";
|
|
6
|
-
import { murmur2 } from "../../protocol/murmur2.js";
|
|
7
6
|
import { runAsyncSeries } from "../../registries/abstract.js";
|
|
8
7
|
import { kInstance, kTransaction, kTransactionAddOffsets, kTransactionAddPartitions, kTransactionCancel, kTransactionCommitOffset, kTransactionEnd, kTransactionFindCoordinator, kTransactionPrepare } from "../../symbols.js";
|
|
9
8
|
import { emitExperimentalApiWarning, NumericMap } from "../../utils.js";
|
|
10
9
|
import { Base, kAfterCreate, kCheckNotClosed, kClosed, kGetApi, kGetBootstrapConnection, kGetConnection, kMetadata, kOptions, kPerformDeduplicated, kPerformWithRetry, kPrometheus, kValidateOptions } from "../base/base.js";
|
|
11
10
|
import { ensureMetric } from "../metrics.js";
|
|
12
11
|
import { produceOptionsValidator, producerOptionsValidator, producerStreamOptionsValidator, sendOptionsValidator } from "./options.js";
|
|
12
|
+
import { defaultPartitioner } from "./partitioners.js";
|
|
13
13
|
import { ProducerStream } from "./producer-stream.js";
|
|
14
14
|
import { Transaction } from "./transaction.js";
|
|
15
15
|
// Don't move this function as being in the same file will enable V8 to remove.
|
|
@@ -36,7 +36,9 @@ export class Producer extends Base {
|
|
|
36
36
|
if (options.idempotent) {
|
|
37
37
|
options.maxInflights = 1;
|
|
38
38
|
options.acks = ProduceAcks.ALL;
|
|
39
|
-
options.retries
|
|
39
|
+
if (options.retries === undefined || (typeof options.retries === 'number' && options.retries <= 1)) {
|
|
40
|
+
options.retries = Number.MAX_SAFE_INTEGER;
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
43
|
else {
|
|
42
44
|
options.idempotent = false;
|
|
@@ -534,10 +536,10 @@ export class Producer extends Base {
|
|
|
534
536
|
let partition = 0;
|
|
535
537
|
if (typeof message.partition !== 'number') {
|
|
536
538
|
if (partitioner) {
|
|
537
|
-
partition = partitioner(message);
|
|
539
|
+
partition = partitioner(message, key);
|
|
538
540
|
}
|
|
539
541
|
else if (key) {
|
|
540
|
-
partition =
|
|
542
|
+
partition = defaultPartitioner(message, key);
|
|
541
543
|
}
|
|
542
544
|
else {
|
|
543
545
|
// Use the roundrobin
|
|
@@ -12,7 +12,7 @@ export interface ProduceResult {
|
|
|
12
12
|
offsets?: TopicWithPartitionAndOffset[];
|
|
13
13
|
unwritableNodes?: number[];
|
|
14
14
|
}
|
|
15
|
-
export type Partitioner<Key, Value, HeaderKey, HeaderValue> = (message: MessageToProduce<Key, Value, HeaderKey, HeaderValue
|
|
15
|
+
export type Partitioner<Key, Value, HeaderKey, HeaderValue> = (message: MessageToProduce<Key, Value, HeaderKey, HeaderValue>, key?: Buffer | undefined) => number;
|
|
16
16
|
export interface ProducerStreamReport {
|
|
17
17
|
batchId: number;
|
|
18
18
|
count: number;
|
|
@@ -7,7 +7,7 @@ const GS2_HEADER = 'n,,';
|
|
|
7
7
|
const GS2_HEADER_BASE64 = Buffer.from(GS2_HEADER).toString('base64');
|
|
8
8
|
const HMAC_CLIENT_KEY = 'Client Key';
|
|
9
9
|
const HMAC_SERVER_KEY = 'Server Key';
|
|
10
|
-
const PARAMETERS_PARSER = /([^=]+)=(
|
|
10
|
+
const PARAMETERS_PARSER = /([^=]+)=([^,]*)/;
|
|
11
11
|
export const ScramAlgorithms = {
|
|
12
12
|
'SHA-256': {
|
|
13
13
|
id: 'SHA-256',
|
|
@@ -30,9 +30,16 @@ export function sanitizeString(str) {
|
|
|
30
30
|
}
|
|
31
31
|
export function parseParameters(data) {
|
|
32
32
|
const original = data.toString('utf-8');
|
|
33
|
+
const parsed = original.split(',').map(parameter => {
|
|
34
|
+
const match = parameter.match(PARAMETERS_PARSER);
|
|
35
|
+
if (!match) {
|
|
36
|
+
throw new AuthenticationError(`Malformed SCRAM parameter: ${parameter}`);
|
|
37
|
+
}
|
|
38
|
+
return match.slice(1, 3);
|
|
39
|
+
});
|
|
33
40
|
return {
|
|
34
41
|
__original: original,
|
|
35
|
-
...Object.fromEntries(
|
|
42
|
+
...Object.fromEntries(parsed)
|
|
36
43
|
};
|
|
37
44
|
}
|
|
38
45
|
// h, hi, hmac and xor, are defined in https://datatracker.ietf.org/doc/html/rfc5802#section-2.2
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type MessageToProduce } from "../../protocol/records";
|
|
2
|
+
export declare function defaultPartitioner<Key = Buffer, Value = Buffer, HeaderKey = Buffer, HeaderValue = Buffer>(_: MessageToProduce<Key, Value, HeaderKey, HeaderValue>, key?: Buffer | undefined): number;
|
|
3
|
+
export declare function compatibilityPartitioner<Key = Buffer, Value = Buffer, HeaderKey = Buffer, HeaderValue = Buffer>(_: MessageToProduce<Key, Value, HeaderKey, HeaderValue>, key?: Buffer | undefined): number;
|
|
@@ -12,7 +12,7 @@ export interface ProduceResult {
|
|
|
12
12
|
offsets?: TopicWithPartitionAndOffset[];
|
|
13
13
|
unwritableNodes?: number[];
|
|
14
14
|
}
|
|
15
|
-
export type Partitioner<Key, Value, HeaderKey, HeaderValue> = (message: MessageToProduce<Key, Value, HeaderKey, HeaderValue
|
|
15
|
+
export type Partitioner<Key, Value, HeaderKey, HeaderValue> = (message: MessageToProduce<Key, Value, HeaderKey, HeaderValue>, key?: Buffer | undefined) => number;
|
|
16
16
|
export interface ProducerStreamReport {
|
|
17
17
|
batchId: number;
|
|
18
18
|
count: number;
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@platformatic/kafka";
|
|
2
|
-
export const version = "1.
|
|
2
|
+
export const version = "1.32.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/kafka",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.32.1",
|
|
4
4
|
"description": "Modern and performant client for Apache Kafka",
|
|
5
5
|
"homepage": "https://github.com/platformatic/kafka",
|
|
6
6
|
"author": "Platformatic Inc. <oss@platformatic.dev> (https://platformatic.dev)",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"types": "./dist/index.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@platformatic/dynamic-buffer": "^0.3.1",
|
|
29
|
-
"@platformatic/wasm-utils": "^0.1
|
|
29
|
+
"@platformatic/wasm-utils": "^0.2.1",
|
|
30
30
|
"ajv": "^8.17.1",
|
|
31
31
|
"avsc": "^5.7.9",
|
|
32
32
|
"debug": "^4.4.3",
|