mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
4065b4f27e
To easily distinguish between sharded channel message and a global channel message, introducing `smessage` (instead of `message`) as message bulk for sharded channel publish message. This is gonna be a breaking change in 7.0.1! Background: Sharded pubsub introduced in redis 7.0, but after the release we quickly realized that the fact that it's problematic that the client can't distinguish between normal (global) pubsub messages and sharded ones. This is important because the same connection can subscribe to both, but messages sent to one pubsub system are not propagated to the other (they're completely separate), so if one connection is used to subscribe to both, we need to assist the client library to know which message it got so it can forward it to the correct callback.
18 lines
581 B
Tcl
18 lines
581 B
Tcl
set testmodule [file normalize tests/modules/publish.so]
|
|
|
|
start_server {tags {"modules"}} {
|
|
r module load $testmodule
|
|
|
|
test {PUBLISH and SPUBLISH via a module} {
|
|
set rd1 [redis_deferring_client]
|
|
set rd2 [redis_deferring_client]
|
|
|
|
assert_equal {1} [ssubscribe $rd1 {chan1}]
|
|
assert_equal {1} [subscribe $rd2 {chan1}]
|
|
assert_equal 1 [r publish.shard chan1 hello]
|
|
assert_equal 1 [r publish.classic chan1 world]
|
|
assert_equal {smessage chan1 hello} [$rd1 read]
|
|
assert_equal {message chan1 world} [$rd2 read]
|
|
}
|
|
}
|