@platformatic/kafka 1.24.0 → 1.25.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/dist/clients/admin/admin.d.ts +3 -3
- package/dist/clients/admin/admin.js +2 -2
- package/dist/clients/admin/options.d.ts +2 -2
- package/dist/clients/admin/options.js +3 -3
- package/dist/clients/admin/types.d.ts +5 -5
- package/dist/clients/base/base.d.ts +20 -3
- package/dist/clients/base/base.js +2 -2
- package/dist/clients/consumer/consumer.d.ts +14 -57
- package/dist/clients/consumer/consumer.js +9 -23
- package/dist/clients/consumer/messages-stream.js +4 -0
- package/dist/clients/index.d.ts +1 -1
- package/dist/clients/index.js +1 -1
- package/dist/diagnostic.d.ts +21 -21
- package/dist/events.d.ts +22 -0
- package/dist/events.js +29 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/network/connection-pool.d.ts +22 -2
- package/dist/network/connection-pool.js +2 -2
- package/dist/network/connection.d.ts +16 -2
- package/dist/network/connection.js +2 -2
- package/dist/typescript-4/dist/clients/admin/admin.d.ts +3 -3
- package/dist/typescript-4/dist/clients/admin/options.d.ts +2 -2
- package/dist/typescript-4/dist/clients/admin/types.d.ts +5 -5
- package/dist/typescript-4/dist/clients/base/base.d.ts +20 -3
- package/dist/typescript-4/dist/clients/consumer/consumer.d.ts +14 -57
- package/dist/typescript-4/dist/clients/index.d.ts +1 -1
- package/dist/typescript-4/dist/diagnostic.d.ts +21 -21
- package/dist/typescript-4/dist/events.d.ts +22 -0
- package/dist/typescript-4/dist/index.d.ts +1 -0
- package/dist/typescript-4/dist/network/connection-pool.d.ts +22 -2
- package/dist/typescript-4/dist/network/connection.d.ts +16 -2
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import { type CallbackWithPromise } from '../../apis/callbacks.ts';
|
|
|
5
5
|
import { type Callback } from '../../apis/definitions.ts';
|
|
6
6
|
import { type Acl } from '../../apis/types.ts';
|
|
7
7
|
import { Base } from '../base/base.ts';
|
|
8
|
-
import { type AdminOptions, type AlterClientQuotasOptions, type AlterConfigsOptions, type AlterConsumerGroupOffsetsOptions, type BrokerLogDirDescription, type ConfigDescription, type CreateAclsOptions, type CreatedTopic, type CreatePartitionsOptions, type CreateTopicsOptions, type DeleteAclsOptions, type DeleteConsumerGroupOffsetsOptions, type DeleteGroupsOptions, type DeleteTopicsOptions, type DescribeAclsOptions, type DescribeClientQuotasOptions, type DescribeConfigsOptions, type DescribeGroupsOptions, type DescribeLogDirsOptions, type Group, type GroupBase, type IncrementalAlterConfigsOptions, type ListConsumerGroupOffsetsGroup, type ListConsumerGroupOffsetsOptions, type ListedOffsetsTopic, type ListGroupsOptions, type
|
|
8
|
+
import { type AdminListOffsetsOptions, type AdminOptions, type AlterClientQuotasOptions, type AlterConfigsOptions, type AlterConsumerGroupOffsetsOptions, type BrokerLogDirDescription, type ConfigDescription, type CreateAclsOptions, type CreatedTopic, type CreatePartitionsOptions, type CreateTopicsOptions, type DeleteAclsOptions, type DeleteConsumerGroupOffsetsOptions, type DeleteGroupsOptions, type DeleteTopicsOptions, type DescribeAclsOptions, type DescribeClientQuotasOptions, type DescribeConfigsOptions, type DescribeGroupsOptions, type DescribeLogDirsOptions, type Group, type GroupBase, type IncrementalAlterConfigsOptions, type ListConsumerGroupOffsetsGroup, type ListConsumerGroupOffsetsOptions, type ListedOffsetsTopic, type ListGroupsOptions, type ListTopicsOptions, type RemoveMembersFromConsumerGroupOptions } from './types.ts';
|
|
9
9
|
export declare class Admin extends Base<AdminOptions> {
|
|
10
10
|
#private;
|
|
11
11
|
constructor(options: AdminOptions);
|
|
@@ -55,6 +55,6 @@ export declare class Admin extends Base<AdminOptions> {
|
|
|
55
55
|
describeAcls(options: DescribeAclsOptions): Promise<DescribeAclsResponseResource[]>;
|
|
56
56
|
deleteAcls(options: DeleteAclsOptions, callback: CallbackWithPromise<Acl[]>): void;
|
|
57
57
|
deleteAcls(options: DeleteAclsOptions): Promise<Acl[]>;
|
|
58
|
-
listOffsets(options:
|
|
59
|
-
listOffsets(options:
|
|
58
|
+
listOffsets(options: AdminListOffsetsOptions, callback: CallbackWithPromise<ListedOffsetsTopic[]>): void;
|
|
59
|
+
listOffsets(options: AdminListOffsetsOptions): Promise<ListedOffsetsTopic[]>;
|
|
60
60
|
}
|
|
@@ -4,7 +4,7 @@ import { adminAclsChannel, adminClientQuotasChannel, adminConfigsChannel, adminC
|
|
|
4
4
|
import { MultipleErrors } from "../../errors.js";
|
|
5
5
|
import { Reader } from "../../protocol/reader.js";
|
|
6
6
|
import { Base, kAfterCreate, kCheckNotClosed, kConnections, kGetApi, kGetBootstrapConnection, kGetConnection, kMetadata, kOptions, kPerformDeduplicated, kPerformWithRetry, kValidateOptions } from "../base/base.js";
|
|
7
|
-
import { alterClientQuotasOptionsValidator, alterConfigsOptionsValidator, alterConsumerGroupOffsetsOptionsValidator, createAclsOptionsValidator, createPartitionsOptionsValidator, createTopicsOptionsValidator, deleteAclsOptionsValidator, deleteConsumerGroupOffsetsOptionsValidator, deleteGroupsOptionsValidator, deleteTopicsOptionsValidator, describeAclsOptionsValidator, describeClientQuotasOptionsValidator, describeConfigsOptionsValidator, describeGroupsOptionsValidator, describeLogDirsOptionsValidator, incrementalAlterConfigsOptionsValidator, listConsumerGroupOffsetsOptionsValidator, listGroupsOptionsValidator,
|
|
7
|
+
import { adminListOffsetsOptionsValidator, alterClientQuotasOptionsValidator, alterConfigsOptionsValidator, alterConsumerGroupOffsetsOptionsValidator, createAclsOptionsValidator, createPartitionsOptionsValidator, createTopicsOptionsValidator, deleteAclsOptionsValidator, deleteConsumerGroupOffsetsOptionsValidator, deleteGroupsOptionsValidator, deleteTopicsOptionsValidator, describeAclsOptionsValidator, describeClientQuotasOptionsValidator, describeConfigsOptionsValidator, describeGroupsOptionsValidator, describeLogDirsOptionsValidator, incrementalAlterConfigsOptionsValidator, listConsumerGroupOffsetsOptionsValidator, listGroupsOptionsValidator, listTopicsOptionsValidator, removeMembersFromConsumerGroupOptionsValidator } from "./options.js";
|
|
8
8
|
export class Admin extends Base {
|
|
9
9
|
#controller = null;
|
|
10
10
|
constructor(options) {
|
|
@@ -326,7 +326,7 @@ export class Admin extends Base {
|
|
|
326
326
|
if (this[kCheckNotClosed](callback)) {
|
|
327
327
|
return callback[kCallbackPromise];
|
|
328
328
|
}
|
|
329
|
-
const validationError = this[kValidateOptions](options,
|
|
329
|
+
const validationError = this[kValidateOptions](options, adminListOffsetsOptionsValidator, '/options', false);
|
|
330
330
|
if (validationError) {
|
|
331
331
|
callback(validationError);
|
|
332
332
|
return callback[kCallbackPromise];
|
|
@@ -802,7 +802,7 @@ export declare const deleteAclsOptionsSchema: {
|
|
|
802
802
|
required: string[];
|
|
803
803
|
additionalProperties: boolean;
|
|
804
804
|
};
|
|
805
|
-
export declare const
|
|
805
|
+
export declare const adminListOffsetsOptionsSchema: {
|
|
806
806
|
type: string;
|
|
807
807
|
properties: {
|
|
808
808
|
topics: {
|
|
@@ -902,6 +902,6 @@ export declare const describeAclsOptionsValidator: import("ajv").ValidateFunctio
|
|
|
902
902
|
export declare const deleteAclsOptionsValidator: import("ajv").ValidateFunction<{
|
|
903
903
|
[x: string]: {};
|
|
904
904
|
}>;
|
|
905
|
-
export declare const
|
|
905
|
+
export declare const adminListOffsetsOptionsValidator: import("ajv").ValidateFunction<{
|
|
906
906
|
[x: string]: {};
|
|
907
907
|
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allowedAclOperations, allowedAclPermissionTypes, allowedClientQuotaMatchTypes, allowedFetchIsolationLevels, allowedIncrementalAlterConfigOperationTypes, allowedResourcePatternTypes, allowedResourceTypes, ConsumerGroupStates, IncrementalAlterConfigOperationTypes } from "../../apis/enumerations.js";
|
|
2
2
|
import { ajv, listErrorMessage } from "../../utils.js";
|
|
3
3
|
import { idProperty } from "../base/options.js";
|
|
4
4
|
export const groupsProperties = {
|
|
@@ -522,7 +522,7 @@ export const deleteAclsOptionsSchema = {
|
|
|
522
522
|
required: ['filters'],
|
|
523
523
|
additionalProperties: false
|
|
524
524
|
};
|
|
525
|
-
export const
|
|
525
|
+
export const adminListOffsetsOptionsSchema = {
|
|
526
526
|
type: 'object',
|
|
527
527
|
properties: {
|
|
528
528
|
topics: {
|
|
@@ -575,4 +575,4 @@ export const incrementalAlterConfigsOptionsValidator = ajv.compile(incrementalAl
|
|
|
575
575
|
export const createAclsOptionsValidator = ajv.compile(createAclsOptionsSchema);
|
|
576
576
|
export const describeAclsOptionsValidator = ajv.compile(describeAclsOptionsSchema);
|
|
577
577
|
export const deleteAclsOptionsValidator = ajv.compile(deleteAclsOptionsSchema);
|
|
578
|
-
export const
|
|
578
|
+
export const adminListOffsetsOptionsValidator = ajv.compile(adminListOffsetsOptionsSchema);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { type AlterClientQuotasRequestEntry } from '../../apis/admin/alter-client-quotas-v1.ts';
|
|
2
|
+
import { type AlterConfigsRequestResource } from '../../apis/admin/alter-configs-v2.ts';
|
|
2
3
|
import { type CreatePartitionsRequestTopic } from '../../apis/admin/create-partitions-v3.ts';
|
|
3
4
|
import { type CreateTopicsRequestTopicConfig } from '../../apis/admin/create-topics-v7.ts';
|
|
4
|
-
import { type AlterConfigsRequestResource } from '../../apis/admin/alter-configs-v2.ts';
|
|
5
|
-
import { type DescribeConfigsRequestResource, type DescribeConfigsResponseConfig } from '../../apis/admin/describe-configs-v4.ts';
|
|
6
5
|
import { type DescribeClientQuotasRequestComponent } from '../../apis/admin/describe-client-quotas-v0.ts';
|
|
6
|
+
import { type DescribeConfigsRequestResource, type DescribeConfigsResponseConfig } from '../../apis/admin/describe-configs-v4.ts';
|
|
7
7
|
import { type DescribeLogDirsRequestTopic, type DescribeLogDirsResponse, type DescribeLogDirsResponseResult } from '../../apis/admin/describe-log-dirs-v4.ts';
|
|
8
8
|
import { type IncrementalAlterConfigsRequestResource } from '../../apis/admin/incremental-alter-configs-v1.ts';
|
|
9
|
-
import { type
|
|
9
|
+
import { type ConfigResourceTypeValue, type ConsumerGroupStateValue, type FetchIsolationLevelValue } from '../../apis/enumerations.ts';
|
|
10
|
+
import { type Acl, type AclFilter } from '../../apis/types.ts';
|
|
10
11
|
import { type Nullable, type NullableString } from '../../protocol/definitions.ts';
|
|
11
12
|
import { type BaseOptions } from '../base/types.ts';
|
|
12
13
|
import { type ExtendedGroupProtocolSubscription, type GroupAssignment } from '../consumer/types.ts';
|
|
13
|
-
import { type Acl, type AclFilter } from '../../apis/types.ts';
|
|
14
14
|
export interface BrokerAssignment {
|
|
15
15
|
partition: number;
|
|
16
16
|
brokers: number[];
|
|
@@ -174,7 +174,7 @@ export interface TopicOffsetRequest {
|
|
|
174
174
|
name: string;
|
|
175
175
|
partitions: PartitionTimestamp[];
|
|
176
176
|
}
|
|
177
|
-
export interface
|
|
177
|
+
export interface AdminListOffsetsOptions {
|
|
178
178
|
topics: TopicOffsetRequest[];
|
|
179
179
|
isolationLevel?: Nullable<FetchIsolationLevelValue>;
|
|
180
180
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type ValidateFunction } from 'ajv';
|
|
2
|
-
import { EventEmitter } from 'node:events';
|
|
3
2
|
import { type CallbackWithPromise } from '../../apis/callbacks.ts';
|
|
4
3
|
import { type API, type Callback } from '../../apis/definitions.ts';
|
|
5
4
|
import { type ApiVersionsResponseApi } from '../../apis/metadata/api-versions-v3.ts';
|
|
6
5
|
import { type ClientType } from '../../diagnostic.ts';
|
|
7
|
-
import {
|
|
6
|
+
import { TypedEventEmitter, type TypedEvents } from '../../events.ts';
|
|
7
|
+
import { ConnectionPool, type ConnectionPoolEventPayload } from '../../network/connection-pool.ts';
|
|
8
8
|
import { type Broker, type Connection } from '../../network/connection.ts';
|
|
9
9
|
import { kInstance } from '../../symbols.ts';
|
|
10
10
|
import { type Metrics } from '../metrics.ts';
|
|
@@ -31,7 +31,24 @@ export declare const kFormatValidationErrors: unique symbol;
|
|
|
31
31
|
export declare const kPrometheus: unique symbol;
|
|
32
32
|
export declare const kClientType: unique symbol;
|
|
33
33
|
export declare const kAfterCreate: unique symbol;
|
|
34
|
-
export
|
|
34
|
+
export interface BaseEvents extends TypedEvents {
|
|
35
|
+
'client:broker:connect': (payload: ConnectionPoolEventPayload) => void;
|
|
36
|
+
'client:broker:disconnect': (payload: ConnectionPoolEventPayload) => void;
|
|
37
|
+
'client:broker:failed': (payload: ConnectionPoolEventPayload) => void;
|
|
38
|
+
'client:broker:drain': (payload: ConnectionPoolEventPayload) => void;
|
|
39
|
+
'client:broker:sasl:handshake': (payload: ConnectionPoolEventPayload & {
|
|
40
|
+
mechanisms: string[];
|
|
41
|
+
}) => void;
|
|
42
|
+
'client:broker:sasl:authentication': (payload: ConnectionPoolEventPayload & {
|
|
43
|
+
authentication: Buffer;
|
|
44
|
+
}) => void;
|
|
45
|
+
'client:broker:sasl:authentication:extended': (payload: ConnectionPoolEventPayload & {
|
|
46
|
+
authentication: Buffer;
|
|
47
|
+
}) => void;
|
|
48
|
+
'client:metadata': (metadata: ClusterMetadata) => void;
|
|
49
|
+
'client:close': () => void;
|
|
50
|
+
}
|
|
51
|
+
export declare class Base<OptionsType extends BaseOptions = BaseOptions, EventsType extends BaseEvents = BaseEvents> extends TypedEventEmitter<EventsType> {
|
|
35
52
|
#private;
|
|
36
53
|
[kInstance]: number;
|
|
37
54
|
[kClientId]: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { EventEmitter } from 'node:events';
|
|
2
1
|
import { createPromisifiedCallback, kCallbackPromise, runConcurrentCallbacks } from "../../apis/callbacks.js";
|
|
3
2
|
import * as apis from "../../apis/index.js";
|
|
4
3
|
import { api as apiVersionsV3 } from "../../apis/metadata/api-versions-v3.js";
|
|
5
4
|
import { baseApisChannel, baseMetadataChannel, createDiagnosticContext, notifyCreation } from "../../diagnostic.js";
|
|
6
5
|
import { MultipleErrors, NetworkError, UnsupportedApiError, UserError } from "../../errors.js";
|
|
6
|
+
import { TypedEventEmitter } from "../../events.js";
|
|
7
7
|
import { ConnectionPool } from "../../network/connection-pool.js";
|
|
8
8
|
import { parseBroker } from "../../network/utils.js";
|
|
9
9
|
import { kInstance } from "../../symbols.js";
|
|
@@ -32,7 +32,7 @@ export const kPrometheus = Symbol('plt.kafka.base.prometheus');
|
|
|
32
32
|
export const kClientType = Symbol('plt.kafka.base.clientType');
|
|
33
33
|
export const kAfterCreate = Symbol('plt.kafka.base.afterCreate');
|
|
34
34
|
let currentInstance = 0;
|
|
35
|
-
export class Base extends
|
|
35
|
+
export class Base extends TypedEventEmitter {
|
|
36
36
|
// This is declared using a symbol (a.k.a protected/friend) to make it available in ConnectionPool and MessagesStream
|
|
37
37
|
[kInstance];
|
|
38
38
|
// General status - Use symbols rather than JS private property to make them "protected" as in C++
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { type CallbackWithPromise } from '../../apis/callbacks.ts';
|
|
2
2
|
import { type FetchResponse } from '../../apis/consumer/fetch-v17.ts';
|
|
3
3
|
import { type ConnectionPool } from '../../network/connection-pool.ts';
|
|
4
|
-
import { Base, kFetchConnections } from '../base/base.ts';
|
|
4
|
+
import { Base, type BaseEvents, kFetchConnections } from '../base/base.ts';
|
|
5
5
|
import { MessagesStream } from './messages-stream.ts';
|
|
6
6
|
import { TopicsMap } from './topics-map.ts';
|
|
7
7
|
import { type CommitOptions, type ConsumeOptions, type ConsumerGroupJoinPayload, type ConsumerGroupLeavePayload, type ConsumerGroupRebalancePayload, type ConsumerHeartbeatErrorPayload, type ConsumerHeartbeatPayload, type ConsumerOptions, type FetchOptions, type GetLagOptions, type GroupAssignment, type GroupOptions, type ListCommitsOptions, type ListOffsetsOptions, type Offsets, type OffsetsWithTimestamps } from './types.ts';
|
|
8
|
-
export
|
|
8
|
+
export interface ConsumerEvents extends BaseEvents {
|
|
9
|
+
'consumer:group:join': (payload: ConsumerGroupJoinPayload) => void;
|
|
10
|
+
'consumer:group:leave': (payload: ConsumerGroupLeavePayload) => void;
|
|
11
|
+
'consumer:group:rejoin': () => void;
|
|
12
|
+
'consumer:group:rebalance': (payload: ConsumerGroupRebalancePayload) => void;
|
|
13
|
+
'consumer:heartbeat:start': (payload?: ConsumerHeartbeatPayload) => void;
|
|
14
|
+
'consumer:heartbeat:cancel': (payload: ConsumerHeartbeatPayload) => void;
|
|
15
|
+
'consumer:heartbeat:end': (payload?: ConsumerHeartbeatPayload) => void;
|
|
16
|
+
'consumer:heartbeat:error': (payload: ConsumerHeartbeatErrorPayload) => void;
|
|
17
|
+
'consumer:lag': (lag: Offsets) => void;
|
|
18
|
+
'consumer:lag:error': (error: Error) => void;
|
|
19
|
+
}
|
|
20
|
+
export declare class Consumer<Key = Buffer, Value = Buffer, HeaderKey = Buffer, HeaderValue = Buffer> extends Base<ConsumerOptions<Key, Value, HeaderKey, HeaderValue>, ConsumerEvents> {
|
|
9
21
|
#private;
|
|
10
22
|
groupId: string;
|
|
11
23
|
generationId: number;
|
|
@@ -17,61 +29,6 @@ export declare class Consumer<Key = Buffer, Value = Buffer, HeaderKey = Buffer,
|
|
|
17
29
|
get streamsCount(): number;
|
|
18
30
|
get lastHeartbeat(): Date | null;
|
|
19
31
|
get coordinatorId(): number | null;
|
|
20
|
-
addListener(event: 'consumer:group:join', listener: (payload: ConsumerGroupJoinPayload) => void): this;
|
|
21
|
-
addListener(event: 'consumer:group:leave', listener: (payload: ConsumerGroupLeavePayload) => void): this;
|
|
22
|
-
addListener(event: 'consumer:group:rejoin', listener: () => void): this;
|
|
23
|
-
addListener(event: 'consumer:group:rebalance', listener: (payload: ConsumerGroupRebalancePayload) => void): this;
|
|
24
|
-
addListener(event: 'consumer:heartbeat:start', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
25
|
-
addListener(event: 'consumer:heartbeat:cancel', listener: (payload: ConsumerHeartbeatPayload) => void): this;
|
|
26
|
-
addListener(event: 'consumer:heartbeat:end', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
27
|
-
addListener(event: 'consumer:heartbeat:error', listener: (payload: ConsumerHeartbeatErrorPayload) => void): this;
|
|
28
|
-
addListener(event: 'consumer:lag', listener: (lag: Offsets) => void): this;
|
|
29
|
-
addListener(event: 'consumer:lag:error', listener: (error: Error) => void): this;
|
|
30
|
-
addListener(event: 'error', listener: (error: Error) => void): this;
|
|
31
|
-
on(event: 'consumer:group:join', listener: (payload: ConsumerGroupJoinPayload) => void): this;
|
|
32
|
-
on(event: 'consumer:group:leave', listener: (payload: ConsumerGroupLeavePayload) => void): this;
|
|
33
|
-
on(event: 'consumer:group:rejoin', listener: () => void): this;
|
|
34
|
-
on(event: 'consumer:group:rebalance', listener: (payload: ConsumerGroupRebalancePayload) => void): this;
|
|
35
|
-
on(event: 'consumer:heartbeat:start', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
36
|
-
on(event: 'consumer:heartbeat:cancel', listener: (payload: ConsumerHeartbeatPayload) => void): this;
|
|
37
|
-
on(event: 'consumer:heartbeat:end', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
38
|
-
on(event: 'consumer:heartbeat:error', listener: (payload: ConsumerHeartbeatErrorPayload) => void): this;
|
|
39
|
-
on(event: 'consumer:lag', listener: (lag: Offsets) => void): this;
|
|
40
|
-
on(event: 'consumer:lag:error', listener: (error: Error) => void): this;
|
|
41
|
-
on(event: 'error', listener: (error: Error) => void): this;
|
|
42
|
-
once(event: 'consumer:group:join', listener: (payload: ConsumerGroupJoinPayload) => void): this;
|
|
43
|
-
once(event: 'consumer:group:leave', listener: (payload: ConsumerGroupLeavePayload) => void): this;
|
|
44
|
-
once(event: 'consumer:group:rejoin', listener: () => void): this;
|
|
45
|
-
once(event: 'consumer:group:rebalance', listener: (payload: ConsumerGroupRebalancePayload) => void): this;
|
|
46
|
-
once(event: 'consumer:heartbeat:start', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
47
|
-
once(event: 'consumer:heartbeat:cancel', listener: (payload: ConsumerHeartbeatPayload) => void): this;
|
|
48
|
-
once(event: 'consumer:heartbeat:end', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
49
|
-
once(event: 'consumer:heartbeat:error', listener: (payload: ConsumerHeartbeatErrorPayload) => void): this;
|
|
50
|
-
once(event: 'consumer:lag', listener: (lag: Offsets) => void): this;
|
|
51
|
-
once(event: 'consumer:lag:error', listener: (error: Error) => void): this;
|
|
52
|
-
once(event: 'error', listener: (error: Error) => void): this;
|
|
53
|
-
prependListener(event: 'consumer:group:join', listener: (payload: ConsumerGroupJoinPayload) => void): this;
|
|
54
|
-
prependListener(event: 'consumer:group:leave', listener: (payload: ConsumerGroupLeavePayload) => void): this;
|
|
55
|
-
prependListener(event: 'consumer:group:rejoin', listener: () => void): this;
|
|
56
|
-
prependListener(event: 'consumer:group:rebalance', listener: (payload: ConsumerGroupRebalancePayload) => void): this;
|
|
57
|
-
prependListener(event: 'consumer:heartbeat:start', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
58
|
-
prependListener(event: 'consumer:heartbeat:cancel', listener: (payload: ConsumerHeartbeatPayload) => void): this;
|
|
59
|
-
prependListener(event: 'consumer:heartbeat:end', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
60
|
-
prependListener(event: 'consumer:heartbeat:error', listener: (payload: ConsumerHeartbeatErrorPayload) => void): this;
|
|
61
|
-
prependListener(event: 'consumer:lag', listener: (lag: Offsets) => void): this;
|
|
62
|
-
prependListener(event: 'consumer:lag:error', listener: (error: Error) => void): this;
|
|
63
|
-
prependListener(event: 'error', listener: (error: Error) => void): this;
|
|
64
|
-
prependOnceListener(event: 'consumer:group:join', listener: (payload: ConsumerGroupJoinPayload) => void): this;
|
|
65
|
-
prependOnceListener(event: 'consumer:group:leave', listener: (payload: ConsumerGroupLeavePayload) => void): this;
|
|
66
|
-
prependOnceListener(event: 'consumer:group:rejoin', listener: () => void): this;
|
|
67
|
-
prependOnceListener(event: 'consumer:group:rebalance', listener: (payload: ConsumerGroupRebalancePayload) => void): this;
|
|
68
|
-
prependOnceListener(event: 'consumer:heartbeat:start', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
69
|
-
prependOnceListener(event: 'consumer:heartbeat:cancel', listener: (payload: ConsumerHeartbeatPayload) => void): this;
|
|
70
|
-
prependOnceListener(event: 'consumer:heartbeat:end', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
71
|
-
prependOnceListener(event: 'consumer:heartbeat:error', listener: (payload: ConsumerHeartbeatErrorPayload) => void): this;
|
|
72
|
-
prependOnceListener(event: 'consumer:lag', listener: (lag: Offsets) => void): this;
|
|
73
|
-
prependOnceListener(event: 'consumer:lag:error', listener: (error: Error) => void): this;
|
|
74
|
-
prependOnceListener(event: 'error', listener: (error: Error) => void): this;
|
|
75
32
|
close(force: boolean | CallbackWithPromise<void>, callback?: CallbackWithPromise<void>): void;
|
|
76
33
|
close(force?: boolean): Promise<void>;
|
|
77
34
|
isActive(): boolean;
|
|
@@ -8,7 +8,6 @@ import { IS_CONTROL } from "../../protocol/records.js";
|
|
|
8
8
|
import { Writer } from "../../protocol/writer.js";
|
|
9
9
|
import { kAutocommit, kRefreshOffsetsAndFetch } from "../../symbols.js";
|
|
10
10
|
import { Base, kAfterCreate, kCheckNotClosed, kClosed, kCreateConnectionPool, kFetchConnections, kFormatValidationErrors, kGetApi, kGetBootstrapConnection, kGetConnection, kMetadata, kOptions, kPerformDeduplicated, kPerformWithRetry, kPrometheus, kValidateOptions } from "../base/base.js";
|
|
11
|
-
import { defaultBaseOptions } from "../base/options.js";
|
|
12
11
|
import { ensureMetric } from "../metrics.js";
|
|
13
12
|
import { MessagesStream } from "./messages-stream.js";
|
|
14
13
|
import { commitOptionsValidator, consumeOptionsValidator, consumerOptionsValidator, defaultConsumerOptions, fetchOptionsValidator, getLagOptionsValidator, groupIdAndOptionsValidator, groupOptionsValidator, listCommitsOptionsValidator, listOffsetsOptionsValidator } from "./options.js";
|
|
@@ -53,8 +52,7 @@ export class Consumer extends Base {
|
|
|
53
52
|
#metricActiveStreams;
|
|
54
53
|
#metricLags;
|
|
55
54
|
constructor(options) {
|
|
56
|
-
super(options);
|
|
57
|
-
this[kOptions] = Object.assign({}, defaultBaseOptions, defaultConsumerOptions, options);
|
|
55
|
+
super({ ...defaultConsumerOptions, ...options });
|
|
58
56
|
this[kValidateOptions](options, consumerOptionsValidator, '/options');
|
|
59
57
|
this.groupId = options.groupId;
|
|
60
58
|
this.generationId = 0;
|
|
@@ -95,26 +93,6 @@ export class Consumer extends Base {
|
|
|
95
93
|
get coordinatorId() {
|
|
96
94
|
return this.#coordinatorId;
|
|
97
95
|
}
|
|
98
|
-
/* c8 ignore next 3 - Only forwards to Node.js implementation - Inserted here to please Typescript */
|
|
99
|
-
addListener(event, listener) {
|
|
100
|
-
return super.addListener(event, listener);
|
|
101
|
-
}
|
|
102
|
-
/* c8 ignore next 3 - Only forwards to Node.js implementation - Inserted here to please Typescript */
|
|
103
|
-
on(event, listener) {
|
|
104
|
-
return super.on(event, listener);
|
|
105
|
-
}
|
|
106
|
-
/* c8 ignore next 3 - Only forwards to Node.js implementation - Inserted here to please Typescript */
|
|
107
|
-
once(event, listener) {
|
|
108
|
-
return super.once(event, listener);
|
|
109
|
-
}
|
|
110
|
-
/* c8 ignore next 3 - Only forwards to Node.js implementation - Inserted here to please Typescript */
|
|
111
|
-
prependListener(event, listener) {
|
|
112
|
-
return super.prependListener(event, listener);
|
|
113
|
-
}
|
|
114
|
-
/* c8 ignore next 3 - Only forwards to Node.js implementation - Inserted here to please Typescript */
|
|
115
|
-
prependOnceListener(event, listener) {
|
|
116
|
-
return super.prependOnceListener(event, listener);
|
|
117
|
-
}
|
|
118
96
|
close(force, callback) {
|
|
119
97
|
if (typeof force === 'function') {
|
|
120
98
|
callback = force;
|
|
@@ -434,6 +412,14 @@ export class Consumer extends Base {
|
|
|
434
412
|
}
|
|
435
413
|
this[kFetchConnections].get(broker, (error, connection) => {
|
|
436
414
|
if (error) {
|
|
415
|
+
// When a connection was not available (either interrupted or not available) we
|
|
416
|
+
// reset the leader epoch in the options so that when connection is re-established again we can continue
|
|
417
|
+
for (const topic of options.topics) {
|
|
418
|
+
for (const partition of topic.partitions) {
|
|
419
|
+
partition.currentLeaderEpoch = -1;
|
|
420
|
+
partition.lastFetchedEpoch = -1;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
437
423
|
retryCallback(error);
|
|
438
424
|
return;
|
|
439
425
|
}
|
|
@@ -114,6 +114,10 @@ export class MessagesStream extends Readable {
|
|
|
114
114
|
if (consumer[kPrometheus]) {
|
|
115
115
|
this.#metricsConsumedMessages = ensureMetric(consumer[kPrometheus], 'Counter', 'kafka_consumed_messages', 'Number of consumed Kafka messages');
|
|
116
116
|
}
|
|
117
|
+
// Whenever the consumer loses a connection, reset all the partitions epochs
|
|
118
|
+
consumer.on('client:broker:disconnect', () => {
|
|
119
|
+
this.#partitionsEpochs.clear();
|
|
120
|
+
});
|
|
117
121
|
notifyCreation('messages-stream', this);
|
|
118
122
|
}
|
|
119
123
|
/* c8 ignore next 3 - Simple getter */
|
package/dist/clients/index.d.ts
CHANGED
package/dist/clients/index.js
CHANGED
package/dist/diagnostic.d.ts
CHANGED
|
@@ -36,24 +36,24 @@ export declare const instancesChannel: ChannelWithName<object>;
|
|
|
36
36
|
export declare const connectionsConnectsChannel: TracingChannelWithName<ConnectionDiagnosticEvent<Record<string, unknown>>>;
|
|
37
37
|
export declare const connectionsApiChannel: TracingChannelWithName<ConnectionDiagnosticEvent<Record<string, unknown>>>;
|
|
38
38
|
export declare const connectionsPoolGetsChannel: TracingChannelWithName<ConnectionPoolDiagnosticEvent<Record<string, unknown>>>;
|
|
39
|
-
export declare const baseApisChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
40
|
-
export declare const baseMetadataChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
41
|
-
export declare const adminTopicsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
42
|
-
export declare const adminGroupsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
43
|
-
export declare const adminClientQuotasChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
44
|
-
export declare const adminLogDirsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
45
|
-
export declare const adminConsumerGroupOffsetsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
46
|
-
export declare const adminConfigsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
47
|
-
export declare const adminAclsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
48
|
-
export declare const adminOffsetsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
49
|
-
export declare const producerInitIdempotentChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
50
|
-
export declare const producerSendsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
51
|
-
export declare const producerTransactionsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
52
|
-
export declare const consumerGroupChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
53
|
-
export declare const consumerHeartbeatChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
54
|
-
export declare const consumerReceivesChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
55
|
-
export declare const consumerFetchesChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
56
|
-
export declare const consumerConsumesChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
57
|
-
export declare const consumerCommitsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
58
|
-
export declare const consumerOffsetsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
59
|
-
export declare const consumerLagChannel: ChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions>, Record<string, unknown>>>;
|
|
39
|
+
export declare const baseApisChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
40
|
+
export declare const baseMetadataChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
41
|
+
export declare const adminTopicsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
42
|
+
export declare const adminGroupsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
43
|
+
export declare const adminClientQuotasChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
44
|
+
export declare const adminLogDirsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
45
|
+
export declare const adminConsumerGroupOffsetsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
46
|
+
export declare const adminConfigsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
47
|
+
export declare const adminAclsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
48
|
+
export declare const adminOffsetsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
49
|
+
export declare const producerInitIdempotentChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
50
|
+
export declare const producerSendsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
51
|
+
export declare const producerTransactionsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
52
|
+
export declare const consumerGroupChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
53
|
+
export declare const consumerHeartbeatChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
54
|
+
export declare const consumerReceivesChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
55
|
+
export declare const consumerFetchesChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
56
|
+
export declare const consumerConsumesChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
57
|
+
export declare const consumerCommitsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
58
|
+
export declare const consumerOffsetsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
|
59
|
+
export declare const consumerLagChannel: ChannelWithName<ClientDiagnosticEvent<Base<import("./index.ts").BaseOptions, import("./clients/base/base.ts").BaseEvents>, Record<string, unknown>>>;
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
export interface TypedEvents {
|
|
3
|
+
error: (error: Error) => void;
|
|
4
|
+
}
|
|
5
|
+
export declare class TypedEventEmitter<EventsType extends TypedEvents = TypedEvents> extends EventEmitter {
|
|
6
|
+
addListener<K extends keyof EventsType>(event: K, listener: EventsType[K]): this;
|
|
7
|
+
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
8
|
+
on<K extends keyof EventsType>(event: K, listener: EventsType[K]): this;
|
|
9
|
+
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
10
|
+
once<K extends keyof EventsType>(event: K, listener: EventsType[K]): this;
|
|
11
|
+
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
12
|
+
prependListener<K extends keyof EventsType>(event: K, listener: EventsType[K]): this;
|
|
13
|
+
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
14
|
+
prependeOnceListener<K extends keyof EventsType>(event: K, listener: EventsType[K]): this;
|
|
15
|
+
prependeOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
16
|
+
off<K extends keyof EventsType>(event: K, listener: EventsType[K]): this;
|
|
17
|
+
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
18
|
+
removeListener<K extends keyof EventsType>(event: K, listener: EventsType[K]): this;
|
|
19
|
+
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
20
|
+
removeAllListeners<K extends keyof EventsType>(event: K): this;
|
|
21
|
+
removeAllListeners(event: string | symbol): this;
|
|
22
|
+
}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
/* c8 ignore start */
|
|
3
|
+
export class TypedEventEmitter extends EventEmitter {
|
|
4
|
+
addListener(event, listener) {
|
|
5
|
+
return super.addListener(event, listener);
|
|
6
|
+
}
|
|
7
|
+
on(event, listener) {
|
|
8
|
+
return super.on(event, listener);
|
|
9
|
+
}
|
|
10
|
+
once(event, listener) {
|
|
11
|
+
return super.once(event, listener);
|
|
12
|
+
}
|
|
13
|
+
prependListener(event, listener) {
|
|
14
|
+
return super.prependListener(event, listener);
|
|
15
|
+
}
|
|
16
|
+
prependeOnceListener(event, listener) {
|
|
17
|
+
return super.prependOnceListener(event, listener);
|
|
18
|
+
}
|
|
19
|
+
off(event, listener) {
|
|
20
|
+
return super.off(event, listener);
|
|
21
|
+
}
|
|
22
|
+
removeListener(event, listener) {
|
|
23
|
+
return super.removeListener(event, listener);
|
|
24
|
+
}
|
|
25
|
+
removeAllListeners(event) {
|
|
26
|
+
return super.removeAllListeners(event);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/* c8 ignore end */
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
import EventEmitter from 'node:events';
|
|
2
1
|
import { type CallbackWithPromise } from '../apis/callbacks.ts';
|
|
2
|
+
import { TypedEventEmitter, type TypedEvents } from '../events.ts';
|
|
3
3
|
import { Connection, type Broker, type ConnectionOptions } from './connection.ts';
|
|
4
|
-
export
|
|
4
|
+
export interface ConnectionPoolEventPayload {
|
|
5
|
+
broker: Broker;
|
|
6
|
+
connection: Connection;
|
|
7
|
+
}
|
|
8
|
+
export interface ConnectionPoolEvents extends TypedEvents {
|
|
9
|
+
connecting: (payload: ConnectionPoolEventPayload) => void;
|
|
10
|
+
failed: (payload: ConnectionPoolEventPayload) => void;
|
|
11
|
+
connect: (payload: ConnectionPoolEventPayload) => void;
|
|
12
|
+
'sasl:handshake': (payload: ConnectionPoolEventPayload & {
|
|
13
|
+
mechanisms: string[];
|
|
14
|
+
}) => void;
|
|
15
|
+
'sasl:authentication': (payload: ConnectionPoolEventPayload & {
|
|
16
|
+
authentication?: Buffer;
|
|
17
|
+
}) => void;
|
|
18
|
+
'sasl:authentication:extended': (payload: ConnectionPoolEventPayload & {
|
|
19
|
+
authentication?: Buffer;
|
|
20
|
+
}) => void;
|
|
21
|
+
disconnect: (payload: ConnectionPoolEventPayload) => void;
|
|
22
|
+
drain: (payload: ConnectionPoolEventPayload) => void;
|
|
23
|
+
}
|
|
24
|
+
export declare class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
|
|
5
25
|
#private;
|
|
6
26
|
constructor(clientId: string, connectionOptions?: ConnectionOptions);
|
|
7
27
|
get instanceId(): number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import EventEmitter from 'node:events';
|
|
2
1
|
import { createPromisifiedCallback, kCallbackPromise, runConcurrentCallbacks } from "../apis/callbacks.js";
|
|
3
2
|
import { connectionsPoolGetsChannel, createDiagnosticContext, notifyCreation } from "../diagnostic.js";
|
|
3
|
+
import { TypedEventEmitter } from "../events.js";
|
|
4
4
|
import { MultipleErrors } from "../errors.js";
|
|
5
5
|
import { Connection, ConnectionStatuses } from "./connection.js";
|
|
6
6
|
let currentInstance = 0;
|
|
7
|
-
export class ConnectionPool extends
|
|
7
|
+
export class ConnectionPool extends TypedEventEmitter {
|
|
8
8
|
#instanceId;
|
|
9
9
|
#clientId;
|
|
10
10
|
#closed;
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
import EventEmitter from 'node:events';
|
|
2
1
|
import { type Socket } from 'node:net';
|
|
3
2
|
import { type ConnectionOptions as TLSConnectionOptions } from 'node:tls';
|
|
4
3
|
import { type CallbackWithPromise } from '../apis/callbacks.ts';
|
|
5
4
|
import { type Callback, type ResponseParser } from '../apis/definitions.ts';
|
|
6
5
|
import { type SASLMechanismValue } from '../apis/enumerations.ts';
|
|
7
6
|
import { type SaslAuthenticateResponse, type SASLAuthenticationAPI } from '../apis/security/sasl-authenticate-v2.ts';
|
|
7
|
+
import { TypedEventEmitter, type TypedEvents } from '../events.ts';
|
|
8
|
+
import { TimeoutError } from '../errors.ts';
|
|
8
9
|
import { Writer } from '../protocol/writer.ts';
|
|
10
|
+
export interface ConnectionEvents extends TypedEvents {
|
|
11
|
+
connecting: () => void;
|
|
12
|
+
timeout: (error: TimeoutError) => void;
|
|
13
|
+
error: (error: Error) => void;
|
|
14
|
+
connect: () => void;
|
|
15
|
+
ready: () => void;
|
|
16
|
+
close: () => void;
|
|
17
|
+
closing: () => void;
|
|
18
|
+
'sasl:handshake': (mechanisms: string[]) => void;
|
|
19
|
+
'sasl:authentication': (authBytes?: Buffer) => void;
|
|
20
|
+
'sasl:authentication:extended': (authBytes?: Buffer) => void;
|
|
21
|
+
drain: () => void;
|
|
22
|
+
}
|
|
9
23
|
export type SASLCredentialProvider<T = string> = () => T | Promise<T>;
|
|
10
24
|
export interface Broker {
|
|
11
25
|
host: string;
|
|
@@ -60,7 +74,7 @@ export declare const defaultOptions: {
|
|
|
60
74
|
requestTimeout: number;
|
|
61
75
|
maxInflights: number;
|
|
62
76
|
};
|
|
63
|
-
export declare class Connection extends
|
|
77
|
+
export declare class Connection extends TypedEventEmitter<ConnectionEvents> {
|
|
64
78
|
#private;
|
|
65
79
|
constructor(clientId?: string, options?: ConnectionOptions);
|
|
66
80
|
get host(): string | undefined;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import fastq from 'fastq';
|
|
2
|
-
import EventEmitter from 'node:events';
|
|
3
2
|
import { createConnection } from 'node:net';
|
|
4
3
|
import { connect as createTLSConnection } from 'node:tls';
|
|
5
4
|
import { createPromisifiedCallback, kCallbackPromise } from "../apis/callbacks.js";
|
|
6
5
|
import { allowedSASLMechanisms, SASLMechanisms } from "../apis/enumerations.js";
|
|
7
6
|
import { saslAuthenticateV2, saslHandshakeV1 } from "../apis/index.js";
|
|
8
7
|
import { connectionsApiChannel, connectionsConnectsChannel, createDiagnosticContext, notifyCreation } from "../diagnostic.js";
|
|
8
|
+
import { TypedEventEmitter } from "../events.js";
|
|
9
9
|
import { AuthenticationError, NetworkError, TimeoutError, UnexpectedCorrelationIdError, UserError } from "../errors.js";
|
|
10
10
|
import { protocolAPIsById } from "../protocol/apis.js";
|
|
11
11
|
import { EMPTY_OR_SINGLE_COMPACT_LENGTH_SIZE, INT32_SIZE } from "../protocol/definitions.js";
|
|
@@ -30,7 +30,7 @@ export const defaultOptions = {
|
|
|
30
30
|
maxInflights: 5
|
|
31
31
|
};
|
|
32
32
|
let currentInstance = 0;
|
|
33
|
-
export class Connection extends
|
|
33
|
+
export class Connection extends TypedEventEmitter {
|
|
34
34
|
#host;
|
|
35
35
|
#port;
|
|
36
36
|
#options;
|
|
@@ -5,7 +5,7 @@ import { type CallbackWithPromise } from "../../apis/callbacks";
|
|
|
5
5
|
import { type Callback } from "../../apis/definitions";
|
|
6
6
|
import { type Acl } from "../../apis/types";
|
|
7
7
|
import { Base } from "../base/base";
|
|
8
|
-
import { type AdminOptions, type AlterClientQuotasOptions, type AlterConfigsOptions, type AlterConsumerGroupOffsetsOptions, type BrokerLogDirDescription, type ConfigDescription, type CreateAclsOptions, type CreatedTopic, type CreatePartitionsOptions, type CreateTopicsOptions, type DeleteAclsOptions, type DeleteConsumerGroupOffsetsOptions, type DeleteGroupsOptions, type DeleteTopicsOptions, type DescribeAclsOptions, type DescribeClientQuotasOptions, type DescribeConfigsOptions, type DescribeGroupsOptions, type DescribeLogDirsOptions, type Group, type GroupBase, type IncrementalAlterConfigsOptions, type ListConsumerGroupOffsetsGroup, type ListConsumerGroupOffsetsOptions, type ListedOffsetsTopic, type ListGroupsOptions, type
|
|
8
|
+
import { type AdminListOffsetsOptions, type AdminOptions, type AlterClientQuotasOptions, type AlterConfigsOptions, type AlterConsumerGroupOffsetsOptions, type BrokerLogDirDescription, type ConfigDescription, type CreateAclsOptions, type CreatedTopic, type CreatePartitionsOptions, type CreateTopicsOptions, type DeleteAclsOptions, type DeleteConsumerGroupOffsetsOptions, type DeleteGroupsOptions, type DeleteTopicsOptions, type DescribeAclsOptions, type DescribeClientQuotasOptions, type DescribeConfigsOptions, type DescribeGroupsOptions, type DescribeLogDirsOptions, type Group, type GroupBase, type IncrementalAlterConfigsOptions, type ListConsumerGroupOffsetsGroup, type ListConsumerGroupOffsetsOptions, type ListedOffsetsTopic, type ListGroupsOptions, type ListTopicsOptions, type RemoveMembersFromConsumerGroupOptions } from "./types";
|
|
9
9
|
export declare class Admin extends Base<AdminOptions> {
|
|
10
10
|
#private;
|
|
11
11
|
constructor(options: AdminOptions);
|
|
@@ -55,6 +55,6 @@ export declare class Admin extends Base<AdminOptions> {
|
|
|
55
55
|
describeAcls(options: DescribeAclsOptions): Promise<DescribeAclsResponseResource[]>;
|
|
56
56
|
deleteAcls(options: DeleteAclsOptions, callback: CallbackWithPromise<Acl[]>): void;
|
|
57
57
|
deleteAcls(options: DeleteAclsOptions): Promise<Acl[]>;
|
|
58
|
-
listOffsets(options:
|
|
59
|
-
listOffsets(options:
|
|
58
|
+
listOffsets(options: AdminListOffsetsOptions, callback: CallbackWithPromise<ListedOffsetsTopic[]>): void;
|
|
59
|
+
listOffsets(options: AdminListOffsetsOptions): Promise<ListedOffsetsTopic[]>;
|
|
60
60
|
}
|
|
@@ -802,7 +802,7 @@ export declare const deleteAclsOptionsSchema: {
|
|
|
802
802
|
required: string[];
|
|
803
803
|
additionalProperties: boolean;
|
|
804
804
|
};
|
|
805
|
-
export declare const
|
|
805
|
+
export declare const adminListOffsetsOptionsSchema: {
|
|
806
806
|
type: string;
|
|
807
807
|
properties: {
|
|
808
808
|
topics: {
|
|
@@ -902,6 +902,6 @@ export declare const describeAclsOptionsValidator: import("ajv").ValidateFunctio
|
|
|
902
902
|
export declare const deleteAclsOptionsValidator: import("ajv").ValidateFunction<{
|
|
903
903
|
[x: string]: {};
|
|
904
904
|
}>;
|
|
905
|
-
export declare const
|
|
905
|
+
export declare const adminListOffsetsOptionsValidator: import("ajv").ValidateFunction<{
|
|
906
906
|
[x: string]: {};
|
|
907
907
|
}>;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { type AlterClientQuotasRequestEntry } from "../../apis/admin/alter-client-quotas-v1";
|
|
2
|
+
import { type AlterConfigsRequestResource } from "../../apis/admin/alter-configs-v2";
|
|
2
3
|
import { type CreatePartitionsRequestTopic } from "../../apis/admin/create-partitions-v3";
|
|
3
4
|
import { type CreateTopicsRequestTopicConfig } from "../../apis/admin/create-topics-v7";
|
|
4
|
-
import { type AlterConfigsRequestResource } from "../../apis/admin/alter-configs-v2";
|
|
5
|
-
import { type DescribeConfigsRequestResource, type DescribeConfigsResponseConfig } from "../../apis/admin/describe-configs-v4";
|
|
6
5
|
import { type DescribeClientQuotasRequestComponent } from "../../apis/admin/describe-client-quotas-v0";
|
|
6
|
+
import { type DescribeConfigsRequestResource, type DescribeConfigsResponseConfig } from "../../apis/admin/describe-configs-v4";
|
|
7
7
|
import { type DescribeLogDirsRequestTopic, type DescribeLogDirsResponse, type DescribeLogDirsResponseResult } from "../../apis/admin/describe-log-dirs-v4";
|
|
8
8
|
import { type IncrementalAlterConfigsRequestResource } from "../../apis/admin/incremental-alter-configs-v1";
|
|
9
|
-
import { type
|
|
9
|
+
import { type ConfigResourceTypeValue, type ConsumerGroupStateValue, type FetchIsolationLevelValue } from "../../apis/enumerations";
|
|
10
|
+
import { type Acl, type AclFilter } from "../../apis/types";
|
|
10
11
|
import { type Nullable, type NullableString } from "../../protocol/definitions";
|
|
11
12
|
import { type BaseOptions } from "../base/types";
|
|
12
13
|
import { type ExtendedGroupProtocolSubscription, type GroupAssignment } from "../consumer/types";
|
|
13
|
-
import { type Acl, type AclFilter } from "../../apis/types";
|
|
14
14
|
export interface BrokerAssignment {
|
|
15
15
|
partition: number;
|
|
16
16
|
brokers: number[];
|
|
@@ -173,7 +173,7 @@ export interface TopicOffsetRequest {
|
|
|
173
173
|
name: string;
|
|
174
174
|
partitions: PartitionTimestamp[];
|
|
175
175
|
}
|
|
176
|
-
export interface
|
|
176
|
+
export interface AdminListOffsetsOptions {
|
|
177
177
|
topics: TopicOffsetRequest[];
|
|
178
178
|
isolationLevel?: Nullable<FetchIsolationLevelValue>;
|
|
179
179
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type ValidateFunction } from 'ajv';
|
|
2
|
-
import { EventEmitter } from 'node:events';
|
|
3
2
|
import { type CallbackWithPromise } from "../../apis/callbacks";
|
|
4
3
|
import { type API, type Callback } from "../../apis/definitions";
|
|
5
4
|
import { type ApiVersionsResponseApi } from "../../apis/metadata/api-versions-v3";
|
|
6
5
|
import { type ClientType } from "../../diagnostic";
|
|
7
|
-
import {
|
|
6
|
+
import { TypedEventEmitter, type TypedEvents } from "../../events";
|
|
7
|
+
import { ConnectionPool, type ConnectionPoolEventPayload } from "../../network/connection-pool";
|
|
8
8
|
import { type Broker, type Connection } from "../../network/connection";
|
|
9
9
|
import { kInstance } from "../../symbols";
|
|
10
10
|
import { type Metrics } from "../metrics";
|
|
@@ -31,7 +31,24 @@ export declare const kFormatValidationErrors: unique symbol;
|
|
|
31
31
|
export declare const kPrometheus: unique symbol;
|
|
32
32
|
export declare const kClientType: unique symbol;
|
|
33
33
|
export declare const kAfterCreate: unique symbol;
|
|
34
|
-
export
|
|
34
|
+
export interface BaseEvents extends TypedEvents {
|
|
35
|
+
'client:broker:connect': (payload: ConnectionPoolEventPayload) => void;
|
|
36
|
+
'client:broker:disconnect': (payload: ConnectionPoolEventPayload) => void;
|
|
37
|
+
'client:broker:failed': (payload: ConnectionPoolEventPayload) => void;
|
|
38
|
+
'client:broker:drain': (payload: ConnectionPoolEventPayload) => void;
|
|
39
|
+
'client:broker:sasl:handshake': (payload: ConnectionPoolEventPayload & {
|
|
40
|
+
mechanisms: string[];
|
|
41
|
+
}) => void;
|
|
42
|
+
'client:broker:sasl:authentication': (payload: ConnectionPoolEventPayload & {
|
|
43
|
+
authentication: Buffer;
|
|
44
|
+
}) => void;
|
|
45
|
+
'client:broker:sasl:authentication:extended': (payload: ConnectionPoolEventPayload & {
|
|
46
|
+
authentication: Buffer;
|
|
47
|
+
}) => void;
|
|
48
|
+
'client:metadata': (metadata: ClusterMetadata) => void;
|
|
49
|
+
'client:close': () => void;
|
|
50
|
+
}
|
|
51
|
+
export declare class Base<OptionsType extends BaseOptions = BaseOptions, EventsType extends BaseEvents = BaseEvents> extends TypedEventEmitter<EventsType> {
|
|
35
52
|
#private;
|
|
36
53
|
[kInstance]: number;
|
|
37
54
|
[kClientId]: string;
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { type CallbackWithPromise } from "../../apis/callbacks";
|
|
2
2
|
import { type FetchResponse } from "../../apis/consumer/fetch-v17";
|
|
3
3
|
import { type ConnectionPool } from "../../network/connection-pool";
|
|
4
|
-
import { Base, kFetchConnections } from "../base/base";
|
|
4
|
+
import { Base, type BaseEvents, kFetchConnections } from "../base/base";
|
|
5
5
|
import { MessagesStream } from "./messages-stream";
|
|
6
6
|
import { TopicsMap } from "./topics-map";
|
|
7
7
|
import { type CommitOptions, type ConsumeOptions, type ConsumerGroupJoinPayload, type ConsumerGroupLeavePayload, type ConsumerGroupRebalancePayload, type ConsumerHeartbeatErrorPayload, type ConsumerHeartbeatPayload, type ConsumerOptions, type FetchOptions, type GetLagOptions, type GroupAssignment, type GroupOptions, type ListCommitsOptions, type ListOffsetsOptions, type Offsets, type OffsetsWithTimestamps } from "./types";
|
|
8
|
-
export
|
|
8
|
+
export interface ConsumerEvents extends BaseEvents {
|
|
9
|
+
'consumer:group:join': (payload: ConsumerGroupJoinPayload) => void;
|
|
10
|
+
'consumer:group:leave': (payload: ConsumerGroupLeavePayload) => void;
|
|
11
|
+
'consumer:group:rejoin': () => void;
|
|
12
|
+
'consumer:group:rebalance': (payload: ConsumerGroupRebalancePayload) => void;
|
|
13
|
+
'consumer:heartbeat:start': (payload?: ConsumerHeartbeatPayload) => void;
|
|
14
|
+
'consumer:heartbeat:cancel': (payload: ConsumerHeartbeatPayload) => void;
|
|
15
|
+
'consumer:heartbeat:end': (payload?: ConsumerHeartbeatPayload) => void;
|
|
16
|
+
'consumer:heartbeat:error': (payload: ConsumerHeartbeatErrorPayload) => void;
|
|
17
|
+
'consumer:lag': (lag: Offsets) => void;
|
|
18
|
+
'consumer:lag:error': (error: Error) => void;
|
|
19
|
+
}
|
|
20
|
+
export declare class Consumer<Key = Buffer, Value = Buffer, HeaderKey = Buffer, HeaderValue = Buffer> extends Base<ConsumerOptions<Key, Value, HeaderKey, HeaderValue>, ConsumerEvents> {
|
|
9
21
|
#private;
|
|
10
22
|
groupId: string;
|
|
11
23
|
generationId: number;
|
|
@@ -17,61 +29,6 @@ export declare class Consumer<Key = Buffer, Value = Buffer, HeaderKey = Buffer,
|
|
|
17
29
|
get streamsCount(): number;
|
|
18
30
|
get lastHeartbeat(): Date | null;
|
|
19
31
|
get coordinatorId(): number | null;
|
|
20
|
-
addListener(event: 'consumer:group:join', listener: (payload: ConsumerGroupJoinPayload) => void): this;
|
|
21
|
-
addListener(event: 'consumer:group:leave', listener: (payload: ConsumerGroupLeavePayload) => void): this;
|
|
22
|
-
addListener(event: 'consumer:group:rejoin', listener: () => void): this;
|
|
23
|
-
addListener(event: 'consumer:group:rebalance', listener: (payload: ConsumerGroupRebalancePayload) => void): this;
|
|
24
|
-
addListener(event: 'consumer:heartbeat:start', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
25
|
-
addListener(event: 'consumer:heartbeat:cancel', listener: (payload: ConsumerHeartbeatPayload) => void): this;
|
|
26
|
-
addListener(event: 'consumer:heartbeat:end', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
27
|
-
addListener(event: 'consumer:heartbeat:error', listener: (payload: ConsumerHeartbeatErrorPayload) => void): this;
|
|
28
|
-
addListener(event: 'consumer:lag', listener: (lag: Offsets) => void): this;
|
|
29
|
-
addListener(event: 'consumer:lag:error', listener: (error: Error) => void): this;
|
|
30
|
-
addListener(event: 'error', listener: (error: Error) => void): this;
|
|
31
|
-
on(event: 'consumer:group:join', listener: (payload: ConsumerGroupJoinPayload) => void): this;
|
|
32
|
-
on(event: 'consumer:group:leave', listener: (payload: ConsumerGroupLeavePayload) => void): this;
|
|
33
|
-
on(event: 'consumer:group:rejoin', listener: () => void): this;
|
|
34
|
-
on(event: 'consumer:group:rebalance', listener: (payload: ConsumerGroupRebalancePayload) => void): this;
|
|
35
|
-
on(event: 'consumer:heartbeat:start', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
36
|
-
on(event: 'consumer:heartbeat:cancel', listener: (payload: ConsumerHeartbeatPayload) => void): this;
|
|
37
|
-
on(event: 'consumer:heartbeat:end', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
38
|
-
on(event: 'consumer:heartbeat:error', listener: (payload: ConsumerHeartbeatErrorPayload) => void): this;
|
|
39
|
-
on(event: 'consumer:lag', listener: (lag: Offsets) => void): this;
|
|
40
|
-
on(event: 'consumer:lag:error', listener: (error: Error) => void): this;
|
|
41
|
-
on(event: 'error', listener: (error: Error) => void): this;
|
|
42
|
-
once(event: 'consumer:group:join', listener: (payload: ConsumerGroupJoinPayload) => void): this;
|
|
43
|
-
once(event: 'consumer:group:leave', listener: (payload: ConsumerGroupLeavePayload) => void): this;
|
|
44
|
-
once(event: 'consumer:group:rejoin', listener: () => void): this;
|
|
45
|
-
once(event: 'consumer:group:rebalance', listener: (payload: ConsumerGroupRebalancePayload) => void): this;
|
|
46
|
-
once(event: 'consumer:heartbeat:start', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
47
|
-
once(event: 'consumer:heartbeat:cancel', listener: (payload: ConsumerHeartbeatPayload) => void): this;
|
|
48
|
-
once(event: 'consumer:heartbeat:end', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
49
|
-
once(event: 'consumer:heartbeat:error', listener: (payload: ConsumerHeartbeatErrorPayload) => void): this;
|
|
50
|
-
once(event: 'consumer:lag', listener: (lag: Offsets) => void): this;
|
|
51
|
-
once(event: 'consumer:lag:error', listener: (error: Error) => void): this;
|
|
52
|
-
once(event: 'error', listener: (error: Error) => void): this;
|
|
53
|
-
prependListener(event: 'consumer:group:join', listener: (payload: ConsumerGroupJoinPayload) => void): this;
|
|
54
|
-
prependListener(event: 'consumer:group:leave', listener: (payload: ConsumerGroupLeavePayload) => void): this;
|
|
55
|
-
prependListener(event: 'consumer:group:rejoin', listener: () => void): this;
|
|
56
|
-
prependListener(event: 'consumer:group:rebalance', listener: (payload: ConsumerGroupRebalancePayload) => void): this;
|
|
57
|
-
prependListener(event: 'consumer:heartbeat:start', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
58
|
-
prependListener(event: 'consumer:heartbeat:cancel', listener: (payload: ConsumerHeartbeatPayload) => void): this;
|
|
59
|
-
prependListener(event: 'consumer:heartbeat:end', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
60
|
-
prependListener(event: 'consumer:heartbeat:error', listener: (payload: ConsumerHeartbeatErrorPayload) => void): this;
|
|
61
|
-
prependListener(event: 'consumer:lag', listener: (lag: Offsets) => void): this;
|
|
62
|
-
prependListener(event: 'consumer:lag:error', listener: (error: Error) => void): this;
|
|
63
|
-
prependListener(event: 'error', listener: (error: Error) => void): this;
|
|
64
|
-
prependOnceListener(event: 'consumer:group:join', listener: (payload: ConsumerGroupJoinPayload) => void): this;
|
|
65
|
-
prependOnceListener(event: 'consumer:group:leave', listener: (payload: ConsumerGroupLeavePayload) => void): this;
|
|
66
|
-
prependOnceListener(event: 'consumer:group:rejoin', listener: () => void): this;
|
|
67
|
-
prependOnceListener(event: 'consumer:group:rebalance', listener: (payload: ConsumerGroupRebalancePayload) => void): this;
|
|
68
|
-
prependOnceListener(event: 'consumer:heartbeat:start', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
69
|
-
prependOnceListener(event: 'consumer:heartbeat:cancel', listener: (payload: ConsumerHeartbeatPayload) => void): this;
|
|
70
|
-
prependOnceListener(event: 'consumer:heartbeat:end', listener: (payload?: ConsumerHeartbeatPayload) => void): this;
|
|
71
|
-
prependOnceListener(event: 'consumer:heartbeat:error', listener: (payload: ConsumerHeartbeatErrorPayload) => void): this;
|
|
72
|
-
prependOnceListener(event: 'consumer:lag', listener: (lag: Offsets) => void): this;
|
|
73
|
-
prependOnceListener(event: 'consumer:lag:error', listener: (error: Error) => void): this;
|
|
74
|
-
prependOnceListener(event: 'error', listener: (error: Error) => void): this;
|
|
75
32
|
close(force: boolean | CallbackWithPromise<void>, callback?: CallbackWithPromise<void>): void;
|
|
76
33
|
close(force?: boolean): Promise<void>;
|
|
77
34
|
isActive(): boolean;
|
|
@@ -36,24 +36,24 @@ export declare const instancesChannel: ChannelWithName<object>;
|
|
|
36
36
|
export declare const connectionsConnectsChannel: TracingChannelWithName<ConnectionDiagnosticEvent<Record<string, unknown>>>;
|
|
37
37
|
export declare const connectionsApiChannel: TracingChannelWithName<ConnectionDiagnosticEvent<Record<string, unknown>>>;
|
|
38
38
|
export declare const connectionsPoolGetsChannel: TracingChannelWithName<ConnectionPoolDiagnosticEvent<Record<string, unknown>>>;
|
|
39
|
-
export declare const baseApisChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
40
|
-
export declare const baseMetadataChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
41
|
-
export declare const adminTopicsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
42
|
-
export declare const adminGroupsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
43
|
-
export declare const adminClientQuotasChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
44
|
-
export declare const adminLogDirsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
45
|
-
export declare const adminConsumerGroupOffsetsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
46
|
-
export declare const adminConfigsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
47
|
-
export declare const adminAclsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
48
|
-
export declare const adminOffsetsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
49
|
-
export declare const producerInitIdempotentChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
50
|
-
export declare const producerSendsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
51
|
-
export declare const producerTransactionsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
52
|
-
export declare const consumerGroupChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
53
|
-
export declare const consumerHeartbeatChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
54
|
-
export declare const consumerReceivesChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
55
|
-
export declare const consumerFetchesChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
56
|
-
export declare const consumerConsumesChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
57
|
-
export declare const consumerCommitsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
58
|
-
export declare const consumerOffsetsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
59
|
-
export declare const consumerLagChannel: ChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions>, Record<string, unknown>>>;
|
|
39
|
+
export declare const baseApisChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
40
|
+
export declare const baseMetadataChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
41
|
+
export declare const adminTopicsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
42
|
+
export declare const adminGroupsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
43
|
+
export declare const adminClientQuotasChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
44
|
+
export declare const adminLogDirsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
45
|
+
export declare const adminConsumerGroupOffsetsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
46
|
+
export declare const adminConfigsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
47
|
+
export declare const adminAclsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
48
|
+
export declare const adminOffsetsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
49
|
+
export declare const producerInitIdempotentChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
50
|
+
export declare const producerSendsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
51
|
+
export declare const producerTransactionsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
52
|
+
export declare const consumerGroupChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
53
|
+
export declare const consumerHeartbeatChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
54
|
+
export declare const consumerReceivesChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
55
|
+
export declare const consumerFetchesChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
56
|
+
export declare const consumerConsumesChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
57
|
+
export declare const consumerCommitsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
58
|
+
export declare const consumerOffsetsChannel: TracingChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
59
|
+
export declare const consumerLagChannel: ChannelWithName<ClientDiagnosticEvent<Base<import("./index").BaseOptions, import("./clients/base/base").BaseEvents>, Record<string, unknown>>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
export interface TypedEvents {
|
|
3
|
+
error: (error: Error) => void;
|
|
4
|
+
}
|
|
5
|
+
export declare class TypedEventEmitter<EventsType extends TypedEvents = TypedEvents> extends EventEmitter {
|
|
6
|
+
addListener<K extends keyof EventsType>(event: K, listener: EventsType[K]): this;
|
|
7
|
+
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
8
|
+
on<K extends keyof EventsType>(event: K, listener: EventsType[K]): this;
|
|
9
|
+
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
10
|
+
once<K extends keyof EventsType>(event: K, listener: EventsType[K]): this;
|
|
11
|
+
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
12
|
+
prependListener<K extends keyof EventsType>(event: K, listener: EventsType[K]): this;
|
|
13
|
+
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
14
|
+
prependeOnceListener<K extends keyof EventsType>(event: K, listener: EventsType[K]): this;
|
|
15
|
+
prependeOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
16
|
+
off<K extends keyof EventsType>(event: K, listener: EventsType[K]): this;
|
|
17
|
+
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
18
|
+
removeListener<K extends keyof EventsType>(event: K, listener: EventsType[K]): this;
|
|
19
|
+
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
20
|
+
removeAllListeners<K extends keyof EventsType>(event: K): this;
|
|
21
|
+
removeAllListeners(event: string | symbol): this;
|
|
22
|
+
}
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
import EventEmitter from 'node:events';
|
|
2
1
|
import { type CallbackWithPromise } from "../apis/callbacks";
|
|
2
|
+
import { TypedEventEmitter, type TypedEvents } from "../events";
|
|
3
3
|
import { Connection, type Broker, type ConnectionOptions } from "./connection";
|
|
4
|
-
export
|
|
4
|
+
export interface ConnectionPoolEventPayload {
|
|
5
|
+
broker: Broker;
|
|
6
|
+
connection: Connection;
|
|
7
|
+
}
|
|
8
|
+
export interface ConnectionPoolEvents extends TypedEvents {
|
|
9
|
+
connecting: (payload: ConnectionPoolEventPayload) => void;
|
|
10
|
+
failed: (payload: ConnectionPoolEventPayload) => void;
|
|
11
|
+
connect: (payload: ConnectionPoolEventPayload) => void;
|
|
12
|
+
'sasl:handshake': (payload: ConnectionPoolEventPayload & {
|
|
13
|
+
mechanisms: string[];
|
|
14
|
+
}) => void;
|
|
15
|
+
'sasl:authentication': (payload: ConnectionPoolEventPayload & {
|
|
16
|
+
authentication?: Buffer;
|
|
17
|
+
}) => void;
|
|
18
|
+
'sasl:authentication:extended': (payload: ConnectionPoolEventPayload & {
|
|
19
|
+
authentication?: Buffer;
|
|
20
|
+
}) => void;
|
|
21
|
+
disconnect: (payload: ConnectionPoolEventPayload) => void;
|
|
22
|
+
drain: (payload: ConnectionPoolEventPayload) => void;
|
|
23
|
+
}
|
|
24
|
+
export declare class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
|
|
5
25
|
#private;
|
|
6
26
|
constructor(clientId: string, connectionOptions?: ConnectionOptions);
|
|
7
27
|
get instanceId(): number;
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
import EventEmitter from 'node:events';
|
|
2
1
|
import { type Socket } from 'node:net';
|
|
3
2
|
import { type ConnectionOptions as TLSConnectionOptions } from 'node:tls';
|
|
4
3
|
import { type CallbackWithPromise } from "../apis/callbacks";
|
|
5
4
|
import { type Callback, type ResponseParser } from "../apis/definitions";
|
|
6
5
|
import { type SASLMechanismValue } from "../apis/enumerations";
|
|
7
6
|
import { type SaslAuthenticateResponse, type SASLAuthenticationAPI } from "../apis/security/sasl-authenticate-v2";
|
|
7
|
+
import { TypedEventEmitter, type TypedEvents } from "../events";
|
|
8
|
+
import { TimeoutError } from "../errors";
|
|
8
9
|
import { Writer } from "../protocol/writer";
|
|
10
|
+
export interface ConnectionEvents extends TypedEvents {
|
|
11
|
+
connecting: () => void;
|
|
12
|
+
timeout: (error: TimeoutError) => void;
|
|
13
|
+
error: (error: Error) => void;
|
|
14
|
+
connect: () => void;
|
|
15
|
+
ready: () => void;
|
|
16
|
+
close: () => void;
|
|
17
|
+
closing: () => void;
|
|
18
|
+
'sasl:handshake': (mechanisms: string[]) => void;
|
|
19
|
+
'sasl:authentication': (authBytes?: Buffer) => void;
|
|
20
|
+
'sasl:authentication:extended': (authBytes?: Buffer) => void;
|
|
21
|
+
drain: () => void;
|
|
22
|
+
}
|
|
9
23
|
export type SASLCredentialProvider<T = string> = () => T | Promise<T>;
|
|
10
24
|
export interface Broker {
|
|
11
25
|
host: string;
|
|
@@ -60,7 +74,7 @@ export declare const defaultOptions: {
|
|
|
60
74
|
requestTimeout: number;
|
|
61
75
|
maxInflights: number;
|
|
62
76
|
};
|
|
63
|
-
export declare class Connection extends
|
|
77
|
+
export declare class Connection extends TypedEventEmitter<ConnectionEvents> {
|
|
64
78
|
#private;
|
|
65
79
|
constructor(clientId?: string, options?: ConnectionOptions);
|
|
66
80
|
get host(): string | undefined;
|
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.25.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/kafka",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.0",
|
|
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)",
|