![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@fpt-smart-cloud/nestjs-kafka
Advanced tools
Readme
A progressive Node.js framework for building efficient and scalable server-side applications.
$ npm i --save @fpt-smart-cloud/nestjs-kafka
Register the KafkaModule
synchronous with the register()
method:
@Module({
imports: [
KafkaModule.register([
{
name: 'HERO_SERVICE',
options: {
client: {
clientId: 'hero',
brokers: ['localhost:9092'],
},
consumer: {
groupId: 'hero-consumer'
}
}
},
]),
]
...
})
Register the KafkaModule
asynchronous with the registerAsync()
method:
import { ConfigModule, ConfigService } from '@nestjs/config';
@Module({
imports: [
ConfigModule.forRoot(),
KafkaModule.registerAsync(['HERO_SERVICE'], {
useFactory: async (configService: ConfigService) => {
const broker = this.configService.get('broker');
return [
{
name: 'HERO_SERVICE',
options: {
clientId: 'hero',
brokers: [broker],
},
consumer: {
groupId: 'hero-consumer'
}
}
}
];
},
inject: [ConfigService]
})
]
...
})
import { KafkaModuleOption, KafkaOptionsFactory } from '../kafka';
import { KAFKA_INTEGRATION_SERVICE } from '../common/constants';
export class KafkaConfigService implements KafkaOptionsFactory {
creatKafkaModuleOptions(): KafkaModuleOption[] {
return [
{
name: 'HERO_SERVICE',
options: {
client: {
clientId: clientId,
brokers: brokers,
},
consumer: {
groupId: clientId,
},
},
},
];
}
}
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { KafkaModule } from '@kimtuan1102/nestjs-kafka';
@Module({
imports: [
KafkaModule.registerAsync(['HERO_SERVICE'], {
imports: [ConfigModule],
useClass: KafkaConfigService,
},
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
Full settings can be found:
Config | Options |
---|---|
client | https://kafka.js.org/docs/configuration |
consumer | https://kafka.js.org/docs/consuming#options |
producer | https://kafka.js.org/docs/producing#options |
serializer | |
deserializer | |
consumeFromBeginning | true/false |
Subscribing to a topic to accept messages.
export class Consumer {
constructor(
@Inject('HERO_SERVICE') private client: KafkaService
) {}
onModuleInit(): void {
this.client.subscribeToResponseOf('hero.kill.dragon', this)
}
@SubscribeTo('hero.kill.dragon')
async getWorld(@Payload() data: KafkaMessage): Promise<void> {
...
}
}
Send messages back to kafka.
const TOPIC_NAME = 'hero.kill.dragon';
export class Producer {
constructor(
@Inject('HERO_SERVICE') private client: KafkaService
) {}
async post(message: string = 'Hello world'): Promise<RecordMetadata[]> {
const result = await this.client.send({
topic: TOPIC_NAME,
messages: [
{
key: '1',
value: message
}
]
});
return result;
}
}
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
Nest is MIT licensed.
FAQs
NestJS Kafka Client
The npm package @fpt-smart-cloud/nestjs-kafka receives a total of 0 weekly downloads. As such, @fpt-smart-cloud/nestjs-kafka popularity was classified as not popular.
We found that @fpt-smart-cloud/nestjs-kafka demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.