Code Review
/
ric-plt
/
sdlgo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
releasing 0.10.4
[ric-plt/sdlgo.git]
/
internal
/
sdlgoredis
/
sdlgosentinel.go
diff --git
a/internal/sdlgoredis/sdlgosentinel.go
b/internal/sdlgoredis/sdlgosentinel.go
index
8a1b331
..
a06722b
100644
(file)
--- a/
internal/sdlgoredis/sdlgosentinel.go
+++ b/
internal/sdlgoredis/sdlgosentinel.go
@@
-1,6
+1,6
@@
/*
Copyright (c) 2021 AT&T Intellectual Property.
/*
Copyright (c) 2021 AT&T Intellectual Property.
- Copyright (c) 2018-202
1
Nokia.
+ Copyright (c) 2018-202
2
Nokia.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@
-30,9
+30,10
@@
import (
)
type Sentinel struct {
)
type Sentinel struct {
- ctx context.Context
+ ctx context.Context
+ MasterName string
+ NodeCnt string
IredisSentinelClient
IredisSentinelClient
- Cfg *Config
}
type IredisSentinelClient interface {
}
type IredisSentinelClient interface {
@@
-41,10
+42,10
@@
type IredisSentinelClient interface {
Sentinels(ctx context.Context, name string) *redis.SliceCmd
}
Sentinels(ctx context.Context, name string) *redis.SliceCmd
}
-type RedisSentinelCreateCb func(
cfg *Config, addr
string) *Sentinel
+type RedisSentinelCreateCb func(
addr, sentinelPort, masterName, nodeCnt
string) *Sentinel
-func newRedisSentinel(
cfg *Config, addr
string) *Sentinel {
- redisAddress := addr + ":" +
cfg.
sentinelPort
+func newRedisSentinel(
addr, sentinelPort, masterName, nodeCnt
string) *Sentinel {
+ redisAddress := addr + ":" + sentinelPort
return &Sentinel{
ctx: context.Background(),
IredisSentinelClient: redis.NewSentinelClient(&redis.Options{
return &Sentinel{
ctx: context.Background(),
IredisSentinelClient: redis.NewSentinelClient(&redis.Options{
@@
-54,7
+55,8
@@
func newRedisSentinel(cfg *Config, addr string) *Sentinel {
PoolSize: 20,
MaxRetries: 2,
}),
PoolSize: 20,
MaxRetries: 2,
}),
- Cfg: cfg,
+ MasterName: masterName,
+ NodeCnt: nodeCnt,
}
}
}
}
@@
-67,9
+69,9
@@
func (s *Sentinel) GetDbState() (*DbState, error) {
state.ReplicasDbState = rState
state.SentinelsDbState = sState
state.ReplicasDbState = rState
state.SentinelsDbState = sState
- cnt, err := strconv.Atoi(s.
Cfg.n
odeCnt)
+ cnt, err := strconv.Atoi(s.
N
odeCnt)
if err != nil {
if err != nil {
- state.Err = fmt.Errorf("Sentinel DBAAS_NODE_COUNT configuration value '%s' conversion to integer failed", s.
Cfg.n
odeCnt)
+ state.Err = fmt.Errorf("Sentinel DBAAS_NODE_COUNT configuration value '%s' conversion to integer failed", s.
N
odeCnt)
return state, state.Err
}
state.ConfigNodeCnt = cnt
return state, state.Err
}
state.ConfigNodeCnt = cnt
@@
-85,7
+87,7
@@
func (s *Sentinel) GetDbState() (*DbState, error) {
func (s *Sentinel) getPrimaryDbState() (*PrimaryDbState, error) {
state := new(PrimaryDbState)
func (s *Sentinel) getPrimaryDbState() (*PrimaryDbState, error) {
state := new(PrimaryDbState)
- redisVal, redisErr := s.Master(s.ctx, s.
Cfg.m
asterName).Result()
+ redisVal, redisErr := s.Master(s.ctx, s.
M
asterName).Result()
if redisErr == nil {
state.Fields.Ip = redisVal["ip"]
state.Fields.Port = redisVal["port"]
if redisErr == nil {
state.Fields.Ip = redisVal["ip"]
state.Fields.Port = redisVal["port"]
@@
-100,7
+102,7
@@
func (s *Sentinel) getReplicasState() (*ReplicasDbState, error) {
states := new(ReplicasDbState)
states.States = make([]*ReplicaDbState, 0)
states := new(ReplicasDbState)
states.States = make([]*ReplicaDbState, 0)
- redisVal, redisErr := s.Slaves(s.ctx, s.
Cfg.m
asterName).Result()
+ redisVal, redisErr := s.Slaves(s.ctx, s.
M
asterName).Result()
if redisErr == nil {
for _, redisReplica := range redisVal {
replicaState := readReplicaState(redisReplica.([]interface{}))
if redisErr == nil {
for _, redisReplica := range redisVal {
replicaState := readReplicaState(redisReplica.([]interface{}))
@@
-133,7
+135,7
@@
func (s *Sentinel) getSentinelsState() (*SentinelsDbState, error) {
states := new(SentinelsDbState)
states.States = make([]*SentinelDbState, 0)
states := new(SentinelsDbState)
states.States = make([]*SentinelDbState, 0)
- redisVal, redisErr := s.Sentinels(s.ctx, s.
Cfg.m
asterName).Result()
+ redisVal, redisErr := s.Sentinels(s.ctx, s.
M
asterName).Result()
if redisErr == nil {
for _, redisSentinel := range redisVal {
sentinelState := readSentinelState(redisSentinel.([]interface{}))
if redisErr == nil {
for _, redisSentinel := range redisVal {
sentinelState := readSentinelState(redisSentinel.([]interface{}))