Skip to content

Commit

Permalink
Notes on what *SUBSCRIBE returns (or doesn't return) (#2327)
Browse files Browse the repository at this point in the history
Add return info to *subscribe and *unsubscribe commands.

Add some notes about RESP3.
  • Loading branch information
zuiderkwast authored Feb 23, 2023
1 parent 5efad36 commit 7310463
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 1 deletion.
14 changes: 14 additions & 0 deletions commands/psubscribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,17 @@ Supported glob-style patterns:
* `h[ae]llo` subscribes to `hello` and `hallo,` but not `hillo`

Use `\` to escape special characters if you want to match them verbatim.

Once the client enters the subscribed state it is not supposed to issue any other commands, except for additional `SUBSCRIBE`, `SSUBSCRIBE`, `PSUBSCRIBE`, `UNSUBSCRIBE`, `SUNSUBSCRIBE`, `PUNSUBSCRIBE`, `PING`, `RESET` and `QUIT` commands.
However, if RESP3 is used (see `HELLO`) it is possible for a client to issue any commands while in subscribed state.

For more information, see [Pub/sub](/docs/manual/pubsub/).

@return

When successful, this command doesn't return anything.
Instead, for each pattern, one message with the first element being the string "psubscribe" is pushed as a confirmation that the command succeeded.

## Behavior change history

* `>= 6.2.0`: `RESET` can be called to exit subscribed state.
5 changes: 5 additions & 0 deletions commands/punsubscribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ When no patterns are specified, the client is unsubscribed from all the
previously subscribed patterns.
In this case, a message for every unsubscribed pattern will be sent to the
client.

@return

When successful, this command doesn't return anything.
Instead, for each pattern, one message with the first element being the string "punsubscribe" is pushed as a confirmation that the command succeeded.
6 changes: 6 additions & 0 deletions commands/ssubscribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ A client can subscribe to channels across different slots over separate `SSUBSCR

For more information about sharded Pub/Sub, see [Sharded Pub/Sub](/topics/pubsub#sharded-pubsub).

@return

When successful, this command doesn't return anything.
Instead, for each shard channel, one message with the first element being the string "ssubscribe" is pushed as a confirmation that the command succeeded.
Note that this command can also return a -MOVED redirect.

@examples

```
Expand Down
10 changes: 9 additions & 1 deletion commands/subscribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ Subscribes the client to the specified channels.
Once the client enters the subscribed state it is not supposed to issue any
other commands, except for additional `SUBSCRIBE`, `SSUBSCRIBE`, `PSUBSCRIBE`, `UNSUBSCRIBE`, `SUNSUBSCRIBE`,
`PUNSUBSCRIBE`, `PING`, `RESET` and `QUIT` commands.
However, if RESP3 is used (see `HELLO`) it is possible for a client to issue any commands while in subscribed state.

For more information, see [Pub/sub](/docs/manual/pubsub/).

@return

When successful, this command doesn't return anything.
Instead, for each channel, one message with the first element being the string "subscribe" is pushed as a confirmation that the command succeeded.

## Behavior change history

* `>= 6.2.0`: `RESET` can be called to exit subscribed state.
* `>= 6.2.0`: `RESET` can be called to exit subscribed state.
5 changes: 5 additions & 0 deletions commands/sunsubscribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ In this case a message for every unsubscribed shard channel will be sent to the
Note: The global channels and shard channels needs to be unsubscribed from separately.

For more information about sharded Pub/Sub, see [Sharded Pub/Sub](/topics/pubsub#sharded-pubsub).

@return

When successful, this command doesn't return anything.
Instead, for each shard channel, one message with the first element being the string "sunsubscribe" is pushed as a confirmation that the command succeeded.
5 changes: 5 additions & 0 deletions commands/unsubscribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ When no channels are specified, the client is unsubscribed from all the
previously subscribed channels.
In this case, a message for every unsubscribed channel will be sent to the
client.

@return

When successful, this command doesn't return anything.
Instead, for each channel, one message with the first element being the string "unsubscribe" is pushed as a confirmation that the command succeeded.

0 comments on commit 7310463

Please sign in to comment.