Documentation ¶
Overview ¶
Package pubsub provides a wrapper around a normal redis client which makes interacting with publish/subscribe commands much easier
Index ¶
- type SubClient
- func (c *SubClient) PSubscribe(patterns ...interface{}) *SubResp
- func (c *SubClient) PUnsubscribe(patterns ...interface{}) *SubResp
- func (c *SubClient) Ping() *SubResp
- func (c *SubClient) Receive() *SubResp
- func (c *SubClient) Subscribe(channels ...interface{}) *SubResp
- func (c *SubClient) Unsubscribe(channels ...interface{}) *SubResp
- type SubResp
- type SubRespType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SubClient ¶
SubClient wraps a Redis client to provide convenience methods for Pub/Sub functionality.
func NewSubClient ¶
NewSubClient takes an existing, connected redis.Client and wraps it in a SubClient, returning that. The passed in redis.Client should not be used as long as the SubClient is also being used
func (*SubClient) PSubscribe ¶
PSubscribe makes a Redis "PSUBSCRIBE" command on the provided patterns
func (*SubClient) PUnsubscribe ¶
PUnsubscribe makes a Redis "PUNSUBSCRIBE" command on the provided patterns
func (*SubClient) Ping ¶
Ping will send a ping command on the connection, and returns a Pong response (or error)
func (*SubClient) Receive ¶
Receive returns the next publish resp on the Redis client. It is possible Receive will timeout, and the *SubResp will be an Error. You can use the Timeout() method on SubResp to easily determine if that is the case. If this is the case you can call Receive again to continue listening for publishes
func (*SubClient) Unsubscribe ¶
Unsubscribe makes a Redis "UNSUBSCRIBE" command on the provided channels
type SubResp ¶
type SubResp struct { *redis.Resp // Original Redis resp Type SubRespType Channel string // Channel resp is on (Message) Pattern string // Pattern which was matched for publishes captured by a PSubscribe SubCount int // Count of subs active after this action (Subscribe or Unsubscribe) Message string // Publish message (Message) Err error // SubResp error (Error) }
SubResp wraps a Redis resp and provides convenient access to Pub/Sub info.
type SubRespType ¶
type SubRespType uint8
SubRespType describes the type of the response being returned from one of the methods in this package
const ( Error SubRespType = iota Subscribe Unsubscribe Message Pong )
The different kinds of SubRespTypes