Documentation ¶
Overview ¶
Package rrpubsub contains a more reliable implementation of Redis Pub-Sub, backed by the redigo library.
It attempts to keep a persistent connection to the Redis server, with a retrying connection loop whenever the server connection fails.
This does not guarantee that all messages will be received: anything published while the connection was down will be lost, so it's still a best-effort thing. Just a much better effort than out of the box.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn interface { Messages() <-chan redis.Message Subscribe(channel ...string) Unsubscribe(channel ...string) Close() error }
Example ¶
ctx := context.Background() conn := New(ctx, "tcp", "localhost:6379") conn.Subscribe("mychannel") messages := conn.Messages() for { select { case msg, ok := <-messages: if !ok { break } fmt.Printf("%#v", msg) } }
Output:
func New ¶
New returns a new connection that will use the given network and address with the specified options.
func NewURL ¶
NewURL returns a new connection that will connect using the Redis URI scheme. URLs should follow the draft IANA specification for the scheme (https://www.iana.org/assignments/uri-schemes/prov/redis).