-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
64 lines (59 loc) · 1.77 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { FastifyPluginAsync } from 'fastify';
import {
Consumer,
ConsumerConfig,
ConsumerRunConfig,
ConsumerSubscribeTopic,
ConsumerSubscribeTopics,
Kafka,
KafkaConfig,
Producer,
ProducerConfig
} from 'kafkajs';
declare namespace fastifyKafkaJS {
type FastifyKafkaJSClient = Kafka;
type FastifyKafkaJSProducer = Producer;
type FastifyKafkaJSConsumer = Consumer;
type FastifyKafkaJSConsumerDeclaration = {
consumerConfig: ConsumerConfig;
subscription: ConsumerSubscribeTopics | ConsumerSubscribeTopic;
runConfig: ConsumerRunConfig;
};
interface FastifyKafkaJSOptions {
/**
* KafkaJS client config
* @default {
* brokers: ['localhost:9092'],
* clientId: 'fastify-kafkajs'
* }
*/
clientConfig?: KafkaConfig;
/**
* KafkaJS producer config
*/
producerConfig?: ProducerConfig;
/**
* Array of objects describing consumers
* @default []
*/
consumers?: FastifyKafkaJSConsumerDeclaration[];
/**
* Ignore the default onClose handled which closes the producer
* and all consumers. If set to true, you will have to manage
* closing the producer and the consumers yourself.
* @default false
*/
ignoreOnClose?: boolean;
}
}
declare module 'fastify' {
interface FastifyInstance {
kafka: {
client: fastifyKafkaJS.FastifyKafkaJSClient;
producer: fastifyKafkaJS.FastifyKafkaJSProducer;
consumers: fastifyKafkaJS.FastifyKafkaJSConsumer[];
};
}
}
declare const fastifyKafkaJS: FastifyPluginAsync<fastifyKafkaJS.FastifyKafkaJSOptions>;
export default fastifyKafkaJS;