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 ¶
- Variables
- func CleanChannels(backend bool, timeout time.Duration)
- func GetNodeIDs() ([]string, error)
- func GetSubscribed(nodeID, channel string, backend bool, timeout time.Duration) ([]conn.Conn, error)
- func Init(addr string, poolSize, subConnCount int)
- func Publish(p Pub) error
- func Subscribe(c conn.Conn, channel string) error
- func Unsubscribe(c conn.Conn, channel string) error
- type Pub
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
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 ¶
Publish sends the given Pub struct to all listening otter instances, including this one
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