Skip to content

psubscribe method issues #101

@tanmaykm

Description

@tanmaykm

Invoking psubscribe with the Dict parameter (naively) as below:

psubscribe(subs, Dict("cha??el" => y->pattern_matched(y.message)))

throws error:

Pub/Sub: Error During Test at /data/HOME/.julia/dev/Redis/test/redis_tests.jl:390
  Got exception outside of a @test
  MethodError: no method matching psubscribe(::SubscriptionConnection,
::Dict{String, var"#16#21"{var"#pattern_matched#19"{Vector{Any}}}})
  
  Closest candidates are:
    psubscribe(::SubscriptionConnection, ::AbstractString, ::Function)
     @ Redis ~/.julia/dev/Redis/src/commands.jl:343
    psubscribe(::SubscriptionConnection, ::Dict{AbstractString, Function})
     @ Redis ~/.julia/dev/Redis/src/commands.jl:348  

It must be invoked with Dict{AbstractString,Function} like below, which is a bit awkward:

psubscribe(subs, Dict("cha??el" => y->pattern_matched(y.message)))

But it then throws another error:

Pub/Sub: Error During Test at /data/HOME/.julia/dev/Redis/test/redis_tests.jl:390
  Got exception outside of a @test
  MethodError: Cannot `convert` an object of type String to an object of type Function
  
  Closest candidates are:
    convert(::Type{T}, ::T) where T
     @ Base Base.jl:64
  
  Stacktrace:
    [1] pushfirst!(a::Vector{Function}, item::String)
      @ Base ./array.jl:1407
    [2] _psubscribe(conn::SubscriptionConnection, patterns::Vector{Function})
      @ Redis ~/.julia/dev/Redis/src/commands.jl:340
    [3] psubscribe(conn::SubscriptionConnection, subs::Dict{AbstractString, Function})
      @ Redis ~/.julia/dev/Redis/src/commands.jl:352
    [4] macro expansion
      @ /data/HOME/.julia/dev/Redis/test/redis_tests.jl:410 [inlined]
    [5] macro expansion
      @ /data/Work/julia/binaries/julia-1.9.4/share/julia/stdlib/v1.9/Test/src/Test.jl:1498 [inlined]

because here the _psubscribe method should have been passed the collection of keys instead of values. Seems like a typo there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions