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

Ignore: ๐Ÿ› Reduce distributed lock duration by separating domain logic #238

Conversation

psychology50
Copy link
Member

@psychology50 psychology50 commented Feb 7, 2025

์ž‘์—… ์ด์œ 

#237

The current chat room join implementation had an issue where distributed locks were held for too long, as they included both business validation and data retrieval for responses.

This refactoring aims to:

  • Minimize distributed lock duration by isolating core join logic
  • Prevent race conditions with proper lock management
  • Improve code maintainability through clear separation of concerns

์ž‘์—… ์‚ฌํ•ญ

  1. Extracted core join logic into ChatMemberJoinOperation

    • Moved all business validations into a single, focused class
    • Reduced lock duration by separating response data preparation
    • Improved validation with clear input parameters
  2. Optimized ChatMemberJoinService

    • Shortened lock duration by focusing on critical section
    • Loads required data efficiently to minimize lock time
    • Clear separation between join logic and response preparation
  3. Added comprehensive test coverage

    • Pure domain logic testing for operation
    • Integration tests verifying lock behavior

๋ฆฌ๋ทฐ์–ด๊ฐ€ ์ค‘์ ์ ์œผ๋กœ ํ™•์ธํ•ด์•ผ ํ•˜๋Š” ๋ถ€๋ถ„

I know, I know. I get that it was inappropriate to suddenly carry out such a large-scale change. But I've never liked the fact that the Aggregate Root references the User object in another ChatMember as an entity. This time, I had to change it to a value reference because otherwise, it could cause a serious delay in chat room joins.


๋ฐœ๊ฒฌํ•œ ์ด์Šˆ

  • none

@psychology50 psychology50 added bug ๊ธด๊ธ‰ํ•˜๊ณ , ์ค‘์š”๋„๊ฐ€ ๋†’์€ ์ด์Šˆ fix ๊ธฐ๋Šฅ ์ˆ˜์ • labels Feb 7, 2025
@psychology50 psychology50 self-assigned this Feb 7, 2025
@psychology50 psychology50 merged commit b245fef into dev Feb 7, 2025
1 check passed
@psychology50 psychology50 deleted the fix/separate-chatroom-join-logic-for-reducing-lock-process-time branch February 7, 2025 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ๊ธด๊ธ‰ํ•˜๊ณ , ์ค‘์š”๋„๊ฐ€ ๋†’์€ ์ด์Šˆ fix ๊ธฐ๋Šฅ ์ˆ˜์ •
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant