-
Notifications
You must be signed in to change notification settings - Fork 18
Feat/kafka-setting: 트랜잭션 락 최소화를 위한 성능 개선 #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
98d935d
bd6044f
e25642b
3fafce8
640fc2a
09bdfbf
47f5ce4
dab0eeb
d92c0d3
3ff967f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ services: | |
| - 8080:8080 | ||
| environment: | ||
| - DYNAMIC_CONFIG_ENABLED=true | ||
| - KAFKA_CLUSTERS_0_NAME=koi_kafka | ||
| - KAFKA_CLUSTERS_0_NAME=stock-service | ||
| - KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka:9092 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저희 카프카 서버 9092와 9094 서버의 차이가 무엇인가요? 각자 역할이 뭔지 궁금해요 |
||
|
|
||
| mongo: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| module.exports = { | ||
| collectCoverageFrom: ['**/*.(t|j)s'], | ||
| coverageDirectory: '../coverage', | ||
| moduleFileExtensions: ['js', 'json', 'ts'], | ||
| rootDir: 'src', | ||
| testEnvironment: 'node', | ||
| testRegex: '.*\\.spec\\.ts$', | ||
| transform: { | ||
| '^.+\\.(t|j)s$': 'ts-jest', | ||
| }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,39 @@ | ||
| import { Module } from '@nestjs/common'; | ||
| import { MongooseModule } from '@nestjs/mongoose'; | ||
| import { ConfigModule, ConfigService } from '@nestjs/config'; | ||
| import { PollModule } from 'feature-nest-poll'; | ||
| import { StockModule } from 'feature-nest-stock'; | ||
| import { ScheduleModule } from '@nestjs/schedule'; | ||
| import { AppController } from './app.controller'; | ||
| import { AppService } from './app.service'; | ||
| import { PartyModule } from './party/party.module'; | ||
| import { KafkaModule } from '../../../../package/feature/feature-nest-stock/src/kafka/kafka.module'; | ||
| import kafkaConfig from '../config/kafka.config'; | ||
|
|
||
| @Module({ | ||
| controllers: [AppController], | ||
| imports: [ | ||
| ScheduleModule.forRoot(), | ||
| ConfigModule.forRoot({ | ||
| isGlobal: true, | ||
| load: [kafkaConfig], | ||
| }), | ||
| MongooseModule.forRoot(process.env.MONGO_URI, { | ||
| ignoreUndefined: true, | ||
| maxIdleTimeMS: 60000, | ||
| }), | ||
| PollModule, | ||
| StockModule, | ||
| PartyModule, | ||
| KafkaModule.forRootAsync({ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. feature-nest-stock 에서 KafkaModule.forFeature 쓸 수 있을까요? |
||
| imports: [ConfigModule], | ||
| inject: [ConfigService], | ||
| useFactory: (configService: ConfigService) => ({ | ||
| brokers: configService.get<string[]>('kafka.brokers') || [], | ||
| clientId: configService.get<string>('kafka.clientId') || '', | ||
| groupId: configService.get<string>('kafka.groupId') || '', | ||
| }), | ||
| }), | ||
| ], | ||
| providers: [AppService], | ||
| }) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export default (): Record<string, unknown> => ({ | ||
| kafka: { | ||
| brokers: process.env.KAFKA_BROKERS?.split(',') || ['localhost:9094'], | ||
| clientId: process.env.KAFKA_CLIENT_ID || 'stock-service', | ||
| groupId: process.env.KAFKA_GROUP_ID || 'stock_service_group', | ||
| }, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| module.exports = { | ||
| moduleFileExtensions: ['js', 'json', 'ts'], | ||
| rootDir: '.', | ||
| testRegex: '.*\\.spec\\.ts$', | ||
| transform: { | ||
| '^.+\\.(t|j)s$': 'ts-jest', | ||
| }, | ||
| collectCoverageFrom: ['**/*.(t|j)s'], | ||
| coverageDirectory: './coverage', | ||
| testEnvironment: 'node', | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { Module, DynamicModule, Type, ForwardReference, Abstract } from '@nestjs/common'; | ||
| import { KafkaService } from './kafka.service'; | ||
|
|
||
| export interface KafkaModuleOptions { | ||
| brokers: string[]; | ||
| clientId: string; | ||
| groupId: string; | ||
| } | ||
|
|
||
| type ModuleType = Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference<unknown>; | ||
|
|
||
| export interface KafkaModuleAsyncOptions { | ||
| imports?: ModuleType[]; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| useFactory: (...args: any[]) => Promise<KafkaModuleOptions> | KafkaModuleOptions; | ||
| // eslint-disable-next-line @typescript-eslint/ban-types | ||
| inject?: Array<Type<unknown> | string | symbol | Abstract<unknown> | Function>; | ||
| } | ||
|
|
||
| @Module({ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. KafkaModule을 package/library/lib-nest-kafka 로 옮길 수 있을까요? |
||
| exports: [KafkaService], | ||
| providers: [KafkaService], | ||
| }) | ||
| export class KafkaModule { | ||
| static forRoot(options: KafkaModuleOptions): DynamicModule { | ||
| return { | ||
| exports: [KafkaService], | ||
| global: true, | ||
| module: KafkaModule, | ||
| providers: [ | ||
| { | ||
| provide: 'KAFKA_OPTIONS', | ||
| useValue: options, | ||
| }, | ||
| KafkaService, | ||
| ], | ||
| }; | ||
| } | ||
|
|
||
| static forRootAsync(options: KafkaModuleAsyncOptions): DynamicModule { | ||
| return { | ||
| exports: [KafkaService], | ||
| global: true, | ||
| imports: options.imports || [], | ||
| module: KafkaModule, | ||
| providers: [ | ||
| { | ||
| inject: options.inject || [], | ||
| provide: 'KAFKA_OPTIONS', | ||
| useFactory: options.useFactory, | ||
| }, | ||
| KafkaService, | ||
| ], | ||
| }; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sdc-stock 으로 변경해도 괜찮을까요?