Skip to content

(feat): Distributed lock harness - #21

Merged
WhitWaldo merged 3 commits into
mainfrom
distributed-lock-harness
Sep 14, 2026
Merged

WhitWaldo merged 3 commits into
mainfrom
distributed-lock-harness

Conversation

@WhitWaldo

Copy link
Copy Markdown
Contributor

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:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
@WhitWaldo
WhitWaldo requested a lite review from Copilot September 14, 2026 00:03
@WhitWaldo WhitWaldo self-assigned this Sep 14, 2026
@WhitWaldo WhitWaldo added the enhancement New feature or request label Sep 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 DistributedLockHarness lifecycle and client helpers.
  • Extends DaprContainer with 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

  • redisPassword is applied only to the generated Dapr component; the managed RedisContainer remains the unauthenticated redis:alpine instance and has no password configuration. Therefore DistributedLockHarness({ redisPassword: "..." }) with the default or supplied RedisContainer makes 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, startedDaprContainer is never assigned, so stop() 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 make DaprContainer retain 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 communicationProtocol to gRPC but omits daprPort, 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 supplying daprPort manually.
    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.

Comment thread src/DaprContainer.ts Outdated
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
# Conflicts:
#	README.md
#	src/DaprContainer.ts

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
@WhitWaldo
WhitWaldo merged commit 3ae9837 into main Sep 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants