Skip to content

Commit

Permalink
doc: add non-nil err case in Receive's godoc
Browse files Browse the repository at this point in the history
  • Loading branch information
rueian committed Jun 25, 2022
1 parent bb3dc9b commit 7d2daf8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -214,9 +214,10 @@ err = c.Receive(context.Background(), c.B().Subscribe().Channel("ch1", "ch2").Bu
The provided handler will be called with received message.

It is important to note that `Client.Receive()` will keep blocking and return only when the following cases:
1. return `nil`, when received any unsubscribe/punsubscribe message related to the provided `subscribe` command.
2. return `rueidis.ErrClosing`, when the client is closed manually.
3. return `ctx.Err()`, when the `ctx` is done.
1. return `nil` when received any unsubscribe/punsubscribe message related to the provided `subscribe` command.
2. return `rueidis.ErrClosing` when the client is closed manually.
3. return `ctx.Err()` when the `ctx` is done.
4. return non-nil `err` when the provided `subscribe` command failed.

While the `Client.Receive()` call is blocking, the `Client` is still able to accept other concurrent requests,
and they are sharing the same tcp connection. If your message handler may take some time to complete, it is recommended
Expand Down
7 changes: 4 additions & 3 deletions rueidis.go
Expand Up @@ -126,9 +126,10 @@ type Client interface {

// Receive accepts SUBSCRIBE, SSUBSCRIBE, PSUBSCRIBE command and a message handler.
// Receive will block and then return value only when the following cases:
// 1. nil, when received any unsubscribe/punsubscribe message related to the provided `subscribe` command.
// 2. ErrClosing, when the client is closed manually.
// 3. ctx.Err(), when the deadline of `ctx` is exceeded.
// 1. return nil when received any unsubscribe/punsubscribe message related to the provided `subscribe` command.
// 2. return ErrClosing when the client is closed manually.
// 3. return ctx.Err() when the `ctx` is done.
// 4. return non-nil err when the provided `subscribe` command failed.
Receive(ctx context.Context, subscribe cmds.Completed, fn func(msg PubSubMessage)) error

// Dedicated acquire a connection from the blocking connection pool, no one else can use the connection
Expand Down

0 comments on commit 7d2daf8

Please sign in to comment.