sentinel

package module
v0.0.0-...-95d10dd Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

README

go-sentinel

Redis Sentinel support for redigo library.

API is unstable and can change at any moment – use with tools like Glide, Godep etc.

Documentation

License

Library is available under the Apache License, Version 2.0.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestRole

func TestRole(c redis.Conn, expectedRole string) bool

TestRole wraps GetRole in a test to verify if the role matches an expected role string. If there was any error in querying the supplied connection, the function returns false. Works with Redis >= 2.8.12. It's not goroutine safe, but if you call this method on pooled connections then you are OK.

Types

type MasterSentinel

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

func (*MasterSentinel) Close

func (ms *MasterSentinel) Close() error

func (*MasterSentinel) Watch

func (ms *MasterSentinel) Watch() (<-chan string, error)

type NoSentinelsAvailable

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

NoSentinelsAvailable is returned when all sentinels in the list are exhausted (or none configured), and contains the last error returned by Dial (which may be nil)

func (NoSentinelsAvailable) Error

func (ns NoSentinelsAvailable) Error() string

type Sentinel

type Sentinel struct {
	// Addrs is a slice with known Sentinel addresses.
	Addrs []string

	// MasterName is a name of Redis master Sentinel servers monitor.
	MasterName string

	// Dial is a user supplied function to connect to Sentinel on given address. This
	// address will be chosen from Addrs slice.
	// Note that as per the redis-sentinel client guidelines, a timeout is mandatory
	// while connecting to Sentinels, and should not be set to 0.
	Dial func(addr string) (redis.Conn, error)

	// Pool is a user supplied function returning custom connection pool to Sentinel.
	// This can be useful to tune options if you are not satisfied with what default
	// Sentinel pool offers. See defaultPool() method for default pool implementation.
	// In most cases you only need to provide Dial function and let this be nil.
	Pool func(addr string) *redis.Pool
	// contains filtered or unexported fields
}

func NewSentinel

func NewSentinel(addrs []string, masterName string) *Sentinel

func (*Sentinel) Close

func (s *Sentinel) Close() error

Close closes current connection to Sentinel.

func (*Sentinel) Discover

func (s *Sentinel) Discover() error

Discover allows to update list of known Sentinel addresses. From docs:

A client may update its internal list of Sentinel nodes following this procedure: 1) Obtain a list of other Sentinels for this master using the command SENTINEL sentinels <master-name>. 2) Add every ip:port pair not already existing in our list at the end of the list.

func (*Sentinel) MasterAddr

func (s *Sentinel) MasterAddr() (string, error)

MasterAddr returns an address of current Redis master instance.

func (*Sentinel) MasterSwitch

func (s *Sentinel) MasterSwitch() (*MasterSentinel, error)

func (*Sentinel) SentinelAddrs

func (s *Sentinel) SentinelAddrs() ([]string, error)

SentinelAddrs returns a slice of known Sentinel addresses Sentinel server aware of.

func (*Sentinel) SlaveAddrs

func (s *Sentinel) SlaveAddrs() ([]string, error)

SlaveAddrs returns a slice with known slaves of current master instance.

type SentinelPool

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

func NewSentinelPool

func NewSentinelPool(addrs []string, masterName string,
	defaultDb int, password string) *SentinelPool

func (*SentinelPool) Close

func (p *SentinelPool) Close()

func (*SentinelPool) Get

func (p *SentinelPool) Get() redis.Conn

redis.Conn must Close after use

func (*SentinelPool) MasterAddr

func (p *SentinelPool) MasterAddr() string

Jump to

Keyboard shortcuts

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