Skip to content

Commit 91a985f

Browse files
simone-sanfratellomcollina
authored andcommitted
feat: expose clear metadata (#163)
* feat: expose clear metadata * fix: lint
1 parent f3c297c commit 91a985f

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

docs/base.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ Returns `true` if the client is not closed.
7979

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

82+
### `clearMetadata`
83+
84+
Clear the current metadata.
85+
8286
## Connecting to Kafka via TLS connection
8387

8488
To connect to a Kafka via TLS connection, simply pass all relevant options in the `tls` options when creating any subclass of `Base`.

src/clients/base/base.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export const kClosed = Symbol('plt.kafka.base.closed')
5353
export const kListApis = Symbol('plt.kafka.base.listApis')
5454
export const kMetadata = Symbol('plt.kafka.base.metadata')
5555
export const kCheckNotClosed = Symbol('plt.kafka.base.checkNotClosed')
56-
export const kClearMetadata = Symbol('plt.kafka.base.clearMetadata')
5756
export const kPerformWithRetry = Symbol('plt.kafka.base.performWithRetry')
5857
export const kPerformDeduplicated = Symbol('plt.kafka.base.performDeduplicated')
5958
export const kValidateOptions = Symbol('plt.kafka.base.validateOptions')
@@ -339,7 +338,7 @@ export class Base<OptionsType extends BaseOptions = BaseOptions> extends EventEm
339338
return false
340339
}
341340

342-
[kClearMetadata] (): void {
341+
clearMetadata (): void {
343342
this.#metadata = undefined
344343
}
345344

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

577576
// Stale metadata, we need to fetch everything again
578577
if (hasStaleMetadata) {
579-
this[kClearMetadata]()
578+
this.clearMetadata()
580579
topicsToFetch = options.topics
581580
}
582581

src/clients/base/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export {
22
Base,
33
kCheckNotClosed,
4-
kClearMetadata,
54
kGetApi,
65
kGetBootstrapConnection,
76
kGetConnection,

src/clients/consumer/consumer.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ import {
6161
Base,
6262
kAfterCreate,
6363
kCheckNotClosed,
64-
kClearMetadata,
6564
kClosed,
6665
kCreateConnectionPool,
6766
kFetchConnections,
@@ -1909,7 +1908,7 @@ export class Consumer<Key = Buffer, Value = Buffer, HeaderKey = Buffer, HeaderVa
19091908

19101909
#handleMetadataError (error: Error | null): Error | null {
19111910
if (error && (error as GenericError)?.findBy('hasStaleMetadata', true)) {
1912-
this[kClearMetadata]()
1911+
this.clearMetadata()
19131912
}
19141913

19151914
return error

src/clients/producer/producer.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
Base,
1717
kAfterCreate,
1818
kCheckNotClosed,
19-
kClearMetadata,
2019
kClosed,
2120
kGetApi,
2221
kGetBootstrapConnection,
@@ -515,7 +514,7 @@ export class Producer<Key = Buffer, Value = Buffer, HeaderKey = Buffer, HeaderVa
515514
const hasStaleMetadata = (error as GenericError).findBy('hasStaleMetadata', true)
516515

517516
if (hasStaleMetadata && repeatOnStaleMetadata) {
518-
this[kClearMetadata]()
517+
this.clearMetadata()
519518
this.#performSingleDestinationSend(
520519
topics,
521520
messages,

0 commit comments

Comments
 (0)