swarthy / redis-semaphore

Distributed mutex and semaphore based on Redis
MIT License
148 stars 28 forks source link

Allow non-ioredis client #219

Closed jokester closed 3 months ago

jokester commented 3 months ago

This PR removes all ioredis imports from non-test code, and instanceof ioredis.Redis checks of redis clients.

Users can now use non-ioredis clients with this library, but are expected to provide ioredis-compatible API, marked by RedisClient type.

ioredis should work as before.

Fixes https://github.com/swarthy/redis-semaphore/issues/201 .

jokester commented 3 months ago

It is now possible to make ioredis an optional peer dep, with peerDependenciesMeta:

  "peerDependenciesMeta": {
    "ioredis": {
      "optional": true
    }
  }

But it could be a breaking change so I'm not sure if we should. If user didn't have ioredis as explicit dependency this could break something in rare case.

swarthy commented 3 months ago

@jokester Hi! Thanks for PR! Please, check review comments.

If user didn't have ioredis as explicit dependency this could break something in rare case.

I guest we can mark it optional and release minor version, because command in README.md already contains ioredis. So it was a conscious decision by the user not to install ioredis explicitly for that rare case.