Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve type compatibility with @types/kafkajs #416

Merged
merged 1 commit into from
Jul 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ export interface ProducerConfig {
maxInFlightRequests?: number
}

export interface Message {
key?: Buffer | string | null
value: Buffer | string | null
partition?: number
headers?: IHeaders
timestamp?: string
}

export interface PartitionerArgs {
topic: string
partitionMetadata: PartitionMetadata[]
Expand All @@ -65,14 +73,6 @@ export const Partitioners: {
JavaCompatiblePartitioner: JavaCompatiblePartitioner
}

export interface Message {
key?: Buffer | null
value: Buffer | null
partition?: number
headers?: IHeaders
timestamp?: string
}

export type PartitionMetadata = {
partitionErrorCode: number
partitionId: number
Expand Down Expand Up @@ -293,7 +293,7 @@ export type Admin = {
timeout?: number
topics: ITopicConfig[]
}): Promise<boolean>
deleteTopics(options: { topics: string[]; timeout: number }): Promise<void>
deleteTopics(options: { topics: string[]; timeout?: number }): Promise<void>
fetchTopicMetadata(options: { topics: string[] }): Promise<{ topics: Array<ITopicMetadata> }>
fetchOffsets(options: {
groupId: string
Expand Down Expand Up @@ -593,6 +593,18 @@ export interface EachBatchPayload {
isStale(): boolean
}

/**
* Type alias to keep compatibility with @types/kafkajs
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/712ad9d59ccca6a3cc92f347fea0d1c7b02f5eeb/types/kafkajs/index.d.ts#L321-L325
*/
export type ConsumerEachMessagePayload = EachMessagePayload

/**
* Type alias to keep compatibility with @types/kafkajs
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/712ad9d59ccca6a3cc92f347fea0d1c7b02f5eeb/types/kafkajs/index.d.ts#L327-L336
*/
export type ConsumerEachBatchPayload = EachBatchPayload

export type Consumer = {
connect(): Promise<void>
disconnect(): Promise<void>
Expand Down