Skip to content

feat(lock): introduce LockConfiguration for configurable lock timing#11

Merged
tshan10 merged 5 commits intoPhonePe:mainfrom
mO-sarfaRAZ:feature/dlm-configurable-lock-timing
Apr 13, 2026
Merged

feat(lock): introduce LockConfiguration for configurable lock timing#11
tshan10 merged 5 commits intoPhonePe:mainfrom
mO-sarfaRAZ:feature/dlm-configurable-lock-timing

Conversation

@mO-sarfaRAZ
Copy link
Copy Markdown

Summary

Lock timing (TTL, wait timeout, retry interval) was hardcoded in LockBase,
giving consumers no way to tune behaviour for their SLOs. This PR introduces
LockConfiguration — a simple, immutable config object — to make these
values configurable per instance

Motivation

Services have widely different SLOs. A payment service may need a 30 s TTL with a
500 ms retry interval; a batch job can tolerate the 90 s defaults. Previously, the
only way to override these values was to pass explicit Duration arguments on every
acquireLock call — error-prone and inconsistent across a codebase.

Changes

  • LockConfiguration — new @Builder value object with three Duration
    fields (lockTtl, waitForLock, retryInterval) and sensible @Builder.Default
    values matching the existing hardcoded constants
  • LockBase — wires in LockConfiguration; removes the old static constants
  • LockConfigurationTest — 7 unit tests covering defaults, custom values,
    partial config, and builder backward compat
  • README — documents the new configuration option
  • Javadocs — updated to reference LockConfiguration for default values

Backward Compatibility

Zero breaking changes. Existing LockBase.builder() calls compile and behave
identically — defaults are preserved via @Builder.Default.

// Custom configuration example
LockConfiguration.builder()
    .lockTtl(Duration.ofSeconds(30))
    .waitForLock(Duration.ofSeconds(10))
    .retryInterval(Duration.ofMillis(500))
    .build();

Backward Compatibility

This change is fully backward compatible. All existing builder calls:

LockBase.builder()
    .mode(LockMode.EXCLUSIVE)
    .lockStore(aerospikeStore)
    .build();

continue to compile and behave identically@Builder.Default ensures the LockConfiguration with 90 s / 90 s / 1 s defaults is applied automatically.

Comment thread src/main/java/com/phonepe/dlm/lock/base/LockConfiguration.java Outdated
Comment thread src/test/java/com/phonepe/dlm/lock/base/LockConfigurationTest.java Outdated
Comment thread src/test/java/com/phonepe/dlm/lock/base/LockConfigurationTest.java Outdated
Comment thread src/test/java/com/phonepe/dlm/lock/base/LockConfigurationTest.java Outdated
Comment thread src/test/java/com/phonepe/dlm/lock/base/LockConfigurationTest.java Outdated
Comment thread src/test/java/com/phonepe/dlm/lock/base/LockConfigurationTest.java Outdated
@sonarqubecloud
Copy link
Copy Markdown

@tshan10 tshan10 merged commit 0e82c90 into PhonePe:main Apr 13, 2026
2 of 5 checks passed
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