-
Notifications
You must be signed in to change notification settings - Fork 5
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
[BE] issue372: Github Token 받아오는 과정을 트랜잭션에서 제외 #373
Merged
Merged
Conversation
This file contains 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
tco0427
added
🚀 feature
New feature or request
🖥 backend
New backend feature
⛑ performance
improvement of performance
labels
Sep 21, 2022
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
verus-j
approved these changes
Sep 29, 2022
jaejae-yoo
approved these changes
Sep 29, 2022
|
||
@PostMapping("/api/auth/login") | ||
public ResponseEntity<AccessTokenResponse> login(@RequestParam final String code) { | ||
final TokensResponse tokenResponse = authService.createToken(code); | ||
final GithubProfileResponse profile = oAuthClient.getProfile(code); | ||
final TokensResponse tokenResponse = authService.createToken(profile); |
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.
github 프로필 정보를 받아 오는 부분을 분리하셨군요 👍
sc0116
approved these changes
Sep 30, 2022
…oamoa into feat/372-improvement-login # Conflicts: # backend/src/main/java/com/woowacourse/moamoa/auth/controller/AuthController.java # backend/src/main/java/com/woowacourse/moamoa/auth/service/AuthService.java # backend/src/test/java/com/woowacourse/moamoa/auth/controller/AuthControllerTest.java
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
🖥 backend
New backend feature
🚀 feature
New feature or request
⛑ performance
improvement of performance
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.
요약
Github Token 받아오는 과정을 트랜잭션에서 제외
세부사항
RealMySQL8.0 책의 5.1.2 절을 보면 트랜잭션을 꼭 필요한 최소의 코드에만 적용하는 것이 좋다라는 문장으로 해당 이슈와 관련된 내용을 이야기한다.
현재 우리의
로그인
과정, 즉,AuthService
의createToken
을 보면 전체 로직이 트랜잭션으로 묶이게 된다.스프링에서 AOP 를 통해서 제공하는
@Transactional
어노테이션의 경우 메소드 시작과 동시에 트랜잭션을 시작하고, 해당 메소드가 끝날 때 트랜잭션이 끝나면서 commit 을 하게 된다. 하지만 우리에게 정말 트랜잭션이 필요한 부분은 다음 코드 부분이다.따라서 외부 네트워크와 통신하는 작업을 하는
oAuthClient
를 우리 트랜잭션에서 제거하여 불필요한 커넥션을 가지고 있는 범위와 트랜잭션 활성화 범위를 제거한다.변경 이후
참고 사이트 : 서비스로직과 트랜잭션 분리
close #372