Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces functionality for managing Polygon tool files, including uploading and deleting tools with content stored directly in the database and notifying other services via RabbitMQ. Key feedback includes addressing a missing class definition for PolygonAMQPService that prevents compilation, implementing file type validation to avoid data corruption when converting uploads to UTF-8 strings, and adding error handling for the deletion of non-existent records to prevent runtime exceptions.
| } | ||
| chunks.push(chunk) | ||
| } | ||
| const fileContent = Buffer.concat(chunks).toString('utf-8') |
Contributor
| } | ||
|
|
||
| async deletePolygonFile(problemId: number, toolType: ToolType) { | ||
| return await this.prisma.polygonTool.delete({ |
Contributor
There was a problem hiding this comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
조만간 정리할게요!!!! 일단 지금까지 작업내용 요약해달라 했음 클로드한테
개요
Polygon Tool(Generator/Validator/Checker)의 파일 업로드 및 Iris 서버와의 RabbitMQ 통신 레이어를 구현했습니다.
변경 사항
libs/constants/src/rabbitmq.constants.tsPolygon 관련 RabbitMQ 상수 추가
Exchange: POLYGON_EXCHANGE
Generator/Validator routing key, message type, result queue 상수
libs/amqp/src/interface/polygonToolRequest.interface.ts (신규)
Iris로 전송하는 메시지 body 타입 정의
GeneratorRequest: problemId, generatorLanguage, generatorCode, generatorArgs, solutionLanguage, solutionCode, testCaseCount
ValidatorRequest: problemId, language, validatorCode
libs/amqp/src/amqp.service.ts
PolygonAMQPService 클래스 추가
startGeneratorSubscription() / startValidatorSubscription(): 결과 메시지 구독
publishGeneratorMessage() / publishValidatorMessage(): 실행 요청 publish (validator는 priority 2 적용)
setMessageHandlers(): 결과 수신 콜백 등록
apps/admin/src/polygon/file/file.service.ts
uploadPolygonToolFile(): 파일 스트림을 읽어 DB에 upsert (10MB 제한)
deletePolygonFile(): DB에서 파일 삭제
apps/admin/src/polygon/polygon-pub.service.ts (신규)
DB에서 PolygonTool/PolygonSolution 조회 후 RabbitMQ 메시지 조립·발행
publishGeneratorMessage(problemId, generatorArgs, testCaseCount)
publishValidatorMessage(problemId)
apps/admin/src/polygon/polygon-sub.service.ts (신규)
OnModuleInit에서 구독 시작 및 핸들러 등록
onGenerateResult / onValidateResult 비즈니스 로직은 Iris 팀의 결과 메시지 스펙 확정 후 작성 예정
apps/admin/src/polygon/polygon.service.ts
uploadPolygonTool(): FileService에 위임하여 DB 저장
runGenerator() / runValidator(): PolygonPublicationService에 위임하여 실행 요청 publish
업로드와 실행을 별도 Mutation으로 분리
미완료 / 확인 필요 사항
polygon.module.ts에 PolygonPublicationService, PolygonSubscriptionService 등록 필요
PolygonSolution이 S3 filePath 기반으로 설계되어 있어 fileContent 조회 방식 확정 필요
Iris 팀과 결과 메시지 구조(routing key, queue 이름, 결과 필드) 확인 필요
Generator의 priority 값 결정 필요 (현재 미설정, Validator는 2 적용)
Language 필드 형식 Iris 스펙과 통일 필요
스키마 변경
filePath -> fileContent (필드명 변경)
amqp.service.ts에 PolygonAMQPService 추가 -> polygon tool을 업로드 했다는 메시지를 iris로 발행
-> 여기 문제가 좀 있어서 아직 커밋을 못했습니다
rabbitmq.constants.ts에 상수 추가
POLYGON_EXCHANGE = 'iris.e.direct.polygon'
POLYGON_TOOL_KEY = 'polygon.tool'
POLYGON_TOOL_MESSAGE_TYPE = 'polygonTool'
admin/src/polygon/file/file.service.ts 에 polygon tool DB 저장 및 삭제 로직 작성
DB 저장 과정: 소스코드(.cpp) -> createReadStream -> [chunk1, chunk2, chunk3, ...] → Buffer.concat.toString('utf-8') → DB(PostgreSQL)에 저장
upsert 사용해서 최초 업로드, 파일 변경 한번에 되도록 작성
admin/src/polygon/polygon.service.ts
DB 저장 로직 + RabbitMQ 메세지 발행 로직 같이 실행
admin/src/polygon/polygon.resolver.ts 작성