pubsubch

package module
v0.0.0-...-485e543 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2015 License: Apache-2.0 Imports: 5 Imported by: 6

README

pubsubch

A redis pubsub go package to supplement the radix one. This one has the ability to select on a publish channel. You can check out the docs here and you can check out an example here.

Documentation

Overview

Package pubsubch supplements the pubsub package found in the radix suite. This one has the ability to receive incomming publishes over a channel. This channel will be close()'d when the connection is closed.

The methods on the PubSubCh object should only ever be used syncronously. However, the PublishCh, where publishes are pushed to, *should* be read from asyncronously. Any blocking on it may block the whole object.

See the example for a good example of how to use this package

Index

Constants

View Source
const DefaultTimeout = 30 * time.Second

DefaultTimeout is the default read/write timeout used on the tcp socket

Variables

This section is empty.

Functions

This section is empty.

Types

type PubSubCh

type PubSubCh struct {

	// Channel which publishes from channels this connection is subscribed to
	// will be pushed onto. Not reading from this will cause the connection
	// routine to be blocked. This is the only part of PubSubCh which can be
	// interacted with in a different go-routine from the rest. It will be
	// close()'d when the connection is closed
	PublishCh chan *Publish
	// contains filtered or unexported fields
}

PubSubCh is a container for the channeled pubsub connection. All methods should be called syncronously, however the PublishCh can (and should) be read from asyncronously.

func Dial

func Dial(addr string) (*PubSubCh, error)

Dial is like DialTimeout, but it uses the DefaultTimeout

func DialTimeout

func DialTimeout(addr string, timeout time.Duration) (*PubSubCh, error)

DialTimeout creates a new PubSubCh with the given timeout. That timeout will be used when reading and writing to the underlying connection

func (*PubSubCh) Close

func (p *PubSubCh) Close() error

Close closes the connection. No methods should be called after this is called. This will cause the PublishCh to close

func (*PubSubCh) PSubscribe

func (p *PubSubCh) PSubscribe(pattern ...string) (int64, error)

PSubscribe is like Subscribe but it takes in a set of patterns instead of channel names

func (*PubSubCh) PUnsubscribe

func (p *PubSubCh) PUnsubscribe(pattern ...string) (int64, error)

PUnsubscribe is like Unsubscribe but it takes in a set of patterns instead of channel names

You *must* provide at least one pattern here, the empty argument form of the command does not work with this package

func (*PubSubCh) Ping

func (p *PubSubCh) Ping() error

Ping calls the PING command on the connection. This will only return an error if the connection has been closed

func (*PubSubCh) Subscribe

func (p *PubSubCh) Subscribe(channel ...string) (int64, error)

Subscribe subscribes this connection to the given set of channels

func (*PubSubCh) Unsubscribe

func (p *PubSubCh) Unsubscribe(channel ...string) (int64, error)

Unsubscribe unsubscribes this connection from the given channels

You *must* provide at least one channel here, the empty argument form of the command does not work with this package

type Publish

type Publish struct {
	Message string
	Channel string
}

Publish is sent back over the PublishCh and represents a single publish the connection has seen

Directories

Path Synopsis
Package inner contains some methods needed to implement an interface for manatcp.
Package inner contains some methods needed to implement an interface for manatcp.

Jump to

Keyboard shortcuts

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