rrpubsub

package module
v0.0.0-...-99f55ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2021 License: MIT Imports: 9 Imported by: 1

README

rrpubsub

More reliable Redis PubSub for Go. Based on redigo.

Build Status GoDoc

License

This library is distributed under the MIT license.

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

func New(ctx context.Context, network, address string, options ...redis.DialOption) Conn

New returns a new connection that will use the given network and address with the specified options.

func NewURL

func NewURL(ctx context.Context, rawurl string, options ...redis.DialOption) (Conn, error)

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL