Bug
The pooled Redis client is using the wrong method on the psubscribe method which results in a wrong subscription.
Here a code example:
REDIS = Redis::PooledClient.new(host=ENV["REDIS_HOST"], port=ENV["REDIS_PORT"].to_i, pool_size: 5)
REDIS.psubscribe("a*") do |on|
on.pmessage do |channel|
puts "Channel: #{channel}"
end
end
Which results in the following subscription on the Redis server:
If we now try to publish, for example, the following message, redis-cli publish 'ab' '{"id":199}', the message will not arrive the server as it will only listen for the a* key.
Bug The pooled Redis client is using the wrong method on the psubscribe method which results in a wrong subscription. Here a code example:
Which results in the following subscription on the Redis server:
If we now try to publish, for example, the following message,
redis-cli publish 'ab' '{"id":199}'
, the message will not arrive the server as it will only listen for thea*
key.Therefore, we can fix this by changing the following line https://github.com/stefanwille/crystal-redis/blob/571ea1c0643a21ddf8a9aa69eba4b21ed6c4d5ba/src/redis/pooled_client.cr#L60 to
Note the change;
&.subscribe
to&.psubscribe
. This will now result in a proper listener:Code reference