Skip to content

Commit 2a2f395

Browse files
magnel4mby
authored andcommitted
fix: super stream consumer handle parameter optionality
1 parent ee11759 commit 2a2f395

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/super_stream_consumer.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ConsumerCreditPolicy, defaultCreditPolicy } from "./consumer_credit_pol
44
import { Message } from "./publisher"
55
import { Offset } from "./requests/subscribe_request"
66

7-
export type SuperStreamConsumerFunc = (msg: Message, consumer?: Consumer) => Promise<void> | void
7+
export type SuperStreamConsumerFunc = (msg: Message, consumer: Consumer) => Promise<void> | void
88

99
export class SuperStreamConsumer {
1010
private consumers: Map<string, Consumer> = new Map<string, Consumer>()
@@ -45,7 +45,12 @@ export class SuperStreamConsumer {
4545
singleActive: true,
4646
creditPolicy: this.creditPolicy,
4747
},
48-
(msg) => this.handle(msg, this.consumers.get(p)),
48+
(msg) => {
49+
const consumer = this.consumers.get(p)
50+
if (consumer) {
51+
return this.handle(msg, consumer)
52+
}
53+
},
4954
this
5055
)
5156
this.consumers.set(p, partitionConsumer)

0 commit comments

Comments
 (0)