Skip to content

Commit

Permalink
feat(cluster): extend initial config (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryabukhinstep authored Oct 20, 2023
1 parent 5098e28 commit ef93ee2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export class ConfigModule {
password: process.env.KAFKA_PASSWORD,
ssl: process.env.KAFKA_SSL,
ca: process.env.KAFKA_CA,
connectionTimeout: process.env.KAFKA_CONNECTION_TIMEOUT, // default is 1 s.
},
consumer: {
groupId: process.env.KAFKA_CONSUMER_GROUP_ID as string,
Expand Down
12 changes: 11 additions & 1 deletion src/config/kafkaClusterConfigDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
* limitations under the License.
*/

import { TransformToBoolean } from "@byndyusoft/class-validator-extended";
import {
TransformToBoolean,
TransformToNumber,
} from "@byndyusoft/class-validator-extended";
import { Transform } from "class-transformer";
import {
ArrayMinSize,
IsArray,
IsBoolean,
IsIn,
IsInt,
IsOptional,
IsString,
} from "class-validator";
Expand All @@ -46,6 +50,7 @@ export class KafkaClusterConfigDto {

return {
brokers,
connectionTimeout: config.connectionTimeout,
...this.getKafkaSslConfig(transformedConfig),
...this.getKafkaSaslConfig(transformedConfig),
};
Expand Down Expand Up @@ -122,4 +127,9 @@ export class KafkaClusterConfigDto {
)
@IsOptional()
public readonly ca?: string | Buffer;

@IsInt()
@IsOptional()
@TransformToNumber()
public readonly connectionTimeout?: number;
}

0 comments on commit ef93ee2

Please sign in to comment.