Skip to content
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

✨ Modulize mysql pool #56

Merged
merged 9 commits into from
Mar 7, 2022
Merged

✨ Modulize mysql pool #56

merged 9 commits into from
Mar 7, 2022

Conversation

hyunkoes
Copy link
Contributor

@hyunkoes hyunkoes commented Mar 4, 2022

WorkList

  • Mysql pool 생성 & pool module화
  • getConnection -> 파라미터로 주어진 query 수행 -> release 를 하는 함수 작성
  • 유닛 테스트

Issue

  • None

Description

  • Mysql loader 에서 getPool() 함수를 통해 Singleton으로 작성된 mysql pool을 반환합니다.
  • 이후 connect || transaction ( connect + commit )으로 pool에서 connection을 얻어 쿼리 수행 및 release를 합니다.
    image
    image

InitiateMysqlPool.ts type 지정 및 async / await 함수 작성에 미숙함이 있어 review 부탁합니다.

refer to https://mayajuni.github.io/2016/07/12/typescript-nodejs-mysql/

@can019
Copy link
Contributor

can019 commented Mar 6, 2022

@201702083
Jest test 결과 fail로 뜨는데 확인 부탁드립니다!!

스크린샷 2022-03-06 오후 8 54 50

@can019 can019 added ✨ New Feature 새로운 기능 ♻️ Refactor 리팩토링 labels Mar 6, 2022
@can019 can019 linked an issue Mar 7, 2022 that may be closed by this pull request
4 tasks
@hyunkoes
Copy link
Contributor Author

hyunkoes commented Mar 7, 2022

@201702083 Jest test 결과 fail로 뜨는데 확인 부탁드립니다!!

@can019
Jest에 mysql pool을 이용한 간단한 쿼리 테스트 추가했습니다.

  • 기본 Table 수 가져오기 ( 현재 동아리 8개 + 관리자 1개로 9개 ) -> pai 동아리 소멸로 추후 변경 필요
  • 테스트 시작 전 후 mysql getconnection & destroy 삭제

image

@hyunkoes
Copy link
Contributor Author

hyunkoes commented Mar 7, 2022

Mysql get connection과 destroy가 필요없어 beforeAll 과 afterAll의 mysql 관련 구문들을 지웠더니

Jest TCPWRAP 오류가 발생했습니다.
image

supertest 관련 이슈를 읽어보면 express가 random port를 할당받아서 생기는 문제라고 합니다. 이슈 생성할까요?

@can019
Copy link
Contributor

can019 commented Mar 7, 2022

local에서 test 확인했습니다

@can019
Copy link
Contributor

can019 commented Mar 7, 2022

Mysql get connection과 destroy가 필요없어 beforeAll 과 afterAll의 mysql 관련 구문들을 지웠더니

Jest TCPWRAP 오류가 발생했습니다. image

supertest 관련 이슈를 읽어보면 express가 random port를 할당받아서 생기는 문제라고 합니다. 이슈 생성할까요?

현재 작업중인 feature/nginx에서는 위와 같은 오류가 발생하지 않고 있습니다.

스크린샷 2022-03-07 오후 3 31 56

  • 다른 잠재적인 오류일 가능성도 확인해봐야 할 것 같습니다.

@hyunkoes
Copy link
Contributor Author

hyunkoes commented Mar 7, 2022

Mysql get connection과 destroy가 필요없어 beforeAll 과 afterAll의 mysql 관련 구문들을 지웠더니
Jest TCPWRAP 오류가 발생했습니다. image
supertest 관련 이슈를 읽어보면 express가 random port를 할당받아서 생기는 문제라고 합니다. 이슈 생성할까요?

현재 작업중인 feature/nginx에서는 위와 같은 오류가 발생하지 않고 있습니다.

스크린샷 2022-03-07 오후 3 31 56
  • 다른 잠재적인 오류일 가능성도 확인해봐야 할 것 같습니다.


일단 Merge & branch 삭제하겠습니다.

@hyunkoes hyunkoes merged commit 182bf2a into develop Mar 7, 2022
@hyunkoes hyunkoes deleted the feature/DB-modularity branch March 7, 2022 06:36
@can019
Copy link
Contributor

can019 commented Mar 7, 2022

Mysql get connection과 destroy가 필요없어 beforeAll 과 afterAll의 mysql 관련 구문들을 지웠더니
Jest TCPWRAP 오류가 발생했습니다. image
supertest 관련 이슈를 읽어보면 express가 random port를 할당받아서 생기는 문제라고 합니다. 이슈 생성할까요?

현재 작업중인 feature/nginx에서는 위와 같은 오류가 발생하지 않고 있습니다.

스크린샷 2022-03-07 오후 3 31 56
  • 다른 잠재적인 오류일 가능성도 확인해봐야 할 것 같습니다.

네 일단 Merge & branch 삭제하겠습니다.

넵 알겠습니다. test 파일에 남긴 코드리뷰 참고해주시면 감사하겠습니다 :)

@can019 can019 added the 🌋 Bug erupt 버그 발생 label Mar 7, 2022
Copy link
Contributor

@can019 can019 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@201702083 :)

src/loaders/mysql.ts Show resolved Hide resolved
src/models/InitiateMysqlPool.ts Show resolved Hide resolved
src/models/InitiateMysqlPool.ts Show resolved Hide resolved
src/models/InitiateMysqlPool.ts Show resolved Hide resolved
__test__/loaders/index.test.ts Show resolved Hide resolved
@hyunkoes hyunkoes restored the feature/DB-modularity branch March 8, 2022 06:45
@hyunkoes hyunkoes deleted the feature/DB-modularity branch March 8, 2022 06:45
hyunkoes added a commit that referenced this pull request Mar 9, 2022
can019 pushed a commit that referenced this pull request Mar 13, 2022
* 🔧 Set mysql pool parameters to .env

* 🔧 Add pool parameters

* 🩹 #56 review feedback

* 🐛 #58 issue fix

* 🗑️ make initialize function void
hyunkoes added a commit that referenced this pull request Mar 13, 2022
* 🔧 Set mysql pool parameters to .env

* 🔧 Add pool parameters

* 🩹 #56 review feedback

* 🐛 #58 issue fix

* 🗑️ make initialize function void

* ⏪ return pool for jest handler issue

* 🩹 logger level 수정
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
♻️ Refactor 리팩토링 ✨ New Feature 새로운 기능 🌋 Bug erupt 버그 발생
Projects
Development

Successfully merging this pull request may close these issues.

✨ Mysql, Redis connection pool 및 module화
2 participants