Skip to content

fix: use DI for DistributedLockService Redis client (fixes #818)#1064

Merged
RUKAYAT-CODER merged 4 commits into
rinafcode:mainfrom
menawar:fix-818-redis-di
Jul 25, 2026
Merged

fix: use DI for DistributedLockService Redis client (fixes #818)#1064
RUKAYAT-CODER merged 4 commits into
rinafcode:mainfrom
menawar:fix-818-redis-di

Conversation

@menawar

@menawar menawar commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR addresses issue #818 by replacing the inline new Redis() instantiation in DistributedLockService with NestJS Dependency Injection. This prevents connection leaks on module teardown and improves testability by allowing a mocked client to be passed during unit testing.

Changes

  • OrchestrationModule: Created an OrchestrationModule which defines a DISTRIBUTED_LOCK_REDIS provider using the shared Redis factory.
  • DistributedLockService:
    • Injected the Redis client via constructor parameter (@Inject(DISTRIBUTED_LOCK_REDIS)).
    • Implemented the OnModuleDestroy lifecycle hook to explicitly close the Redis connection (this.redis.quit()) during module teardown.
  • Tests: Refactored distributed-lock.service.spec.ts to pass a mocked Redis client instead of relying on the previously hardcoded Redis class instance.
  • AppModule: Registered OrchestrationModule.

Fixes #818

@drips-wave

drips-wave Bot commented Jul 24, 2026

Copy link
Copy Markdown

@menawar Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Well done on the job done so far!
Kindly resolve conflict

@menawar

menawar commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

Well done on the job done so far! Kindly resolve conflict

thank you @RUKAYAT-CODER conflicts resolved

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Always pull from main before pushing.
Please fix your workflow to pass.

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit 5fe84a6 into rinafcode:main Jul 25, 2026
1 check 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.

DistributedLockService creates Redis client inline bypassing dependency injection

2 participants