(feat): Distributed lock harness - #21
Merged
Merged
Conversation
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved Redis provisioning, authentication, cleanup, and gRPC-port issues require changes.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds a Redis-backed distributed lock harness with Dapr integration, tests, exports, and documentation.
Changes:
- Adds
DistributedLockHarnesslifecycle and client helpers. - Extends
DaprContainerwith distributed-lock configuration. - Adds tests, package exports, and README usage documentation.
File summaries
| File | Summary | Findings |
|---|---|---|
src/index.ts |
Exports the new harness. | None noted. |
src/DistributedLockHarness.ts |
Implements harness lifecycle and client creation. | Moderate: startup failures can leak child containers; gRPC should select the correct mapped port when daprPort is omitted. |
src/DistributedLockHarness.test.ts |
Tests lock behavior and protocols. | None noted. |
src/DaprContainer.ts |
Configures Redis-backed distributed locks. | Critical: Redis provisioning can be skipped when another feature supplies an external host. Moderate: redisPassword is not applied to the managed Redis container. |
README.md |
Documents distributed-lock usage. | None noted. |
Review details
Suppressed comments (3)
src/DaprContainer.ts:252
redisPasswordis applied only to the generated Dapr component; the managedRedisContainerremains the unauthenticatedredis:alpineinstance and has no password configuration. ThereforeDistributedLockHarness({ redisPassword: "..." })with the default or suppliedRedisContainermakes Dapr authenticate against a server that does not require that password, so lock calls fail. Configure Redis with the same password (including the supplied-container path), or restrict this option to externally managed Redis hosts, and cover the behavior with an integration test.
const redisLock = RedisContainer.createDistributedLockComponent({
name: lockStoreName,
redisHost,
redisPassword: this.distributedLockOptions?.redisPassword,
src/DistributedLockHarness.ts:87
- If
this.daprContainer.start()fails after placement, scheduler, or Redis has started,startedDaprContaineris never assigned, sostop()has no handles with which to stop those child containers; stopping an owned network alone can leave them running. Please add startup-failure cleanup (or makeDaprContainerretain and clean up its child start handles) before exposing this harness as safely disposable.
this.startedDaprContainer = await this.daprContainer.start();
src/DistributedLockHarness.ts:143
- If a caller sets
communicationProtocolto gRPC but omitsdaprPort, this helper still injects the mapped HTTP port at line 142, so the SDK attempts a gRPC connection against the HTTP endpoint. Select the mapped port based on the requested protocol (while preserving an explicit override), or reject the mismatched combination; the current gRPC test hides this by supplyingdaprPortmanually.
const client = new DaprClient({
daprHost: started.getHost(),
daprPort: started.getHttpPort().toString(),
...clientOptions,
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
# Conflicts: # README.md # src/DaprContainer.ts Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Implemented distributed lock harness
Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #[issue number]
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: