Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions docs/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ Returns `true` if the client is not closed.

Returns `true` if all client's connections are currently connected and the client is connected to at least one broker.

### `clearMetadata`

Clear the current metadata.

## Connecting to Kafka via TLS connection

To connect to a Kafka via TLS connection, simply pass all relevant options in the `tls` options when creating any subclass of `Base`.
Expand Down
5 changes: 2 additions & 3 deletions src/clients/base/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export const kClosed = Symbol('plt.kafka.base.closed')
export const kListApis = Symbol('plt.kafka.base.listApis')
export const kMetadata = Symbol('plt.kafka.base.metadata')
export const kCheckNotClosed = Symbol('plt.kafka.base.checkNotClosed')
export const kClearMetadata = Symbol('plt.kafka.base.clearMetadata')
export const kPerformWithRetry = Symbol('plt.kafka.base.performWithRetry')
export const kPerformDeduplicated = Symbol('plt.kafka.base.performDeduplicated')
export const kValidateOptions = Symbol('plt.kafka.base.validateOptions')
Expand Down Expand Up @@ -339,7 +338,7 @@ export class Base<OptionsType extends BaseOptions = BaseOptions> extends EventEm
return false
}

[kClearMetadata] (): void {
clearMetadata (): void {
this.#metadata = undefined
}

Expand Down Expand Up @@ -576,7 +575,7 @@ export class Base<OptionsType extends BaseOptions = BaseOptions> extends EventEm

// Stale metadata, we need to fetch everything again
if (hasStaleMetadata) {
this[kClearMetadata]()
this.clearMetadata()
topicsToFetch = options.topics
}

Expand Down
1 change: 0 additions & 1 deletion src/clients/base/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export {
Base,
kCheckNotClosed,
kClearMetadata,
kGetApi,
kGetBootstrapConnection,
kGetConnection,
Expand Down
3 changes: 1 addition & 2 deletions src/clients/consumer/consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ import {
Base,
kAfterCreate,
kCheckNotClosed,
kClearMetadata,
kClosed,
kCreateConnectionPool,
kFetchConnections,
Expand Down Expand Up @@ -1909,7 +1908,7 @@ export class Consumer<Key = Buffer, Value = Buffer, HeaderKey = Buffer, HeaderVa

#handleMetadataError (error: Error | null): Error | null {
if (error && (error as GenericError)?.findBy('hasStaleMetadata', true)) {
this[kClearMetadata]()
this.clearMetadata()
}

return error
Expand Down
3 changes: 1 addition & 2 deletions src/clients/producer/producer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
Base,
kAfterCreate,
kCheckNotClosed,
kClearMetadata,
kClosed,
kGetApi,
kGetBootstrapConnection,
Expand Down Expand Up @@ -515,7 +514,7 @@ export class Producer<Key = Buffer, Value = Buffer, HeaderKey = Buffer, HeaderVa
const hasStaleMetadata = (error as GenericError).findBy('hasStaleMetadata', true)

if (hasStaleMetadata && repeatOnStaleMetadata) {
this[kClearMetadata]()
this.clearMetadata()
this.#performSingleDestinationSend(
topics,
messages,
Expand Down