Documentation ¶
Overview ¶
The pubsub package provides a wrapper around a normal redis client which makes interacting with subscribe commands much easier
Index ¶
- type SubClient
- func (c *SubClient) PSubscribe(patterns ...interface{}) *SubReply
- func (c *SubClient) PUnsubscribe(patterns ...interface{}) *SubReply
- func (c *SubClient) Receive() *SubReply
- func (c *SubClient) Subscribe(channels ...interface{}) *SubReply
- func (c *SubClient) Unsubscribe(channels ...interface{}) *SubReply
- type SubReply
- type SubReplyType
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 ¶
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) Receive ¶
Receive returns the next publish reply on the Redis client. It is possible Receive will timeout, and the *SubReply will be an ErrorReply. You can use the Timeout() method on SubReply 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 SubReply ¶
type SubReply struct { Type SubReplyType // SubReply type Channel string // Channel reply is on (MessageReply) SubCount int // Count of subs active after this action (SubscribeReply or UnsubscribeReply) Message string // Publish message (MessageReply) Err error // SubReply error (ErrorReply) Reply *redis.Reply // Original Redis reply (MessageReply) }
SubReply wraps a Redis reply and provides convienient access to Pub/Sub info.
type SubReplyType ¶
type SubReplyType uint8
const ( ErrorReply SubReplyType = iota SubscribeReply UnsubscribeReply MessageReply )