nest
nest copied to clipboard
Wildcard support for Redis subscriptions in microservices
Is there an existing issue that is already proposing this?
- [X] I have searched the existing issues
Is your feature request related to a problem? Please describe it
When creating a Redis microservice, it is not possible to make use of wildcards in the pattern/topic (like it is for MQTT for example). This however is supported by the npm packages 'redis' and 'ioredis' by using psubscribe instead of the simpler subscribe.
(Another issue with the same request (#5211) was closed, but I do believe it to be a good feature.)
Describe the solution you'd like
Start using psubscribe instead of subscribe in the source code of the Redis microservice. This makes sure it is possible to use wildcards in the pattern/topic.
I cannot think of any drawbacks, because it simply is an extra feature and the documentation of Redis itself specifies that there is no speed difference. The time complexity of either function is the same.
Teachability, documentation, adoption, migration strategy
The docs of the MQTT microservice already include an extra section for the wildcards explicitly. A similar one could be included for the Redis page, where the specifics on the wildcards would have to be changed. The reader could also be redirected to the Redis website for those details (https://redis.io/commands/psubscribe/).
What is the motivation / use case for changing the behavior?
I think it is a nice feature to make the Redis microservice more complete and useful and I cannot think of any drawbacks.
Would you like to create a PR for this issue?
Let's track this here https://github.com/nestjs/nest/pull/10359