pubsub

package module
v0.0.0-...-bae7609 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2014 License: MIT Imports: 2 Imported by: 0

README

pubsub

A small Golang library for Redis backed pub/sub messaging

Documentation

Overview

PubSub implements a simple Redis backed publish-subscribe client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

PubSub is a Redis pub/sub client. It uses a connection pool for communicating with Redis.

func Dial

func Dial(network string, address string, idle int, active int) Conn

Dial connects to the Redis server with the given network and address.

func (Conn) Close

func (c Conn) Close()

Closes the connection to Redis. This closes the connection pool.

func (Conn) Publish

func (c Conn) Publish(topic string, msg []byte)

Publish a message with the given topic.

func (Conn) Subscribe

func (c Conn) Subscribe(topic string, chn chan<- []byte)

Subscribe to topic and get messages received for this topic sent to the given channel.

func (Conn) SubscribeMessage

func (c Conn) SubscribeMessage(topic string, chn chan<- Message)

Subscribe to topic and get messages received for this topic sent to the given channel as a message with an envelop that contains the topic name.

This can be used for distinguishing messages by topic if multiple subscriptions send to a single channel.

type Message

type Message struct {
	Topic   string          `json:"topic"`
	Payload json.RawMessage `json:"payload"`
}

Message is an envelop for a JSON message with lazy unmarshalling for the payload.

Jump to

Keyboard shortcuts

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