42 lines
1.8 KiB
TypeScript
42 lines
1.8 KiB
TypeScript
import { Module, Global } from '@nestjs/common';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { ClientsModule, Transport } from '@nestjs/microservices';
|
|
import { EventPublisherService } from './event-publisher.service';
|
|
import { DepositEventConsumerService } from './deposit-event-consumer.service';
|
|
import { PlantingEventConsumerService } from './planting-event-consumer.service';
|
|
// [已屏蔽] 前端直接从 reward-service 查询,不再订阅 reward-service 消息
|
|
// import { RewardEventConsumerController } from './reward-event-consumer.controller';
|
|
// import { EventAckPublisher } from './event-ack.publisher';
|
|
import { PrismaService } from '../persistence/prisma/prisma.service';
|
|
|
|
@Global()
|
|
@Module({
|
|
imports: [
|
|
ClientsModule.registerAsync([
|
|
{
|
|
name: 'KAFKA_SERVICE',
|
|
imports: [ConfigModule],
|
|
useFactory: (configService: ConfigService) => ({
|
|
transport: Transport.KAFKA,
|
|
options: {
|
|
client: {
|
|
clientId: configService.get<string>('KAFKA_CLIENT_ID', 'wallet-service'),
|
|
brokers: configService.get<string>('KAFKA_BROKERS', 'localhost:9092').split(','),
|
|
},
|
|
consumer: {
|
|
groupId: configService.get<string>('KAFKA_GROUP_ID', 'wallet-service-group'),
|
|
},
|
|
},
|
|
}),
|
|
inject: [ConfigService],
|
|
},
|
|
]),
|
|
],
|
|
// [已屏蔽] 前端直接从 reward-service 查询,不再订阅 reward-service 消息
|
|
// controllers: [RewardEventConsumerController],
|
|
controllers: [],
|
|
providers: [PrismaService, EventPublisherService, DepositEventConsumerService, PlantingEventConsumerService],
|
|
exports: [EventPublisherService, DepositEventConsumerService, PlantingEventConsumerService, ClientsModule],
|
|
})
|
|
export class KafkaModule {}
|