Skip to content

refactor: decompose LockActor.create() and refresh() into focused pri…#1194

Open
pallakartheekreddy wants to merge 1 commit intocloud-store-refactoringfrom
refactor/lock-actor-decompose
Open

refactor: decompose LockActor.create() and refresh() into focused pri…#1194
pallakartheekreddy wants to merge 1 commit intocloud-store-refactoringfrom
refactor/lock-actor-decompose

Conversation

@pallakartheekreddy
Copy link
Collaborator

…vate helpers

Extracted three private helpers shared across create(), refresh(), retire(), and list():

  • validateDeviceHeader(request): single-responsibility check for X-device-Id header, eliminating the repeated inline throw across all four operations
  • lockOkResponse(lockId, expiresAt): builds the standard lockKey/expiresAt/expiresIn response map, eliminating copy-paste between create and refresh success paths
  • readLockExternalProps(request, resourceId): sets identifier on request and fires readExternalProps, eliminating 4-line boilerplate repeated in create/refresh/retire

Extracted two business-logic helpers from create():

  • handleExistingLock(...): handles the three cases when a lock record already exists (same owner → extend, same user different device → self-lock error, other user → locked)
  • createNewLock(...): persists the new lock to Cassandra and calls updateContent

create() shrinks from 52 to ~20 lines; refresh() from 48 to ~35 lines. All logic is preserved exactly — only organisation changed.

…vate helpers

Extracted three private helpers shared across create(), refresh(), retire(), and list():
- validateDeviceHeader(request): single-responsibility check for X-device-Id header,
  eliminating the repeated inline throw across all four operations
- lockOkResponse(lockId, expiresAt): builds the standard lockKey/expiresAt/expiresIn
  response map, eliminating copy-paste between create and refresh success paths
- readLockExternalProps(request, resourceId): sets identifier on request and fires
  readExternalProps, eliminating 4-line boilerplate repeated in create/refresh/retire

Extracted two business-logic helpers from create():
- handleExistingLock(...): handles the three cases when a lock record already exists
  (same owner → extend, same user different device → self-lock error, other user → locked)
- createNewLock(...): persists the new lock to Cassandra and calls updateContent

create() shrinks from 52 to ~20 lines; refresh() from 48 to ~35 lines. All logic
is preserved exactly — only organisation changed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/lock-actor-decompose

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

@github-actions
Copy link

SonarCloud Analysis Results 🔍

Quality Gate Results for Services:

Please review the analysis results for each service. Ensure all quality gates are passing before merging.

Base automatically changed from develop to cloud-store-refactoring February 27, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants