Skip to content

Commit

Permalink
docs: do not call client.Do in the pubsub callback directly
Browse files Browse the repository at this point in the history
  • Loading branch information
rueian committed Aug 18, 2024
1 parent 1e07e97 commit 618b1b6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ To receive messages from channels, `client.Receive()` should be used. It support

```golang
err = client.Receive(context.Background(), client.B().Subscribe().Channel("ch1", "ch2").Build(), func(msg rueidis.PubSubMessage) {
// handle the msg
// Handle the message. Note that if you want to call another `client.Do()` here, you need to do it in another goroutine or the `client` will be blocked.
})
```

Expand All @@ -253,7 +253,7 @@ defer cancel()

wait := c.SetPubSubHooks(rueidis.PubSubHooks{
OnMessage: func(m rueidis.PubSubMessage) {
// Handle message. This callback will be called sequentially but in another goroutine.
// Handle the message. Note that if you want to call another `c.Do()` here, you need to do it in another goroutine or the `c` will be blocked.
}
})
c.Do(ctx, c.B().Subscribe().Channel("ch").Build())
Expand Down

0 comments on commit 618b1b6

Please sign in to comment.