#psubscribe subscription callback not called
danielwestendorf opened this issue · 1 comments
danielwestendorf commented
I'm unsure if this is a bug or just improper usage of the library. I can #subscribe
to a channel without issue. However, when I try to use #psubscribe
the subscription callback never is called. What am I doing wrong?
require "redis"
redis = Redis.new
redis.psubscribe("channel.*") do |on|
on.message do |channel, message|
puts "I got a message"
end
end
$ crystal run src/psubscribe.cr
^
$ redis-cli
127.0.0.1:6379> PSUBSCRIBE channel.*
Reading messages... (press Ctrl-C to quit)
1) "psubscribe"
2) "channel.*"
3) (integer) 1
1) "pmessage"
2) "channel.*"
3) "channel.abc"
4) "hello"
$ redis-cli
127.0.0.1:6379> PUBLISH channel.abc hello
(integer) 1
127.0.0.1:6379>
$ crystal --version
Crystal 0.23.1 (2017-09-08) LLVM 4.0.1
redis:
github: stefanwille/crystal-redis
version: 1.9.0
danielwestendorf commented
This was a usage issue. After looking at the specs, the API for listening to #psubscribe
is different.
I've created a PR with an example for #psubscribe
to the examples repo.