distr

package
v0.0.0-...-541d478 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2016 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package distr handles storing data to redis and managing how it is distributed amongst the redis cluster. It also handles cleaning up old data from dead nodes

Index

Constants

This section is empty.

Variables

View Source
var PubCh = make(chan Pub, 1000)

PubCh is where publishes which are being received by this node are written to. They need to be read off the channel and consumed constantly

Functions

func CleanChannels

func CleanChannels(backend bool, timeout time.Duration)

CleanChannels runs through all the channels in the cluster and removes entries from them that are older than the given timeout. Only operates on frontend/backend subs in a single call, so this will probably have to be called twice

func GetNodeIDs

func GetNodeIDs() ([]string, error)

GetNodeIDs returns the IDs of all the currently active nodes. This does a full key scan, so it shouldn't be used in any tight loops.

func GetSubscribed

func GetSubscribed(nodeID, channel string, backend bool, timeout time.Duration) ([]conn.Conn, error)

GetSubscribed returns the set of connections on the given node which are subscribed to the given channel. Does not include backend connections.

func Init

func Init(addr string, poolSize, subConnCount int)

Init initializes the shared util.Cmder instance connected to the given address (single instance or cluster), as well as sets up any necessary go-routines

func Publish

func Publish(p Pub) error

Publish sends the given Pub struct to all listening otter instances, including this one

func Subscribe

func Subscribe(c conn.Conn, channel string) error

Subscribe adds the given connection to the set of connections subscribed to the channel. Backend connections get their own set.

func Unsubscribe

func Unsubscribe(c conn.Conn, channel string) error

Unsubscribe removes the given connection from the set of connections subscribed to the channel

Types

type Pub

type Pub struct {
	// Possible types are "pub", "sub", and "unsub"
	Type    string           `json:"type"`
	Conn    conn.Conn        `json:"connection"`
	Channel string           `json:"channel"`
	Message *json.RawMessage `json:"message,omitempty"`
}

Pub describes a publish message either being sent out to other nodes or being received by this one

Jump to

Keyboard shortcuts

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