@nathapp/nestjs-microservices 1.0.0-rc.10 → 1.0.0-rc.12
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/adapter/adapter.interface.d.ts +178 -0
- package/dist/adapter/adapter.interface.js +2 -0
- package/dist/adapter/http-service.adapter.d.ts +5 -1
- package/dist/adapter/http-service.adapter.js +8 -0
- package/dist/adapter/index.d.ts +3 -1
- package/dist/adapter/index.js +3 -1
- package/dist/adapter/micro-service-adapter-factory.d.ts +3 -2
- package/dist/adapter/micro-service-adapter-factory.js +32 -0
- package/dist/adapter/micro-service.adapter.d.ts +11 -7
- package/dist/adapter/nestjs-micro-service.adapter.d.ts +11 -0
- package/dist/adapter/nestjs-micro-service.adapter.js +21 -0
- package/dist/client/custom-client-rmq.d.ts +42 -0
- package/dist/client/custom-client-rmq.js +197 -0
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.js +3 -1
- package/dist/client/service-client.d.ts +5 -3
- package/dist/client/service-client.js +1 -0
- package/dist/enum/transport.enum.d.ts +8 -1
- package/dist/enum/transport.enum.js +8 -1
- package/dist/external/grpc-options.interface.d.ts +16 -0
- package/dist/external/grpc-options.interface.js +2 -0
- package/dist/external/kafka.interface.d.ts +1118 -0
- package/dist/external/kafka.interface.js +77 -0
- package/dist/external/mqtt-client.interface.d.ts +32 -0
- package/dist/external/mqtt-client.interface.js +3 -0
- package/dist/external/mqtt-options.interface.d.ts +55 -0
- package/dist/external/mqtt-options.interface.js +2 -0
- package/dist/external/redis.interface.d.ts +53 -0
- package/dist/external/redis.interface.js +2 -0
- package/dist/external/rmq-url.interface.d.ts +28 -0
- package/dist/external/rmq-url.interface.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/server/custom-server-rmq.d.ts +27 -0
- package/dist/server/custom-server-rmq.js +159 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +7 -0
- package/dist/server/server-keepalive.d.ts +7 -0
- package/dist/server/server-keepalive.js +21 -0
- package/dist/strategy/microservice-jwt-strategy-provider.d.ts +2 -5
- package/lib/external/README.md +1 -0
- package/package.json +50 -6
|
@@ -0,0 +1,1118 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import * as net from 'net';
|
|
5
|
+
import * as tls from 'tls';
|
|
6
|
+
type Without<T, U> = {
|
|
7
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
|
8
|
+
};
|
|
9
|
+
type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
|
|
10
|
+
export declare class Kafka {
|
|
11
|
+
constructor(config: KafkaConfig);
|
|
12
|
+
producer(config?: ProducerConfig): Producer;
|
|
13
|
+
consumer(config: ConsumerConfig): Consumer;
|
|
14
|
+
admin(config?: AdminConfig): Admin;
|
|
15
|
+
logger(): Logger;
|
|
16
|
+
}
|
|
17
|
+
export type BrokersFunction = () => string[] | Promise<string[]>;
|
|
18
|
+
type SaslAuthenticationRequest = {
|
|
19
|
+
encode: () => Buffer | Promise<Buffer>;
|
|
20
|
+
};
|
|
21
|
+
type SaslAuthenticationResponse<ParseResult> = {
|
|
22
|
+
decode: (rawResponse: Buffer) => Buffer | Promise<Buffer>;
|
|
23
|
+
parse: (data: Buffer) => ParseResult;
|
|
24
|
+
};
|
|
25
|
+
type Authenticator = {
|
|
26
|
+
authenticate: () => Promise<void>;
|
|
27
|
+
};
|
|
28
|
+
type AuthenticationProviderArgs = {
|
|
29
|
+
host: string;
|
|
30
|
+
port: number;
|
|
31
|
+
logger: Logger;
|
|
32
|
+
saslAuthenticate: <ParseResult>(request: SaslAuthenticationRequest, response?: SaslAuthenticationResponse<ParseResult>) => Promise<ParseResult | void>;
|
|
33
|
+
};
|
|
34
|
+
type Mechanism = {
|
|
35
|
+
mechanism: string;
|
|
36
|
+
authenticationProvider: (args: AuthenticationProviderArgs) => Authenticator;
|
|
37
|
+
};
|
|
38
|
+
export interface KafkaConfig {
|
|
39
|
+
brokers: string[] | BrokersFunction;
|
|
40
|
+
ssl?: tls.ConnectionOptions | boolean;
|
|
41
|
+
sasl?: SASLOptions | Mechanism;
|
|
42
|
+
clientId?: string;
|
|
43
|
+
connectionTimeout?: number;
|
|
44
|
+
authenticationTimeout?: number;
|
|
45
|
+
reauthenticationThreshold?: number;
|
|
46
|
+
requestTimeout?: number;
|
|
47
|
+
enforceRequestTimeout?: boolean;
|
|
48
|
+
retry?: RetryOptions;
|
|
49
|
+
socketFactory?: ISocketFactory;
|
|
50
|
+
logLevel?: logLevel;
|
|
51
|
+
logCreator?: logCreator;
|
|
52
|
+
}
|
|
53
|
+
export interface ISocketFactoryArgs {
|
|
54
|
+
host: string;
|
|
55
|
+
port: number;
|
|
56
|
+
ssl: tls.ConnectionOptions;
|
|
57
|
+
onConnect: () => void;
|
|
58
|
+
}
|
|
59
|
+
export type ISocketFactory = (args: ISocketFactoryArgs) => net.Socket;
|
|
60
|
+
export interface OauthbearerProviderResponse {
|
|
61
|
+
value: string;
|
|
62
|
+
}
|
|
63
|
+
type SASLMechanismOptionsMap = {
|
|
64
|
+
plain: {
|
|
65
|
+
username: string;
|
|
66
|
+
password: string;
|
|
67
|
+
};
|
|
68
|
+
'scram-sha-256': {
|
|
69
|
+
username: string;
|
|
70
|
+
password: string;
|
|
71
|
+
};
|
|
72
|
+
'scram-sha-512': {
|
|
73
|
+
username: string;
|
|
74
|
+
password: string;
|
|
75
|
+
};
|
|
76
|
+
aws: {
|
|
77
|
+
authorizationIdentity: string;
|
|
78
|
+
accessKeyId: string;
|
|
79
|
+
secretAccessKey: string;
|
|
80
|
+
sessionToken?: string;
|
|
81
|
+
};
|
|
82
|
+
oauthbearer: {
|
|
83
|
+
oauthBearerProvider: () => Promise<OauthbearerProviderResponse>;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
export type SASLMechanism = keyof SASLMechanismOptionsMap;
|
|
87
|
+
type SASLMechanismOptions<T> = T extends SASLMechanism ? {
|
|
88
|
+
mechanism: T;
|
|
89
|
+
} & SASLMechanismOptionsMap[T] : never;
|
|
90
|
+
export type SASLOptions = SASLMechanismOptions<SASLMechanism>;
|
|
91
|
+
export interface ProducerConfig {
|
|
92
|
+
createPartitioner?: ICustomPartitioner;
|
|
93
|
+
retry?: RetryOptions;
|
|
94
|
+
metadataMaxAge?: number;
|
|
95
|
+
allowAutoTopicCreation?: boolean;
|
|
96
|
+
idempotent?: boolean;
|
|
97
|
+
transactionalId?: string;
|
|
98
|
+
transactionTimeout?: number;
|
|
99
|
+
maxInFlightRequests?: number;
|
|
100
|
+
}
|
|
101
|
+
export interface Message {
|
|
102
|
+
key?: Buffer | string | null;
|
|
103
|
+
value: Buffer | string | null;
|
|
104
|
+
partition?: number;
|
|
105
|
+
headers?: IHeaders;
|
|
106
|
+
timestamp?: string;
|
|
107
|
+
}
|
|
108
|
+
export interface PartitionerArgs {
|
|
109
|
+
topic: string;
|
|
110
|
+
partitionMetadata: PartitionMetadata[];
|
|
111
|
+
message: Message;
|
|
112
|
+
}
|
|
113
|
+
export type ICustomPartitioner = () => (args: PartitionerArgs) => number;
|
|
114
|
+
export type DefaultPartitioner = ICustomPartitioner;
|
|
115
|
+
export type LegacyPartitioner = ICustomPartitioner;
|
|
116
|
+
export declare let Partitioners: {
|
|
117
|
+
DefaultPartitioner: DefaultPartitioner;
|
|
118
|
+
LegacyPartitioner: LegacyPartitioner;
|
|
119
|
+
JavaCompatiblePartitioner: DefaultPartitioner;
|
|
120
|
+
};
|
|
121
|
+
export type PartitionMetadata = {
|
|
122
|
+
partitionErrorCode: number;
|
|
123
|
+
partitionId: number;
|
|
124
|
+
leader: number;
|
|
125
|
+
replicas: number[];
|
|
126
|
+
isr: number[];
|
|
127
|
+
offlineReplicas?: number[];
|
|
128
|
+
};
|
|
129
|
+
export interface IHeaders {
|
|
130
|
+
[key: string]: Buffer | string | (Buffer | string)[] | undefined;
|
|
131
|
+
}
|
|
132
|
+
export interface ConsumerConfig {
|
|
133
|
+
groupId: string;
|
|
134
|
+
partitionAssigners?: PartitionAssigner[];
|
|
135
|
+
metadataMaxAge?: number;
|
|
136
|
+
sessionTimeout?: number;
|
|
137
|
+
rebalanceTimeout?: number;
|
|
138
|
+
heartbeatInterval?: number;
|
|
139
|
+
maxBytesPerPartition?: number;
|
|
140
|
+
minBytes?: number;
|
|
141
|
+
maxBytes?: number;
|
|
142
|
+
maxWaitTimeInMs?: number;
|
|
143
|
+
retry?: RetryOptions & {
|
|
144
|
+
restartOnFailure?: (err: Error) => Promise<boolean>;
|
|
145
|
+
};
|
|
146
|
+
allowAutoTopicCreation?: boolean;
|
|
147
|
+
maxInFlightRequests?: number;
|
|
148
|
+
readUncommitted?: boolean;
|
|
149
|
+
rackId?: string;
|
|
150
|
+
}
|
|
151
|
+
export type PartitionAssigner = (config: {
|
|
152
|
+
cluster: Cluster;
|
|
153
|
+
groupId: string;
|
|
154
|
+
logger: Logger;
|
|
155
|
+
}) => Assigner;
|
|
156
|
+
export interface CoordinatorMetadata {
|
|
157
|
+
errorCode: number;
|
|
158
|
+
coordinator: {
|
|
159
|
+
nodeId: number;
|
|
160
|
+
host: string;
|
|
161
|
+
port: number;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
export type Cluster = {
|
|
165
|
+
getNodeIds(): number[];
|
|
166
|
+
metadata(): Promise<BrokerMetadata>;
|
|
167
|
+
removeBroker(options: {
|
|
168
|
+
host: string;
|
|
169
|
+
port: number;
|
|
170
|
+
}): void;
|
|
171
|
+
addMultipleTargetTopics(topics: string[]): Promise<void>;
|
|
172
|
+
isConnected(): boolean;
|
|
173
|
+
connect(): Promise<void>;
|
|
174
|
+
disconnect(): Promise<void>;
|
|
175
|
+
refreshMetadata(): Promise<void>;
|
|
176
|
+
refreshMetadataIfNecessary(): Promise<void>;
|
|
177
|
+
addTargetTopic(topic: string): Promise<void>;
|
|
178
|
+
findBroker(node: {
|
|
179
|
+
nodeId: string;
|
|
180
|
+
}): Promise<Broker>;
|
|
181
|
+
findControllerBroker(): Promise<Broker>;
|
|
182
|
+
findTopicPartitionMetadata(topic: string): PartitionMetadata[];
|
|
183
|
+
findLeaderForPartitions(topic: string, partitions: number[]): {
|
|
184
|
+
[leader: string]: number[];
|
|
185
|
+
};
|
|
186
|
+
findGroupCoordinator(group: {
|
|
187
|
+
groupId: string;
|
|
188
|
+
}): Promise<Broker>;
|
|
189
|
+
findGroupCoordinatorMetadata(group: {
|
|
190
|
+
groupId: string;
|
|
191
|
+
}): Promise<CoordinatorMetadata>;
|
|
192
|
+
defaultOffset(config: {
|
|
193
|
+
fromBeginning: boolean;
|
|
194
|
+
}): number;
|
|
195
|
+
fetchTopicsOffset(topics: Array<{
|
|
196
|
+
topic: string;
|
|
197
|
+
partitions: Array<{
|
|
198
|
+
partition: number;
|
|
199
|
+
}>;
|
|
200
|
+
} & XOR<{
|
|
201
|
+
fromBeginning: boolean;
|
|
202
|
+
}, {
|
|
203
|
+
fromTimestamp: number;
|
|
204
|
+
}>>): Promise<TopicOffsets[]>;
|
|
205
|
+
};
|
|
206
|
+
export type Assignment = {
|
|
207
|
+
[topic: string]: number[];
|
|
208
|
+
};
|
|
209
|
+
export type GroupMember = {
|
|
210
|
+
memberId: string;
|
|
211
|
+
memberMetadata: Buffer;
|
|
212
|
+
};
|
|
213
|
+
export type GroupMemberAssignment = {
|
|
214
|
+
memberId: string;
|
|
215
|
+
memberAssignment: Buffer;
|
|
216
|
+
};
|
|
217
|
+
export type GroupState = {
|
|
218
|
+
name: string;
|
|
219
|
+
metadata: Buffer;
|
|
220
|
+
};
|
|
221
|
+
export type Assigner = {
|
|
222
|
+
name: string;
|
|
223
|
+
version: number;
|
|
224
|
+
assign(group: {
|
|
225
|
+
members: GroupMember[];
|
|
226
|
+
topics: string[];
|
|
227
|
+
}): Promise<GroupMemberAssignment[]>;
|
|
228
|
+
protocol(subscription: {
|
|
229
|
+
topics: string[];
|
|
230
|
+
}): GroupState;
|
|
231
|
+
};
|
|
232
|
+
export interface RetryOptions {
|
|
233
|
+
maxRetryTime?: number;
|
|
234
|
+
initialRetryTime?: number;
|
|
235
|
+
factor?: number;
|
|
236
|
+
multiplier?: number;
|
|
237
|
+
retries?: number;
|
|
238
|
+
restartOnFailure?: (e: Error) => Promise<boolean>;
|
|
239
|
+
}
|
|
240
|
+
export interface AdminConfig {
|
|
241
|
+
retry?: RetryOptions;
|
|
242
|
+
}
|
|
243
|
+
export interface ITopicConfig {
|
|
244
|
+
topic: string;
|
|
245
|
+
numPartitions?: number;
|
|
246
|
+
replicationFactor?: number;
|
|
247
|
+
replicaAssignment?: object[];
|
|
248
|
+
configEntries?: IResourceConfigEntry[];
|
|
249
|
+
}
|
|
250
|
+
export interface ITopicPartitionConfig {
|
|
251
|
+
topic: string;
|
|
252
|
+
count: number;
|
|
253
|
+
assignments?: Array<Array<number>>;
|
|
254
|
+
}
|
|
255
|
+
export interface ITopicMetadata {
|
|
256
|
+
name: string;
|
|
257
|
+
partitions: PartitionMetadata[];
|
|
258
|
+
}
|
|
259
|
+
export declare enum AclResourceTypes {
|
|
260
|
+
UNKNOWN = 0,
|
|
261
|
+
ANY = 1,
|
|
262
|
+
TOPIC = 2,
|
|
263
|
+
GROUP = 3,
|
|
264
|
+
CLUSTER = 4,
|
|
265
|
+
TRANSACTIONAL_ID = 5,
|
|
266
|
+
DELEGATION_TOKEN = 6
|
|
267
|
+
}
|
|
268
|
+
export declare enum ConfigResourceTypes {
|
|
269
|
+
UNKNOWN = 0,
|
|
270
|
+
TOPIC = 2,
|
|
271
|
+
BROKER = 4,
|
|
272
|
+
BROKER_LOGGER = 8
|
|
273
|
+
}
|
|
274
|
+
export declare enum ConfigSource {
|
|
275
|
+
UNKNOWN = 0,
|
|
276
|
+
TOPIC_CONFIG = 1,
|
|
277
|
+
DYNAMIC_BROKER_CONFIG = 2,
|
|
278
|
+
DYNAMIC_DEFAULT_BROKER_CONFIG = 3,
|
|
279
|
+
STATIC_BROKER_CONFIG = 4,
|
|
280
|
+
DEFAULT_CONFIG = 5,
|
|
281
|
+
DYNAMIC_BROKER_LOGGER_CONFIG = 6
|
|
282
|
+
}
|
|
283
|
+
export declare enum AclPermissionTypes {
|
|
284
|
+
UNKNOWN = 0,
|
|
285
|
+
ANY = 1,
|
|
286
|
+
DENY = 2,
|
|
287
|
+
ALLOW = 3
|
|
288
|
+
}
|
|
289
|
+
export declare enum AclOperationTypes {
|
|
290
|
+
UNKNOWN = 0,
|
|
291
|
+
ANY = 1,
|
|
292
|
+
ALL = 2,
|
|
293
|
+
READ = 3,
|
|
294
|
+
WRITE = 4,
|
|
295
|
+
CREATE = 5,
|
|
296
|
+
DELETE = 6,
|
|
297
|
+
ALTER = 7,
|
|
298
|
+
DESCRIBE = 8,
|
|
299
|
+
CLUSTER_ACTION = 9,
|
|
300
|
+
DESCRIBE_CONFIGS = 10,
|
|
301
|
+
ALTER_CONFIGS = 11,
|
|
302
|
+
IDEMPOTENT_WRITE = 12
|
|
303
|
+
}
|
|
304
|
+
export declare enum ResourcePatternTypes {
|
|
305
|
+
UNKNOWN = 0,
|
|
306
|
+
ANY = 1,
|
|
307
|
+
MATCH = 2,
|
|
308
|
+
LITERAL = 3,
|
|
309
|
+
PREFIXED = 4
|
|
310
|
+
}
|
|
311
|
+
export interface ResourceConfigQuery {
|
|
312
|
+
type: ConfigResourceTypes;
|
|
313
|
+
name: string;
|
|
314
|
+
configNames?: string[];
|
|
315
|
+
}
|
|
316
|
+
export interface ConfigEntries {
|
|
317
|
+
configName: string;
|
|
318
|
+
configValue: string;
|
|
319
|
+
isDefault: boolean;
|
|
320
|
+
configSource: ConfigSource;
|
|
321
|
+
isSensitive: boolean;
|
|
322
|
+
readOnly: boolean;
|
|
323
|
+
configSynonyms: ConfigSynonyms[];
|
|
324
|
+
}
|
|
325
|
+
export interface ConfigSynonyms {
|
|
326
|
+
configName: string;
|
|
327
|
+
configValue: string;
|
|
328
|
+
configSource: ConfigSource;
|
|
329
|
+
}
|
|
330
|
+
export interface DescribeConfigResponse {
|
|
331
|
+
resources: {
|
|
332
|
+
configEntries: ConfigEntries[];
|
|
333
|
+
errorCode: number;
|
|
334
|
+
errorMessage: string;
|
|
335
|
+
resourceName: string;
|
|
336
|
+
resourceType: ConfigResourceTypes;
|
|
337
|
+
}[];
|
|
338
|
+
throttleTime: number;
|
|
339
|
+
}
|
|
340
|
+
export interface IResourceConfigEntry {
|
|
341
|
+
name: string;
|
|
342
|
+
value: string;
|
|
343
|
+
}
|
|
344
|
+
export interface IResourceConfig {
|
|
345
|
+
type: ConfigResourceTypes;
|
|
346
|
+
name: string;
|
|
347
|
+
configEntries: IResourceConfigEntry[];
|
|
348
|
+
}
|
|
349
|
+
type ValueOf<T> = T[keyof T];
|
|
350
|
+
export type AdminEvents = {
|
|
351
|
+
CONNECT: 'admin.connect';
|
|
352
|
+
DISCONNECT: 'admin.disconnect';
|
|
353
|
+
REQUEST: 'admin.network.request';
|
|
354
|
+
REQUEST_TIMEOUT: 'admin.network.request_timeout';
|
|
355
|
+
REQUEST_QUEUE_SIZE: 'admin.network.request_queue_size';
|
|
356
|
+
};
|
|
357
|
+
export interface InstrumentationEvent<T> {
|
|
358
|
+
id: string;
|
|
359
|
+
type: string;
|
|
360
|
+
timestamp: number;
|
|
361
|
+
payload: T;
|
|
362
|
+
}
|
|
363
|
+
export type RemoveInstrumentationEventListener<T> = () => void;
|
|
364
|
+
export type ConnectEvent = InstrumentationEvent<null>;
|
|
365
|
+
export type DisconnectEvent = InstrumentationEvent<null>;
|
|
366
|
+
export type RequestEvent = InstrumentationEvent<{
|
|
367
|
+
apiKey: number;
|
|
368
|
+
apiName: string;
|
|
369
|
+
apiVersion: number;
|
|
370
|
+
broker: string;
|
|
371
|
+
clientId: string;
|
|
372
|
+
correlationId: number;
|
|
373
|
+
createdAt: number;
|
|
374
|
+
duration: number;
|
|
375
|
+
pendingDuration: number;
|
|
376
|
+
sentAt: number;
|
|
377
|
+
size: number;
|
|
378
|
+
}>;
|
|
379
|
+
export type RequestTimeoutEvent = InstrumentationEvent<{
|
|
380
|
+
apiKey: number;
|
|
381
|
+
apiName: string;
|
|
382
|
+
apiVersion: number;
|
|
383
|
+
broker: string;
|
|
384
|
+
clientId: string;
|
|
385
|
+
correlationId: number;
|
|
386
|
+
createdAt: number;
|
|
387
|
+
pendingDuration: number;
|
|
388
|
+
sentAt: number;
|
|
389
|
+
}>;
|
|
390
|
+
export type RequestQueueSizeEvent = InstrumentationEvent<{
|
|
391
|
+
broker: string;
|
|
392
|
+
clientId: string;
|
|
393
|
+
queueSize: number;
|
|
394
|
+
}>;
|
|
395
|
+
export type SeekEntry = PartitionOffset;
|
|
396
|
+
export type FetchOffsetsPartition = PartitionOffset & {
|
|
397
|
+
metadata: string | null;
|
|
398
|
+
};
|
|
399
|
+
export interface Acl {
|
|
400
|
+
principal: string;
|
|
401
|
+
host: string;
|
|
402
|
+
operation: AclOperationTypes;
|
|
403
|
+
permissionType: AclPermissionTypes;
|
|
404
|
+
}
|
|
405
|
+
export interface AclResource {
|
|
406
|
+
resourceType: AclResourceTypes;
|
|
407
|
+
resourceName: string;
|
|
408
|
+
resourcePatternType: ResourcePatternTypes;
|
|
409
|
+
}
|
|
410
|
+
export type AclEntry = Acl & AclResource;
|
|
411
|
+
export type DescribeAclResource = AclResource & {
|
|
412
|
+
acls: Acl[];
|
|
413
|
+
};
|
|
414
|
+
export interface DescribeAclResponse {
|
|
415
|
+
throttleTime: number;
|
|
416
|
+
errorCode: number;
|
|
417
|
+
errorMessage?: string;
|
|
418
|
+
resources: DescribeAclResource[];
|
|
419
|
+
}
|
|
420
|
+
export interface AclFilter {
|
|
421
|
+
resourceType: AclResourceTypes;
|
|
422
|
+
resourceName?: string;
|
|
423
|
+
resourcePatternType: ResourcePatternTypes;
|
|
424
|
+
principal?: string;
|
|
425
|
+
host?: string;
|
|
426
|
+
operation: AclOperationTypes;
|
|
427
|
+
permissionType: AclPermissionTypes;
|
|
428
|
+
}
|
|
429
|
+
export interface MatchingAcl {
|
|
430
|
+
errorCode: number;
|
|
431
|
+
errorMessage?: string;
|
|
432
|
+
resourceType: AclResourceTypes;
|
|
433
|
+
resourceName: string;
|
|
434
|
+
resourcePatternType: ResourcePatternTypes;
|
|
435
|
+
principal: string;
|
|
436
|
+
host: string;
|
|
437
|
+
operation: AclOperationTypes;
|
|
438
|
+
permissionType: AclPermissionTypes;
|
|
439
|
+
}
|
|
440
|
+
export interface DeleteAclFilterResponses {
|
|
441
|
+
errorCode: number;
|
|
442
|
+
errorMessage?: string;
|
|
443
|
+
matchingAcls: MatchingAcl[];
|
|
444
|
+
}
|
|
445
|
+
export interface DeleteAclResponse {
|
|
446
|
+
throttleTime: number;
|
|
447
|
+
filterResponses: DeleteAclFilterResponses[];
|
|
448
|
+
}
|
|
449
|
+
export type Admin = {
|
|
450
|
+
connect(): Promise<void>;
|
|
451
|
+
disconnect(): Promise<void>;
|
|
452
|
+
listTopics(): Promise<string[]>;
|
|
453
|
+
createTopics(options: {
|
|
454
|
+
validateOnly?: boolean;
|
|
455
|
+
waitForLeaders?: boolean;
|
|
456
|
+
timeout?: number;
|
|
457
|
+
topics: ITopicConfig[];
|
|
458
|
+
}): Promise<boolean>;
|
|
459
|
+
deleteTopics(options: {
|
|
460
|
+
topics: string[];
|
|
461
|
+
timeout?: number;
|
|
462
|
+
}): Promise<void>;
|
|
463
|
+
createPartitions(options: {
|
|
464
|
+
validateOnly?: boolean;
|
|
465
|
+
timeout?: number;
|
|
466
|
+
topicPartitions: ITopicPartitionConfig[];
|
|
467
|
+
}): Promise<boolean>;
|
|
468
|
+
fetchTopicMetadata(options?: {
|
|
469
|
+
topics: string[];
|
|
470
|
+
}): Promise<{
|
|
471
|
+
topics: Array<ITopicMetadata>;
|
|
472
|
+
}>;
|
|
473
|
+
fetchOffsets(options: {
|
|
474
|
+
groupId: string;
|
|
475
|
+
topics?: string[];
|
|
476
|
+
resolveOffsets?: boolean;
|
|
477
|
+
}): Promise<Array<{
|
|
478
|
+
topic: string;
|
|
479
|
+
partitions: FetchOffsetsPartition[];
|
|
480
|
+
}>>;
|
|
481
|
+
fetchTopicOffsets(topic: string): Promise<Array<SeekEntry & {
|
|
482
|
+
high: string;
|
|
483
|
+
low: string;
|
|
484
|
+
}>>;
|
|
485
|
+
fetchTopicOffsetsByTimestamp(topic: string, timestamp?: number): Promise<Array<SeekEntry>>;
|
|
486
|
+
describeCluster(): Promise<{
|
|
487
|
+
brokers: Array<{
|
|
488
|
+
nodeId: number;
|
|
489
|
+
host: string;
|
|
490
|
+
port: number;
|
|
491
|
+
}>;
|
|
492
|
+
controller: number | null;
|
|
493
|
+
clusterId: string;
|
|
494
|
+
}>;
|
|
495
|
+
setOffsets(options: {
|
|
496
|
+
groupId: string;
|
|
497
|
+
topic: string;
|
|
498
|
+
partitions: SeekEntry[];
|
|
499
|
+
}): Promise<void>;
|
|
500
|
+
resetOffsets(options: {
|
|
501
|
+
groupId: string;
|
|
502
|
+
topic: string;
|
|
503
|
+
earliest: boolean;
|
|
504
|
+
}): Promise<void>;
|
|
505
|
+
describeConfigs(configs: {
|
|
506
|
+
resources: ResourceConfigQuery[];
|
|
507
|
+
includeSynonyms: boolean;
|
|
508
|
+
}): Promise<DescribeConfigResponse>;
|
|
509
|
+
alterConfigs(configs: {
|
|
510
|
+
validateOnly: boolean;
|
|
511
|
+
resources: IResourceConfig[];
|
|
512
|
+
}): Promise<any>;
|
|
513
|
+
listGroups(): Promise<{
|
|
514
|
+
groups: GroupOverview[];
|
|
515
|
+
}>;
|
|
516
|
+
deleteGroups(groupIds: string[]): Promise<DeleteGroupsResult[]>;
|
|
517
|
+
describeGroups(groupIds: string[]): Promise<GroupDescriptions>;
|
|
518
|
+
describeAcls(options: AclFilter): Promise<DescribeAclResponse>;
|
|
519
|
+
deleteAcls(options: {
|
|
520
|
+
filters: AclFilter[];
|
|
521
|
+
}): Promise<DeleteAclResponse>;
|
|
522
|
+
createAcls(options: {
|
|
523
|
+
acl: AclEntry[];
|
|
524
|
+
}): Promise<boolean>;
|
|
525
|
+
deleteTopicRecords(options: {
|
|
526
|
+
topic: string;
|
|
527
|
+
partitions: SeekEntry[];
|
|
528
|
+
}): Promise<void>;
|
|
529
|
+
logger(): Logger;
|
|
530
|
+
on(eventName: AdminEvents['CONNECT'], listener: (event: ConnectEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
531
|
+
on(eventName: AdminEvents['DISCONNECT'], listener: (event: DisconnectEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
532
|
+
on(eventName: AdminEvents['REQUEST'], listener: (event: RequestEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
533
|
+
on(eventName: AdminEvents['REQUEST_QUEUE_SIZE'], listener: (event: RequestQueueSizeEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
534
|
+
on(eventName: AdminEvents['REQUEST_TIMEOUT'], listener: (event: RequestTimeoutEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
535
|
+
on(eventName: ValueOf<AdminEvents>, listener: (event: InstrumentationEvent<any>) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
536
|
+
readonly events: AdminEvents;
|
|
537
|
+
};
|
|
538
|
+
export declare let PartitionAssigners: {
|
|
539
|
+
roundRobin: PartitionAssigner;
|
|
540
|
+
};
|
|
541
|
+
export interface ISerializer<T> {
|
|
542
|
+
encode(value: T): Buffer;
|
|
543
|
+
decode(buffer: Buffer): T | null;
|
|
544
|
+
}
|
|
545
|
+
export type MemberMetadata = {
|
|
546
|
+
version: number;
|
|
547
|
+
topics: string[];
|
|
548
|
+
userData: Buffer;
|
|
549
|
+
};
|
|
550
|
+
export type MemberAssignment = {
|
|
551
|
+
version: number;
|
|
552
|
+
assignment: Assignment;
|
|
553
|
+
userData: Buffer;
|
|
554
|
+
};
|
|
555
|
+
export declare let AssignerProtocol: {
|
|
556
|
+
MemberMetadata: ISerializer<MemberMetadata>;
|
|
557
|
+
MemberAssignment: ISerializer<MemberAssignment>;
|
|
558
|
+
};
|
|
559
|
+
export declare enum logLevel {
|
|
560
|
+
NOTHING = 0,
|
|
561
|
+
ERROR = 1,
|
|
562
|
+
WARN = 2,
|
|
563
|
+
INFO = 4,
|
|
564
|
+
DEBUG = 5
|
|
565
|
+
}
|
|
566
|
+
export interface LogEntry {
|
|
567
|
+
namespace: string;
|
|
568
|
+
level: logLevel;
|
|
569
|
+
label: string;
|
|
570
|
+
log: LoggerEntryContent;
|
|
571
|
+
}
|
|
572
|
+
export interface LoggerEntryContent {
|
|
573
|
+
readonly timestamp: string;
|
|
574
|
+
readonly message: string;
|
|
575
|
+
[key: string]: any;
|
|
576
|
+
}
|
|
577
|
+
export type logCreator = (logLevel: logLevel) => (entry: LogEntry) => void;
|
|
578
|
+
export type Logger = {
|
|
579
|
+
info: (message: string, extra?: object) => void;
|
|
580
|
+
error: (message: string, extra?: object) => void;
|
|
581
|
+
warn: (message: string, extra?: object) => void;
|
|
582
|
+
debug: (message: string, extra?: object) => void;
|
|
583
|
+
namespace: (namespace: string, logLevel?: logLevel) => Logger;
|
|
584
|
+
setLogLevel: (logLevel: logLevel) => void;
|
|
585
|
+
};
|
|
586
|
+
export interface BrokerMetadata {
|
|
587
|
+
brokers: Array<{
|
|
588
|
+
nodeId: number;
|
|
589
|
+
host: string;
|
|
590
|
+
port: number;
|
|
591
|
+
rack?: string;
|
|
592
|
+
}>;
|
|
593
|
+
topicMetadata: Array<{
|
|
594
|
+
topicErrorCode: number;
|
|
595
|
+
topic: string;
|
|
596
|
+
partitionMetadata: PartitionMetadata[];
|
|
597
|
+
}>;
|
|
598
|
+
}
|
|
599
|
+
export interface ApiVersions {
|
|
600
|
+
[apiKey: number]: {
|
|
601
|
+
minVersion: number;
|
|
602
|
+
maxVersion: number;
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
export type Broker = {
|
|
606
|
+
isConnected(): boolean;
|
|
607
|
+
connect(): Promise<void>;
|
|
608
|
+
disconnect(): Promise<void>;
|
|
609
|
+
apiVersions(): Promise<ApiVersions>;
|
|
610
|
+
metadata(topics: string[]): Promise<BrokerMetadata>;
|
|
611
|
+
describeGroups: (options: {
|
|
612
|
+
groupIds: string[];
|
|
613
|
+
}) => Promise<any>;
|
|
614
|
+
offsetCommit(request: {
|
|
615
|
+
groupId: string;
|
|
616
|
+
groupGenerationId: number;
|
|
617
|
+
memberId: string;
|
|
618
|
+
retentionTime?: number;
|
|
619
|
+
topics: TopicOffsets[];
|
|
620
|
+
}): Promise<any>;
|
|
621
|
+
offsetFetch(request: {
|
|
622
|
+
groupId: string;
|
|
623
|
+
topics: TopicOffsets[];
|
|
624
|
+
}): Promise<{
|
|
625
|
+
responses: TopicOffsets[];
|
|
626
|
+
}>;
|
|
627
|
+
fetch(request: {
|
|
628
|
+
replicaId?: number;
|
|
629
|
+
isolationLevel?: number;
|
|
630
|
+
maxWaitTime?: number;
|
|
631
|
+
minBytes?: number;
|
|
632
|
+
maxBytes?: number;
|
|
633
|
+
topics: Array<{
|
|
634
|
+
topic: string;
|
|
635
|
+
partitions: Array<{
|
|
636
|
+
partition: number;
|
|
637
|
+
fetchOffset: string;
|
|
638
|
+
maxBytes: number;
|
|
639
|
+
}>;
|
|
640
|
+
}>;
|
|
641
|
+
rackId?: string;
|
|
642
|
+
}): Promise<any>;
|
|
643
|
+
produce(request: {
|
|
644
|
+
topicData: Array<{
|
|
645
|
+
topic: string;
|
|
646
|
+
partitions: Array<{
|
|
647
|
+
partition: number;
|
|
648
|
+
firstSequence?: number;
|
|
649
|
+
messages: Message[];
|
|
650
|
+
}>;
|
|
651
|
+
}>;
|
|
652
|
+
transactionalId?: string;
|
|
653
|
+
producerId?: number;
|
|
654
|
+
producerEpoch?: number;
|
|
655
|
+
acks?: number;
|
|
656
|
+
timeout?: number;
|
|
657
|
+
compression?: CompressionTypes;
|
|
658
|
+
}): Promise<any>;
|
|
659
|
+
};
|
|
660
|
+
interface MessageSetEntry {
|
|
661
|
+
key: Buffer | null;
|
|
662
|
+
value: Buffer | null;
|
|
663
|
+
timestamp: string;
|
|
664
|
+
attributes: number;
|
|
665
|
+
offset: string;
|
|
666
|
+
size: number;
|
|
667
|
+
headers?: never;
|
|
668
|
+
}
|
|
669
|
+
interface RecordBatchEntry {
|
|
670
|
+
key: Buffer | null;
|
|
671
|
+
value: Buffer | null;
|
|
672
|
+
timestamp: string;
|
|
673
|
+
attributes: number;
|
|
674
|
+
offset: string;
|
|
675
|
+
headers: IHeaders;
|
|
676
|
+
size?: never;
|
|
677
|
+
}
|
|
678
|
+
export type KafkaMessage = MessageSetEntry | RecordBatchEntry;
|
|
679
|
+
export interface ProducerRecord {
|
|
680
|
+
topic: string;
|
|
681
|
+
messages: Message[];
|
|
682
|
+
acks?: number;
|
|
683
|
+
timeout?: number;
|
|
684
|
+
compression?: CompressionTypes;
|
|
685
|
+
}
|
|
686
|
+
export type RecordMetadata = {
|
|
687
|
+
topicName: string;
|
|
688
|
+
partition: number;
|
|
689
|
+
errorCode: number;
|
|
690
|
+
offset?: string;
|
|
691
|
+
timestamp?: string;
|
|
692
|
+
baseOffset?: string;
|
|
693
|
+
logAppendTime?: string;
|
|
694
|
+
logStartOffset?: string;
|
|
695
|
+
};
|
|
696
|
+
export interface TopicMessages {
|
|
697
|
+
topic: string;
|
|
698
|
+
messages: Message[];
|
|
699
|
+
}
|
|
700
|
+
export interface ProducerBatch {
|
|
701
|
+
acks?: number;
|
|
702
|
+
timeout?: number;
|
|
703
|
+
compression?: CompressionTypes;
|
|
704
|
+
topicMessages?: TopicMessages[];
|
|
705
|
+
}
|
|
706
|
+
export interface PartitionOffset {
|
|
707
|
+
partition: number;
|
|
708
|
+
offset: string;
|
|
709
|
+
}
|
|
710
|
+
export interface TopicOffsets {
|
|
711
|
+
topic: string;
|
|
712
|
+
partitions: PartitionOffset[];
|
|
713
|
+
}
|
|
714
|
+
export interface Offsets {
|
|
715
|
+
topics: TopicOffsets[];
|
|
716
|
+
}
|
|
717
|
+
type Sender = {
|
|
718
|
+
send(record: ProducerRecord): Promise<RecordMetadata[]>;
|
|
719
|
+
sendBatch(batch: ProducerBatch): Promise<RecordMetadata[]>;
|
|
720
|
+
};
|
|
721
|
+
export type ProducerEvents = {
|
|
722
|
+
CONNECT: 'producer.connect';
|
|
723
|
+
DISCONNECT: 'producer.disconnect';
|
|
724
|
+
REQUEST: 'producer.network.request';
|
|
725
|
+
REQUEST_TIMEOUT: 'producer.network.request_timeout';
|
|
726
|
+
REQUEST_QUEUE_SIZE: 'producer.network.request_queue_size';
|
|
727
|
+
};
|
|
728
|
+
export type Producer = Sender & {
|
|
729
|
+
connect(): Promise<void>;
|
|
730
|
+
disconnect(): Promise<void>;
|
|
731
|
+
isIdempotent(): boolean;
|
|
732
|
+
readonly events: ProducerEvents;
|
|
733
|
+
on(eventName: ProducerEvents['CONNECT'], listener: (event: ConnectEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
734
|
+
on(eventName: ProducerEvents['DISCONNECT'], listener: (event: DisconnectEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
735
|
+
on(eventName: ProducerEvents['REQUEST'], listener: (event: RequestEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
736
|
+
on(eventName: ProducerEvents['REQUEST_QUEUE_SIZE'], listener: (event: RequestQueueSizeEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
737
|
+
on(eventName: ProducerEvents['REQUEST_TIMEOUT'], listener: (event: RequestTimeoutEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
738
|
+
on(eventName: ValueOf<ProducerEvents>, listener: (event: InstrumentationEvent<any>) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
739
|
+
transaction(): Promise<Transaction>;
|
|
740
|
+
logger(): Logger;
|
|
741
|
+
};
|
|
742
|
+
export type Transaction = Sender & {
|
|
743
|
+
sendOffsets(offsets: Offsets & {
|
|
744
|
+
consumerGroupId: string;
|
|
745
|
+
}): Promise<void>;
|
|
746
|
+
commit(): Promise<void>;
|
|
747
|
+
abort(): Promise<void>;
|
|
748
|
+
isActive(): boolean;
|
|
749
|
+
};
|
|
750
|
+
export type ConsumerGroup = {
|
|
751
|
+
groupId: string;
|
|
752
|
+
generationId: number;
|
|
753
|
+
memberId: string;
|
|
754
|
+
coordinator: Broker;
|
|
755
|
+
};
|
|
756
|
+
export type MemberDescription = {
|
|
757
|
+
clientHost: string;
|
|
758
|
+
clientId: string;
|
|
759
|
+
memberId: string;
|
|
760
|
+
memberAssignment: Buffer;
|
|
761
|
+
memberMetadata: Buffer;
|
|
762
|
+
};
|
|
763
|
+
export type ConsumerGroupState = 'Unknown' | 'PreparingRebalance' | 'CompletingRebalance' | 'Stable' | 'Dead' | 'Empty';
|
|
764
|
+
export type GroupDescription = {
|
|
765
|
+
groupId: string;
|
|
766
|
+
members: MemberDescription[];
|
|
767
|
+
protocol: string;
|
|
768
|
+
protocolType: string;
|
|
769
|
+
state: ConsumerGroupState;
|
|
770
|
+
};
|
|
771
|
+
export type GroupDescriptions = {
|
|
772
|
+
groups: GroupDescription[];
|
|
773
|
+
};
|
|
774
|
+
export type TopicPartitions = {
|
|
775
|
+
topic: string;
|
|
776
|
+
partitions: number[];
|
|
777
|
+
};
|
|
778
|
+
export type TopicPartition = {
|
|
779
|
+
topic: string;
|
|
780
|
+
partition: number;
|
|
781
|
+
};
|
|
782
|
+
export type TopicPartitionOffset = TopicPartition & {
|
|
783
|
+
offset: string;
|
|
784
|
+
};
|
|
785
|
+
export type TopicPartitionOffsetAndMetadata = TopicPartitionOffset & {
|
|
786
|
+
metadata?: string | null;
|
|
787
|
+
};
|
|
788
|
+
export type Batch = {
|
|
789
|
+
topic: string;
|
|
790
|
+
partition: number;
|
|
791
|
+
highWatermark: string;
|
|
792
|
+
messages: KafkaMessage[];
|
|
793
|
+
isEmpty(): boolean;
|
|
794
|
+
firstOffset(): string | null;
|
|
795
|
+
lastOffset(): string;
|
|
796
|
+
offsetLag(): string;
|
|
797
|
+
offsetLagLow(): string;
|
|
798
|
+
};
|
|
799
|
+
export type GroupOverview = {
|
|
800
|
+
groupId: string;
|
|
801
|
+
protocolType: string;
|
|
802
|
+
};
|
|
803
|
+
export type DeleteGroupsResult = {
|
|
804
|
+
groupId: string;
|
|
805
|
+
errorCode?: number;
|
|
806
|
+
error?: KafkaJSProtocolError;
|
|
807
|
+
};
|
|
808
|
+
export type ConsumerEvents = {
|
|
809
|
+
HEARTBEAT: 'consumer.heartbeat';
|
|
810
|
+
COMMIT_OFFSETS: 'consumer.commit_offsets';
|
|
811
|
+
GROUP_JOIN: 'consumer.group_join';
|
|
812
|
+
FETCH_START: 'consumer.fetch_start';
|
|
813
|
+
FETCH: 'consumer.fetch';
|
|
814
|
+
START_BATCH_PROCESS: 'consumer.start_batch_process';
|
|
815
|
+
END_BATCH_PROCESS: 'consumer.end_batch_process';
|
|
816
|
+
CONNECT: 'consumer.connect';
|
|
817
|
+
DISCONNECT: 'consumer.disconnect';
|
|
818
|
+
STOP: 'consumer.stop';
|
|
819
|
+
CRASH: 'consumer.crash';
|
|
820
|
+
REBALANCING: 'consumer.rebalancing';
|
|
821
|
+
RECEIVED_UNSUBSCRIBED_TOPICS: 'consumer.received_unsubscribed_topics';
|
|
822
|
+
REQUEST: 'consumer.network.request';
|
|
823
|
+
REQUEST_TIMEOUT: 'consumer.network.request_timeout';
|
|
824
|
+
REQUEST_QUEUE_SIZE: 'consumer.network.request_queue_size';
|
|
825
|
+
};
|
|
826
|
+
export type ConsumerHeartbeatEvent = InstrumentationEvent<{
|
|
827
|
+
groupId: string;
|
|
828
|
+
memberId: string;
|
|
829
|
+
groupGenerationId: number;
|
|
830
|
+
}>;
|
|
831
|
+
export type ConsumerCommitOffsetsEvent = InstrumentationEvent<{
|
|
832
|
+
groupId: string;
|
|
833
|
+
memberId: string;
|
|
834
|
+
groupGenerationId: number;
|
|
835
|
+
topics: TopicOffsets[];
|
|
836
|
+
}>;
|
|
837
|
+
export interface IMemberAssignment {
|
|
838
|
+
[key: string]: number[];
|
|
839
|
+
}
|
|
840
|
+
export type ConsumerGroupJoinEvent = InstrumentationEvent<{
|
|
841
|
+
duration: number;
|
|
842
|
+
groupId: string;
|
|
843
|
+
isLeader: boolean;
|
|
844
|
+
leaderId: string;
|
|
845
|
+
groupProtocol: string;
|
|
846
|
+
memberId: string;
|
|
847
|
+
memberAssignment: IMemberAssignment;
|
|
848
|
+
}>;
|
|
849
|
+
export type ConsumerFetchStartEvent = InstrumentationEvent<{
|
|
850
|
+
nodeId: number;
|
|
851
|
+
}>;
|
|
852
|
+
export type ConsumerFetchEvent = InstrumentationEvent<{
|
|
853
|
+
numberOfBatches: number;
|
|
854
|
+
duration: number;
|
|
855
|
+
nodeId: number;
|
|
856
|
+
}>;
|
|
857
|
+
interface IBatchProcessEvent {
|
|
858
|
+
topic: string;
|
|
859
|
+
partition: number;
|
|
860
|
+
highWatermark: string;
|
|
861
|
+
offsetLag: string;
|
|
862
|
+
offsetLagLow: string;
|
|
863
|
+
batchSize: number;
|
|
864
|
+
firstOffset: string;
|
|
865
|
+
lastOffset: string;
|
|
866
|
+
}
|
|
867
|
+
export type ConsumerStartBatchProcessEvent = InstrumentationEvent<IBatchProcessEvent>;
|
|
868
|
+
export type ConsumerEndBatchProcessEvent = InstrumentationEvent<IBatchProcessEvent & {
|
|
869
|
+
duration: number;
|
|
870
|
+
}>;
|
|
871
|
+
export type ConsumerCrashEvent = InstrumentationEvent<{
|
|
872
|
+
error: Error;
|
|
873
|
+
groupId: string;
|
|
874
|
+
restart: boolean;
|
|
875
|
+
}>;
|
|
876
|
+
export type ConsumerRebalancingEvent = InstrumentationEvent<{
|
|
877
|
+
groupId: string;
|
|
878
|
+
memberId: string;
|
|
879
|
+
}>;
|
|
880
|
+
export type ConsumerReceivedUnsubscribedTopicsEvent = InstrumentationEvent<{
|
|
881
|
+
groupId: string;
|
|
882
|
+
generationId: number;
|
|
883
|
+
memberId: string;
|
|
884
|
+
assignedTopics: string[];
|
|
885
|
+
topicsSubscribed: string[];
|
|
886
|
+
topicsNotSubscribed: string[];
|
|
887
|
+
}>;
|
|
888
|
+
export interface OffsetsByTopicPartition {
|
|
889
|
+
topics: TopicOffsets[];
|
|
890
|
+
}
|
|
891
|
+
export interface EachMessagePayload {
|
|
892
|
+
topic: string;
|
|
893
|
+
partition: number;
|
|
894
|
+
message: KafkaMessage;
|
|
895
|
+
heartbeat(): Promise<void>;
|
|
896
|
+
pause(): () => void;
|
|
897
|
+
}
|
|
898
|
+
export interface EachBatchPayload {
|
|
899
|
+
batch: Batch;
|
|
900
|
+
resolveOffset(offset: string): void;
|
|
901
|
+
heartbeat(): Promise<void>;
|
|
902
|
+
pause(): () => void;
|
|
903
|
+
commitOffsetsIfNecessary(offsets?: Offsets): Promise<void>;
|
|
904
|
+
uncommittedOffsets(): OffsetsByTopicPartition;
|
|
905
|
+
isRunning(): boolean;
|
|
906
|
+
isStale(): boolean;
|
|
907
|
+
}
|
|
908
|
+
export type ConsumerEachMessagePayload = EachMessagePayload;
|
|
909
|
+
export type ConsumerEachBatchPayload = EachBatchPayload;
|
|
910
|
+
export type EachBatchHandler = (payload: EachBatchPayload) => Promise<void>;
|
|
911
|
+
export type EachMessageHandler = (payload: EachMessagePayload) => Promise<void>;
|
|
912
|
+
export type ConsumerRunConfig = {
|
|
913
|
+
autoCommit?: boolean;
|
|
914
|
+
autoCommitInterval?: number | null;
|
|
915
|
+
autoCommitThreshold?: number | null;
|
|
916
|
+
eachBatchAutoResolve?: boolean;
|
|
917
|
+
partitionsConsumedConcurrently?: number;
|
|
918
|
+
eachBatch?: EachBatchHandler;
|
|
919
|
+
eachMessage?: EachMessageHandler;
|
|
920
|
+
};
|
|
921
|
+
export type ConsumerSubscribeTopic = {
|
|
922
|
+
topic: string | RegExp;
|
|
923
|
+
fromBeginning?: boolean;
|
|
924
|
+
};
|
|
925
|
+
export type ConsumerSubscribeTopics = {
|
|
926
|
+
topics: (string | RegExp)[];
|
|
927
|
+
fromBeginning?: boolean;
|
|
928
|
+
};
|
|
929
|
+
export type Consumer = {
|
|
930
|
+
connect(): Promise<void>;
|
|
931
|
+
disconnect(): Promise<void>;
|
|
932
|
+
subscribe(subscription: ConsumerSubscribeTopics | ConsumerSubscribeTopic): Promise<void>;
|
|
933
|
+
stop(): Promise<void>;
|
|
934
|
+
run(config?: ConsumerRunConfig): Promise<void>;
|
|
935
|
+
commitOffsets(topicPartitions: Array<TopicPartitionOffsetAndMetadata>): Promise<void>;
|
|
936
|
+
seek(topicPartitionOffset: TopicPartitionOffset): void;
|
|
937
|
+
describeGroup(): Promise<GroupDescription>;
|
|
938
|
+
pause(topics: Array<{
|
|
939
|
+
topic: string;
|
|
940
|
+
partitions?: number[];
|
|
941
|
+
}>): void;
|
|
942
|
+
paused(): TopicPartitions[];
|
|
943
|
+
resume(topics: Array<{
|
|
944
|
+
topic: string;
|
|
945
|
+
partitions?: number[];
|
|
946
|
+
}>): void;
|
|
947
|
+
on(eventName: ConsumerEvents['HEARTBEAT'], listener: (event: ConsumerHeartbeatEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
948
|
+
on(eventName: ConsumerEvents['COMMIT_OFFSETS'], listener: (event: ConsumerCommitOffsetsEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
949
|
+
on(eventName: ConsumerEvents['GROUP_JOIN'], listener: (event: ConsumerGroupJoinEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
950
|
+
on(eventName: ConsumerEvents['FETCH_START'], listener: (event: ConsumerFetchStartEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
951
|
+
on(eventName: ConsumerEvents['FETCH'], listener: (event: ConsumerFetchEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
952
|
+
on(eventName: ConsumerEvents['START_BATCH_PROCESS'], listener: (event: ConsumerStartBatchProcessEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
953
|
+
on(eventName: ConsumerEvents['END_BATCH_PROCESS'], listener: (event: ConsumerEndBatchProcessEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
954
|
+
on(eventName: ConsumerEvents['CONNECT'], listener: (event: ConnectEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
955
|
+
on(eventName: ConsumerEvents['DISCONNECT'], listener: (event: DisconnectEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
956
|
+
on(eventName: ConsumerEvents['STOP'], listener: (event: InstrumentationEvent<null>) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
957
|
+
on(eventName: ConsumerEvents['CRASH'], listener: (event: ConsumerCrashEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
958
|
+
on(eventName: ConsumerEvents['REBALANCING'], listener: (event: ConsumerRebalancingEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
959
|
+
on(eventName: ConsumerEvents['RECEIVED_UNSUBSCRIBED_TOPICS'], listener: (event: ConsumerReceivedUnsubscribedTopicsEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
960
|
+
on(eventName: ConsumerEvents['REQUEST'], listener: (event: RequestEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
961
|
+
on(eventName: ConsumerEvents['REQUEST_TIMEOUT'], listener: (event: RequestTimeoutEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
962
|
+
on(eventName: ConsumerEvents['REQUEST_QUEUE_SIZE'], listener: (event: RequestQueueSizeEvent) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
963
|
+
on(eventName: ValueOf<ConsumerEvents>, listener: (event: InstrumentationEvent<any>) => void): RemoveInstrumentationEventListener<typeof eventName>;
|
|
964
|
+
logger(): Logger;
|
|
965
|
+
readonly events: ConsumerEvents;
|
|
966
|
+
};
|
|
967
|
+
export declare enum CompressionTypes {
|
|
968
|
+
None = 0,
|
|
969
|
+
GZIP = 1,
|
|
970
|
+
Snappy = 2,
|
|
971
|
+
LZ4 = 3,
|
|
972
|
+
ZSTD = 4
|
|
973
|
+
}
|
|
974
|
+
export declare let CompressionCodecs: {
|
|
975
|
+
[CompressionTypes.GZIP]: () => any;
|
|
976
|
+
[CompressionTypes.Snappy]: () => any;
|
|
977
|
+
[CompressionTypes.LZ4]: () => any;
|
|
978
|
+
[CompressionTypes.ZSTD]: () => any;
|
|
979
|
+
};
|
|
980
|
+
export declare class KafkaJSError extends Error {
|
|
981
|
+
readonly message: Error['message'];
|
|
982
|
+
readonly name: string;
|
|
983
|
+
readonly retriable: boolean;
|
|
984
|
+
readonly helpUrl?: string;
|
|
985
|
+
readonly cause?: Error;
|
|
986
|
+
constructor(e: Error | string, metadata?: KafkaJSErrorMetadata);
|
|
987
|
+
}
|
|
988
|
+
export declare class KafkaJSNonRetriableError extends KafkaJSError {
|
|
989
|
+
constructor(e: Error | string);
|
|
990
|
+
}
|
|
991
|
+
export declare class KafkaJSProtocolError extends KafkaJSError {
|
|
992
|
+
readonly code: number;
|
|
993
|
+
readonly type: string;
|
|
994
|
+
constructor(e: Error | string);
|
|
995
|
+
}
|
|
996
|
+
export declare class KafkaJSOffsetOutOfRange extends KafkaJSProtocolError {
|
|
997
|
+
readonly topic: string;
|
|
998
|
+
readonly partition: number;
|
|
999
|
+
constructor(e: Error | string, metadata?: KafkaJSOffsetOutOfRangeMetadata);
|
|
1000
|
+
}
|
|
1001
|
+
export declare class KafkaJSNumberOfRetriesExceeded extends KafkaJSNonRetriableError {
|
|
1002
|
+
readonly stack: string;
|
|
1003
|
+
readonly retryCount: number;
|
|
1004
|
+
readonly retryTime: number;
|
|
1005
|
+
constructor(e: Error | string, metadata?: KafkaJSNumberOfRetriesExceededMetadata);
|
|
1006
|
+
}
|
|
1007
|
+
export declare class KafkaJSConnectionError extends KafkaJSError {
|
|
1008
|
+
readonly broker: string;
|
|
1009
|
+
constructor(e: Error | string, metadata?: KafkaJSConnectionErrorMetadata);
|
|
1010
|
+
}
|
|
1011
|
+
export declare class KafkaJSRequestTimeoutError extends KafkaJSError {
|
|
1012
|
+
readonly broker: string;
|
|
1013
|
+
readonly correlationId: number;
|
|
1014
|
+
readonly createdAt: number;
|
|
1015
|
+
readonly sentAt: number;
|
|
1016
|
+
readonly pendingDuration: number;
|
|
1017
|
+
constructor(e: Error | string, metadata?: KafkaJSRequestTimeoutErrorMetadata);
|
|
1018
|
+
}
|
|
1019
|
+
export declare class KafkaJSMetadataNotLoaded extends KafkaJSError {
|
|
1020
|
+
constructor();
|
|
1021
|
+
}
|
|
1022
|
+
export declare class KafkaJSTopicMetadataNotLoaded extends KafkaJSMetadataNotLoaded {
|
|
1023
|
+
readonly topic: string;
|
|
1024
|
+
constructor(e: Error | string, metadata?: KafkaJSTopicMetadataNotLoadedMetadata);
|
|
1025
|
+
}
|
|
1026
|
+
export declare class KafkaJSStaleTopicMetadataAssignment extends KafkaJSError {
|
|
1027
|
+
readonly topic: string;
|
|
1028
|
+
readonly unknownPartitions: number;
|
|
1029
|
+
constructor(e: Error | string, metadata?: KafkaJSStaleTopicMetadataAssignmentMetadata);
|
|
1030
|
+
}
|
|
1031
|
+
export declare class KafkaJSServerDoesNotSupportApiKey extends KafkaJSNonRetriableError {
|
|
1032
|
+
readonly apiKey: number;
|
|
1033
|
+
readonly apiName: string;
|
|
1034
|
+
constructor(e: Error | string, metadata?: KafkaJSServerDoesNotSupportApiKeyMetadata);
|
|
1035
|
+
}
|
|
1036
|
+
export declare class KafkaJSBrokerNotFound extends KafkaJSError {
|
|
1037
|
+
constructor();
|
|
1038
|
+
}
|
|
1039
|
+
export declare class KafkaJSPartialMessageError extends KafkaJSError {
|
|
1040
|
+
constructor();
|
|
1041
|
+
}
|
|
1042
|
+
export declare class KafkaJSSASLAuthenticationError extends KafkaJSError {
|
|
1043
|
+
constructor();
|
|
1044
|
+
}
|
|
1045
|
+
export declare class KafkaJSGroupCoordinatorNotFound extends KafkaJSError {
|
|
1046
|
+
constructor();
|
|
1047
|
+
}
|
|
1048
|
+
export declare class KafkaJSNotImplemented extends KafkaJSError {
|
|
1049
|
+
constructor();
|
|
1050
|
+
}
|
|
1051
|
+
export declare class KafkaJSTimeout extends KafkaJSError {
|
|
1052
|
+
constructor();
|
|
1053
|
+
}
|
|
1054
|
+
export declare class KafkaJSLockTimeout extends KafkaJSError {
|
|
1055
|
+
constructor();
|
|
1056
|
+
}
|
|
1057
|
+
export declare class KafkaJSUnsupportedMagicByteInMessageSet extends KafkaJSError {
|
|
1058
|
+
constructor();
|
|
1059
|
+
}
|
|
1060
|
+
export declare class KafkaJSDeleteGroupsError extends KafkaJSError {
|
|
1061
|
+
readonly groups: DeleteGroupsResult[];
|
|
1062
|
+
constructor(e: Error | string, groups?: KafkaJSDeleteGroupsErrorGroups[]);
|
|
1063
|
+
}
|
|
1064
|
+
export declare class KafkaJSDeleteTopicRecordsError extends KafkaJSError {
|
|
1065
|
+
constructor(metadata: KafkaJSDeleteTopicRecordsErrorTopic);
|
|
1066
|
+
}
|
|
1067
|
+
export interface KafkaJSDeleteGroupsErrorGroups {
|
|
1068
|
+
groupId: string;
|
|
1069
|
+
errorCode: number;
|
|
1070
|
+
error: KafkaJSError;
|
|
1071
|
+
}
|
|
1072
|
+
export interface KafkaJSDeleteTopicRecordsErrorTopic {
|
|
1073
|
+
topic: string;
|
|
1074
|
+
partitions: KafkaJSDeleteTopicRecordsErrorPartition[];
|
|
1075
|
+
}
|
|
1076
|
+
export interface KafkaJSDeleteTopicRecordsErrorPartition {
|
|
1077
|
+
partition: number;
|
|
1078
|
+
offset: string;
|
|
1079
|
+
error: KafkaJSError;
|
|
1080
|
+
}
|
|
1081
|
+
export interface KafkaJSErrorMetadata {
|
|
1082
|
+
retriable?: boolean;
|
|
1083
|
+
topic?: string;
|
|
1084
|
+
partitionId?: number;
|
|
1085
|
+
metadata?: PartitionMetadata;
|
|
1086
|
+
}
|
|
1087
|
+
export interface KafkaJSOffsetOutOfRangeMetadata {
|
|
1088
|
+
topic: string;
|
|
1089
|
+
partition: number;
|
|
1090
|
+
}
|
|
1091
|
+
export interface KafkaJSNumberOfRetriesExceededMetadata {
|
|
1092
|
+
retryCount: number;
|
|
1093
|
+
retryTime: number;
|
|
1094
|
+
}
|
|
1095
|
+
export interface KafkaJSConnectionErrorMetadata {
|
|
1096
|
+
broker?: string;
|
|
1097
|
+
code?: string;
|
|
1098
|
+
}
|
|
1099
|
+
export interface KafkaJSRequestTimeoutErrorMetadata {
|
|
1100
|
+
broker: string;
|
|
1101
|
+
clientId: string;
|
|
1102
|
+
correlationId: number;
|
|
1103
|
+
createdAt: number;
|
|
1104
|
+
sentAt: number;
|
|
1105
|
+
pendingDuration: number;
|
|
1106
|
+
}
|
|
1107
|
+
export interface KafkaJSTopicMetadataNotLoadedMetadata {
|
|
1108
|
+
topic: string;
|
|
1109
|
+
}
|
|
1110
|
+
export interface KafkaJSStaleTopicMetadataAssignmentMetadata {
|
|
1111
|
+
topic: string;
|
|
1112
|
+
unknownPartitions: PartitionMetadata[];
|
|
1113
|
+
}
|
|
1114
|
+
export interface KafkaJSServerDoesNotSupportApiKeyMetadata {
|
|
1115
|
+
apiKey: number;
|
|
1116
|
+
apiName: string;
|
|
1117
|
+
}
|
|
1118
|
+
export {};
|