Documentation
¶
Overview ¶
2017-08-12 11:57 Package gxredis provides a redis driver by sentinel ref: https://github.com/alexstocks/go-sentinel/blob/master/sentinel.go
Package gxredis is a generated protocol buffer package. It is generated from these files: redis_meta.proto It has these top-level messages: IPAddr Slave Instance RawInstance
Package gxredis is a generated protocol buffer package.
It is generated from these files:
redis_meta.proto
It has these top-level messages:
IPAddr Slave Instance RawInstance
2017-08-12 11:57 Package gxredis provides a redis driver by sentinel ref: https://github.com/alexstocks/go-sentinel/blob/master/role.go
Index ¶
- Variables
- func CheckRole(c redis.Conn, redisRole RedisRole) bool
- type IPAddr
- func (*IPAddr) Descriptor() ([]byte, []int)
- func (this *IPAddr) Equal(that interface{}) bool
- func (this *IPAddr) GoString() string
- func (m *IPAddr) Marshal() (dAtA []byte, err error)
- func (m *IPAddr) MarshalTo(dAtA []byte) (int, error)
- func (*IPAddr) ProtoMessage()
- func (m *IPAddr) Reset()
- func (m *IPAddr) Size() (n int)
- func (this *IPAddr) String() string
- func (m *IPAddr) TcpAddr() *net.TCPAddr
- func (m *IPAddr) Unmarshal(dAtA []byte) error
- func (this *IPAddr) Validate() error
- func (this *IPAddr) VerboseEqual(that interface{}) error
- type Instance
- func (*Instance) Descriptor() ([]byte, []int)
- func (this *Instance) Equal(that interface{}) bool
- func (this *Instance) GoString() string
- func (m *Instance) Marshal() (dAtA []byte, err error)
- func (m *Instance) MarshalTo(dAtA []byte) (int, error)
- func (*Instance) ProtoMessage()
- func (m *Instance) Reset()
- func (m *Instance) Size() (n int)
- func (this *Instance) String() string
- func (m *Instance) Unmarshal(dAtA []byte) error
- func (this *Instance) Validate() error
- func (this *Instance) VerboseEqual(that interface{}) error
- type MasterSwitchInfo
- type NoSentinelsAvailable
- type RawInstance
- func (*RawInstance) Descriptor() ([]byte, []int)
- func (this *RawInstance) Equal(that interface{}) bool
- func (this *RawInstance) GoString() string
- func (m *RawInstance) Marshal() (dAtA []byte, err error)
- func (m *RawInstance) MarshalTo(dAtA []byte) (int, error)
- func (*RawInstance) ProtoMessage()
- func (m *RawInstance) Reset()
- func (m *RawInstance) Size() (n int)
- func (this *RawInstance) String() string
- func (m *RawInstance) Unmarshal(dAtA []byte) error
- func (this *RawInstance) Validate() error
- func (this *RawInstance) VerboseEqual(that interface{}) error
- type RedisRole
- type SdownInfo
- type Sentinel
- func (s *Sentinel) AddInstance(inst RawInstance) error
- func (s *Sentinel) Close() error
- func (s *Sentinel) Discover(name string, excludeIPArray []string) error
- func (s *Sentinel) GetConn(addr string) redis.Conn
- func (s *Sentinel) GetConnByRole(addr string, role RedisRole) (redis.Conn, error)
- func (s *Sentinel) GetInstanceNames() ([]string, error)
- func (s *Sentinel) GetInstances() ([]Instance, error)
- func (s *Sentinel) GetSentinels() []string
- func (s *Sentinel) MakeMasterSwitchSentinelWatcher() (*SentinelWatcher, error)
- func (s *Sentinel) MakeSdownSentinelWatcher() (*SentinelWatcher, error)
- func (s *Sentinel) MasterAddr(name string) (string, error)
- func (s *Sentinel) RemoveInstance(name string) error
- func (s *Sentinel) SentinelAddrs(name string) ([]string, error)
- func (s *Sentinel) SlaveAddrs(name string) ([]string, error)
- func (s *Sentinel) Slaves(name string) ([]*Slave, error)
- type SentinelWatcher
- type Slave
- func (s *Slave) Address() string
- func (s *Slave) Available() bool
- func (*Slave) Descriptor() ([]byte, []int)
- func (this *Slave) Equal(that interface{}) bool
- func (this *Slave) GoString() string
- func (m *Slave) Marshal() (dAtA []byte, err error)
- func (m *Slave) MarshalTo(dAtA []byte) (int, error)
- func (*Slave) ProtoMessage()
- func (m *Slave) Reset()
- func (m *Slave) Size() (n int)
- func (this *Slave) String() string
- func (m *Slave) Unmarshal(dAtA []byte) error
- func (this *Slave) Validate() error
- func (this *Slave) VerboseEqual(that interface{}) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthRedisMeta = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowRedisMeta = fmt.Errorf("proto: integer overflow") )
var RedisRole_name = map[int32]string{
0: "RR_Default",
1: "RR_Master",
2: "RR_Slave",
3: "RR_Sentinel",
}
var RedisRole_value = map[string]int32{
"RR_Default": 0,
"RR_Master": 1,
"RR_Slave": 2,
"RR_Sentinel": 3,
}
Functions ¶
func CheckRole ¶
CheckRole 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 IPAddr ¶
type IPAddr struct { IP string `protobuf:"bytes,1,opt,name=IP,proto3" json:"IP,omitempty"` Port uint32 `protobuf:"varint,2,opt,name=Port,proto3" json:"Port,omitempty"` }
TCPAddr represents the address of a TCP end point.
func (*IPAddr) Descriptor ¶
func (*IPAddr) ProtoMessage ¶
func (*IPAddr) ProtoMessage()
func (*IPAddr) VerboseEqual ¶
type Instance ¶
type Instance struct { Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` Master *IPAddr `protobuf:"bytes,2,opt,name=Master" json:"Master,omitempty"` Slaves []*Slave `protobuf:"bytes,3,rep,name=Slaves" json:"Slaves,omitempty"` }
func (*Instance) Descriptor ¶
func (*Instance) ProtoMessage ¶
func (*Instance) ProtoMessage()
func (*Instance) VerboseEqual ¶
type MasterSwitchInfo ¶
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 RawInstance ¶
type RawInstance struct { Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` Addr *IPAddr `protobuf:"bytes,2,opt,name=Addr" json:"Addr,omitempty"` Epoch int32 `protobuf:"varint,3,opt,name=Epoch,proto3" json:"Epoch,omitempty"` Sdowntime int32 `protobuf:"varint,4,opt,name=Sdowntime,proto3" json:"Sdowntime,omitempty"` FailoverTimeout int32 `protobuf:"varint,5,opt,name=FailoverTimeout,proto3" json:"FailoverTimeout,omitempty"` NotifyScript string `protobuf:"bytes,6,opt,name=NotifyScript,proto3" json:"NotifyScript,omitempty"` }
func (*RawInstance) Descriptor ¶
func (*RawInstance) Descriptor() ([]byte, []int)
func (*RawInstance) Equal ¶
func (this *RawInstance) Equal(that interface{}) bool
func (*RawInstance) GoString ¶
func (this *RawInstance) GoString() string
func (*RawInstance) Marshal ¶
func (m *RawInstance) Marshal() (dAtA []byte, err error)
func (*RawInstance) ProtoMessage ¶
func (*RawInstance) ProtoMessage()
func (*RawInstance) Reset ¶
func (m *RawInstance) Reset()
func (*RawInstance) Size ¶
func (m *RawInstance) Size() (n int)
func (*RawInstance) String ¶
func (this *RawInstance) String() string
func (*RawInstance) Unmarshal ¶
func (m *RawInstance) Unmarshal(dAtA []byte) error
func (*RawInstance) Validate ¶
func (this *RawInstance) Validate() error
func (*RawInstance) VerboseEqual ¶
func (this *RawInstance) VerboseEqual(that interface{}) error
type Sentinel ¶
type Sentinel struct { // Addrs is a slice with known Sentinel addresses. Addrs []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 (*Sentinel) AddInstance ¶
func (s *Sentinel) AddInstance(inst RawInstance) error
AddInstance adds a redis intance to sentinel to monitor it
func (*Sentinel) Discover ¶
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) GetConnByRole ¶
func (*Sentinel) GetInstanceNames ¶
func (*Sentinel) GetInstances ¶
GetInstances returns redis instances
func (*Sentinel) GetSentinels ¶
GetSentinels retruns redis sentinels
func (*Sentinel) MakeMasterSwitchSentinelWatcher ¶
func (s *Sentinel) MakeMasterSwitchSentinelWatcher() (*SentinelWatcher, error)
func (*Sentinel) MakeSdownSentinelWatcher ¶
func (s *Sentinel) MakeSdownSentinelWatcher() (*SentinelWatcher, error)
func (*Sentinel) MasterAddr ¶
MasterAddr returns an address of @name Redis master instance.
func (*Sentinel) RemoveInstance ¶
RemoveInstance removes a redis intance from sentinel
func (*Sentinel) SentinelAddrs ¶
SentinelAddrs returns a slice of known Sentinel addresses Sentinel server aware of.
func (*Sentinel) SlaveAddrs ¶
SlaveAddrs returns a slice with known slave addresses of @name master instance.
type SentinelWatcher ¶
func NewSentinelWatcher ¶
func NewSentinelWatcher(redisChannel string, conn redis.PubSubConn) *SentinelWatcher
func (*SentinelWatcher) Close ¶
func (s *SentinelWatcher) Close() error
func (*SentinelWatcher) Watch ¶
func (s *SentinelWatcher) Watch() (<-chan interface{}, error)
type Slave ¶
type Slave struct { Addr *IPAddr `protobuf:"bytes,1,opt,name=Addr" json:"Addr,omitempty"` Flags string `protobuf:"bytes,2,opt,name=Flags,proto3" json:"Flags,omitempty"` }
Slave represents a Redis slave instance which is known by Sentinel.
func (*Slave) Available ¶
Available returns if slave is in working state at moment based on information in slave flags.
func (*Slave) Descriptor ¶
func (*Slave) ProtoMessage ¶
func (*Slave) ProtoMessage()