Closed Shamshiel closed 3 years ago
Thanks! I agree it does need the forRootAysnc
method and it has been on my list to get too. If you were just wanting to load config you can do that using the nestjs config ConfigModule.forRoot()
, the via:
import { ConfigModule, ConfigService } from '@nestjs/config';
@Module({
imports: [
MicroserviceHealthIndicator,
ConfigModule.forRoot(),
KafkaModule.register([
{
name: 'KAFKA_SERVICE',
options: {
client: {
clientId: 'my-client',
brokers: [process.env.KAFKA_BROKERS || 'localhost:9092'],
connectionTimeout: 3000,
ssl: true,
sasl: {
mechanism: 'plain',
username: process.env.KAFKA_USERNAME,
password: process.env.KAFKA_PASSWORD
}
},
}
}]
]})
@rob3000 I created a branch with asynchronous module initialization. I could make a pull request if you want but currently I'm not able to push the branch.
@Shamshiel a PR would be perfect! 👌
Released in 1.4.0
FIrst of all thank you for providing this package. I tried to use this package today and it seems to miss a critical feature.
I need to load the username, password and broker list on application start up dynamically. Other NestJS packages provide a "forRootAsync" or "registerAsync" method for this. I can use this method to inject some services and load config values.
Example from the HttpModule
Sorry if this is already possible but I didn't find any method that would provide this. (Is there another way to achieve this that I'm not aware of?)