Skip to content

Commit b7e7e66

Browse files
committed
move codec to init
1 parent 4e2655a commit b7e7e66

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/service-utils/src/node/usageV2.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,17 @@ export class UsageV2Producer {
8080

8181
this.topic = getTopicName(productName);
8282
this.compression = compression;
83-
if (compression === CompressionTypes.LZ4) {
84-
CompressionCodecs[CompressionTypes.LZ4] = new LZ4Codec().codec;
85-
}
8683
}
8784

8885
/**
8986
* Connect the producer.
9087
* This must be called before calling `sendEvents()`.
9188
*/
9289
async init(configOverrides?: ProducerConfig) {
90+
if (this.compression === CompressionTypes.LZ4) {
91+
CompressionCodecs[CompressionTypes.LZ4] = new LZ4Codec().codec;
92+
}
93+
9394
this.producer = this.kafka.producer({
9495
allowAutoTopicCreation: false,
9596
...configOverrides,

0 commit comments

Comments
 (0)