Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow opt out of redlock in redis cacher #1192

Merged
merged 1 commit into from
Mar 8, 2023

Conversation

shawnmcknight
Copy link
Member

📝 Description

Currently, the Redis cacher will always try to instantiate a redlock instance if the dependency is able to be resolved. Currently, moleculer is only compatible with ^4.0.0. The current version of redlock is 5.0.0-beta.2 and moleculer is not compatible with it. However, if moleculer users with to use the current version of redlock while using the Redis cacher, they will experience errors when the cacher gets instantiated that prevent the broker from starting. This happens whether consumers wish to make use of the redlock functionality in moleculer or not.

This PR allows consumers to opt-out of using redlock in the Redis cacher by setting the opts.redlock to false. This was done to avoid any breaking changes.

Additionally, this PR added a little more safety around use of the lock and tryLock methods in the cacher. If redlock is not installed or was disabled, those methods would currently error because they would be accessing something not instantiated. Those methods will now log an error and resolve instead.

💎 Type of change

  • Bug fix (non-breaking change which fixes an issue)

🚦 How Has This Been Tested?

New unit tests were added and existing unit tests continue to pass.

🏁 Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have commented my code, particularly in hard-to-understand areas

Copy link
Member

@icebob icebob left a comment

Choose a reason for hiding this comment

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

Great job, thanks!

@icebob icebob merged commit 6c7f1c1 into moleculerjs:master Mar 8, 2023
@shawnmcknight shawnmcknight deleted the redlock-opt-out branch March 13, 2023 15:33
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