Finished upgrading the Redis driver

This commit is contained in:
Trial97
2020-08-03 11:12:43 +03:00
committed by Dan Christian Bogos
parent 858bd61b81
commit cfebb0d616
12 changed files with 638 additions and 2404 deletions

View File

@@ -33,4 +33,9 @@
},
"apiers": {
"enabled": true,
},
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -46,7 +46,7 @@ func NewDataDBConn(dbType, host, port, name, user,
if port != "" && strings.Index(host, ":") == -1 {
host += ":" + port
}
d, err = NewRedisStorage(host, dbNo, pass, marshaler, utils.REDIS_MAX_CONNS, sentinelName)
d, err = NewRedisStorage(host, dbNo, user, pass, marshaler, utils.REDIS_MAX_CONNS, sentinelName)
case utils.MONGO:
d, err = NewMongoStorage(host, port, name, user, pass, marshaler, utils.DataDB, nil, true)
case utils.INTERNAL:

View File

@@ -52,7 +52,7 @@ func TestDMitinitDB(t *testing.T) {
case utils.MetaMySQL:
dataDB, err = NewRedisStorage(
fmt.Sprintf("%s:%s", cfg.DataDbCfg().DataDbHost, cfg.DataDbCfg().DataDbPort),
4, cfg.DataDbCfg().DataDbPass, cfg.GeneralCfg().DBDataEncoding,
4, cfg.DataDbCfg().DataDbUser, cfg.DataDbCfg().DataDbPass, cfg.GeneralCfg().DBDataEncoding,
utils.REDIS_MAX_CONNS, "")
if err != nil {
t.Fatal("Could not connect to Redis", err.Error())
@@ -105,9 +105,9 @@ func testDMitCRUDStatQueue(t *testing.T) {
Answered: 2,
Count: 3,
Events: map[string]*StatWithCompress{
"cgrates.org:ev1": &StatWithCompress{Stat: 1},
"cgrates.org:ev2": &StatWithCompress{Stat: 1},
"cgrates.org:ev3": &StatWithCompress{Stat: 0},
"cgrates.org:ev1": {Stat: 1},
"cgrates.org:ev2": {Stat: 1},
"cgrates.org:ev3": {Stat: 0},
},
},
},

View File

@@ -79,7 +79,7 @@ func TestFilterIndexerIT(t *testing.T) {
cfg, _ := config.NewDefaultCGRConfig()
redisDB, err := NewRedisStorage(
fmt.Sprintf("%s:%s", cfg.DataDbCfg().DataDbHost, cfg.DataDbCfg().DataDbPort),
4, cfg.DataDbCfg().DataDbPass, cfg.GeneralCfg().DBDataEncoding,
4, cfg.DataDbCfg().DataDbUser, cfg.DataDbCfg().DataDbPass, cfg.GeneralCfg().DBDataEncoding,
utils.REDIS_MAX_CONNS, "")
if err != nil {
t.Fatal("Could not connect to Redis", err.Error())

View File

@@ -93,7 +93,7 @@ func TestOnStorIT(t *testing.T) {
cfg, _ := config.NewDefaultCGRConfig()
rdsITdb, err = NewRedisStorage(
fmt.Sprintf("%s:%s", cfg.DataDbCfg().DataDbHost, cfg.DataDbCfg().DataDbPort),
4, cfg.DataDbCfg().DataDbPass, cfg.GeneralCfg().DBDataEncoding,
4, cfg.DataDbCfg().DataDbUser, cfg.DataDbCfg().DataDbPass, cfg.GeneralCfg().DBDataEncoding,
utils.REDIS_MAX_CONNS, "")
if err != nil {
t.Fatal("Could not connect to Redis", err.Error())
@@ -1377,7 +1377,8 @@ func testOnStorITCRUDHistory(t *testing.T) {
}
func testOnStorITCRUDStructVersion(t *testing.T) {
if _, err := onStor.DataDB().GetVersions(utils.Accounts); err != utils.ErrNotFound {
if vrst, err := onStor.DataDB().GetVersions(utils.Accounts); err != utils.ErrNotFound {
fmt.Println(vrst)
t.Error(err)
}
vrs := Versions{

View File

@@ -156,7 +156,7 @@ func testRedisSentinelSetGetAttribute(t *testing.T) {
var reply *engine.AttributeProfile
if err := sentinelRPC.Call(utils.APIerSv1GetAttributeProfile,
&utils.TenantID{Tenant: "cgrates.org", ID: "ApierTest"}, &reply); err != nil {
t.Error(err)
t.Fatal(err)
}
reply.Compile()
if !reflect.DeepEqual(alsPrf, reply) {
@@ -268,7 +268,7 @@ func testRedisSentinelGetAttrAfterFailover(t *testing.T) {
var reply *engine.AttributeProfile
if err := sentinelRPC.Call(utils.APIerSv1GetAttributeProfile,
&utils.TenantID{Tenant: "cgrates.org", ID: "ApierTest"}, &reply); err != nil {
t.Error(err)
t.Fatal(err)
}
reply.Compile()
if !reflect.DeepEqual(alsPrf, reply) {

9
go.mod
View File

@@ -35,17 +35,20 @@ require (
github.com/ishidawataru/sctp v0.0.0-20191218070446-00ab2ac2db07 // indirect
github.com/jinzhu/gorm v1.9.15
github.com/lib/pq v1.8.0
github.com/mailru/easyjson v0.7.2 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mediocregopher/radix.v2 v0.0.0-20181115013041-b67df6e626f9
github.com/mediocregopher/radix/v3 v3.5.2 // indirect
github.com/mediocregopher/radix/v3 v3.5.2
github.com/miekg/dns v1.1.30
github.com/mitchellh/mapstructure v1.3.3
github.com/nyaruka/phonenumbers v1.0.56
github.com/peterh/liner v1.2.0
github.com/philhofer/fwd v1.0.0 // indirect
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 // indirect
github.com/robfig/cron/v3 v3.0.1
github.com/segmentio/kafka-go v0.3.7
github.com/streadway/amqp v1.0.0
github.com/ugorji/go/codec v1.1.7
github.com/tinylib/msgp v1.1.2 // indirect
github.com/ugorji/go v0.0.0-20171112025056-5a66da2e74af
github.com/xdg/stringprep v1.0.1-0.20180714160509-73f8eece6fdc // indirect
go.mongodb.org/mongo-driver v1.4.0
golang.org/x/net v0.0.0-20200707034311-ab3426394381

18
go.sum
View File

@@ -194,6 +194,8 @@ github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht
github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc=
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
@@ -213,6 +215,8 @@ github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.8.0 h1:9xohqzkUwzR4Ga4ivdTcawVS89YSDVxXMa3xJX3cGzg=
github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mailru/easyjson v0.7.2 h1:V9ecaZWDYm7v9uJ15RZD6DajMu5sE0hdep0aoDwT9g4=
github.com/mailru/easyjson v0.7.2/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
@@ -220,8 +224,6 @@ github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/Qd
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA=
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
github.com/mediocregopher/radix.v2 v0.0.0-20181115013041-b67df6e626f9 h1:ViNuGS149jgnttqhc6XQNPwdupEMBXqCx9wtlW7P3sA=
github.com/mediocregopher/radix.v2 v0.0.0-20181115013041-b67df6e626f9/go.mod h1:fLRUbhbSd5Px2yKUaGYYPltlyxi1guJz1vCmo1RQL50=
github.com/mediocregopher/radix/v3 v3.5.2 h1:A9u3G7n4+fWmDZ2ZDHtlK+cZl4q55T+7RjKjR0/MAdk=
github.com/mediocregopher/radix/v3 v3.5.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8=
github.com/miekg/dns v1.1.30 h1:Qww6FseFn8PRfw07jueqIXqodm0JKiiKuK0DeXSqfyo=
@@ -234,6 +236,8 @@ github.com/nyaruka/phonenumbers v1.0.56/go.mod h1:sDaTZ/KPX5f8qyV9qN+hIm+4ZBARJr
github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo=
github.com/peterh/liner v1.2.0 h1:w/UPXyl5GfahFxcTOz2j9wCIHNI+pUPr2laqpojKNCg=
github.com/peterh/liner v1.2.0/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
github.com/philhofer/fwd v1.0.0 h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ=
github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@ -242,6 +246,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 h1:xoIK0ctDddBMnc74udxJYBqlo9Ylnsp1waqjLsnef20=
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7/go.mod h1:YARuvh7BUWHNhzDq2OM5tzR2RiCcN2D7sapiKyCel/M=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
@@ -267,10 +273,10 @@ github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/tinylib/msgp v1.1.2 h1:gWmO7n0Ys2RBEb7GPYB9Ujq8Mk5p2U08lRnmMcGy6BQ=
github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
github.com/ugorji/go v0.0.0-20171112025056-5a66da2e74af h1:t75uFwPUcq1o8k4DCN3aDp6dNjSHLmp5mUc5E3PvD2k=
github.com/ugorji/go v0.0.0-20171112025056-5a66da2e74af/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c h1:u40Z8hqBAAQyv+vATcGgV0YCnDjqSL7/q/JyPhhJSPk=
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=

View File

@@ -108,7 +108,7 @@ func (m *Migrator) migrateActionPlans() (err error) {
if m.dmIN.DataManager().DataDB().GetStorageType() == utils.REDIS { // if redis rebuild action plans indexes
redisDB, can := m.dmIN.DataManager().DataDB().(*engine.RedisStorage)
if !can {
return fmt.Errorf("Storage type %s could not be cated to <*engine.RedisStorage>", m.dmIN.DataManager().DataDB().GetStorageType())
return fmt.Errorf("Storage type %s could not be casted to <*engine.RedisStorage>", m.dmIN.DataManager().DataDB().GetStorageType())
}
if err = redisDB.RebbuildActionPlanKeys(); err != nil {
return

View File

@@ -23,7 +23,6 @@ import (
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
"github.com/mediocregopher/radix.v2/redis"
)
type redisMigrator struct {
@@ -66,8 +65,8 @@ func (v1rs *redisMigrator) getv1Account() (v1Acnt *v1Account, err error) {
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err := v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
v1Acnt = &v1Account{Id: v1rs.dataKeys[*v1rs.qryIdx]}
@@ -89,7 +88,7 @@ func (v1rs *redisMigrator) setV1Account(x *v1Account) (err error) {
if err != nil {
return err
}
if err = v1rs.rds.Cmd("SET", key, bit).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(bit)); err != nil {
return err
}
return
@@ -98,7 +97,7 @@ func (v1rs *redisMigrator) setV1Account(x *v1Account) (err error) {
//rem
func (v1rs *redisMigrator) remV1Account(id string) (err error) {
key := v1AccountDBPrefix + id
return v1rs.rds.Cmd("DEL", key).Err
return v1rs.rds.Cmd(nil, "DEL", key)
}
//V2
@@ -114,8 +113,8 @@ func (v1rs *redisMigrator) getv2Account() (v2Acnt *v2Account, err error) {
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err := v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
v2Acnt = &v2Account{ID: v1rs.dataKeys[*v1rs.qryIdx]}
@@ -137,7 +136,7 @@ func (v1rs *redisMigrator) setV2Account(x *v2Account) (err error) {
if err != nil {
return err
}
if err = v1rs.rds.Cmd("SET", key, bit).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(bit)); err != nil {
return err
}
return
@@ -146,7 +145,7 @@ func (v1rs *redisMigrator) setV2Account(x *v2Account) (err error) {
//rem
func (v1rs *redisMigrator) remV2Account(id string) (err error) {
key := utils.ACCOUNT_PREFIX + id
return v1rs.rds.Cmd("DEL", key).Err
return v1rs.rds.Cmd(nil, "DEL", key)
}
//ActionPlans methods
@@ -162,8 +161,8 @@ func (v1rs *redisMigrator) getV1ActionPlans() (v1aps *v1ActionPlans, err error)
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err := v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v1aps); err != nil {
@@ -184,7 +183,7 @@ func (v1rs *redisMigrator) setV1ActionPlans(x *v1ActionPlans) (err error) {
if err != nil {
return err
}
if err = v1rs.rds.Cmd("SET", key, bit).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(bit)); err != nil {
return err
}
return
@@ -193,7 +192,7 @@ func (v1rs *redisMigrator) setV1ActionPlans(x *v1ActionPlans) (err error) {
//rem
func (v1rs *redisMigrator) remV1ActionPlans(x *v1ActionPlans) (err error) {
key := utils.ACTION_PLAN_PREFIX + (*x)[0].Id
return v1rs.rds.Cmd("DEL", key).Err
return v1rs.rds.Cmd(nil, "DEL", key)
}
//Actions methods
@@ -209,8 +208,8 @@ func (v1rs *redisMigrator) getV1Actions() (v1acs *v1Actions, err error) {
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v1acs); err != nil {
@@ -231,7 +230,7 @@ func (v1rs *redisMigrator) setV1Actions(x *v1Actions) (err error) {
if err != nil {
return err
}
if err = v1rs.rds.Cmd("SET", key, bit).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(bit)); err != nil {
return err
}
return
@@ -240,7 +239,7 @@ func (v1rs *redisMigrator) setV1Actions(x *v1Actions) (err error) {
//rem
func (v1rs *redisMigrator) remV1Actions(x v1Actions) (err error) {
key := utils.ACTION_PREFIX + x[0].Id
return v1rs.rds.Cmd("DEL", key).Err
return v1rs.rds.Cmd(nil, "DEL", key)
}
@@ -257,8 +256,8 @@ func (v1rs *redisMigrator) getV1ActionTriggers() (v1acts *v1ActionTriggers, err
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v1acts); err != nil {
@@ -279,7 +278,7 @@ func (v1rs *redisMigrator) setV1ActionTriggers(x *v1ActionTriggers) (err error)
if err != nil {
return err
}
if err = v1rs.rds.Cmd("SET", key, bit).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(bit)); err != nil {
return err
}
return
@@ -288,7 +287,7 @@ func (v1rs *redisMigrator) setV1ActionTriggers(x *v1ActionTriggers) (err error)
//rem
func (v1rs *redisMigrator) remV1ActionTriggers(x *v1ActionTriggers) (err error) {
key := utils.ACTION_TRIGGER_PREFIX + (*x)[0].Id
return v1rs.rds.Cmd("DEL", key).Err
return v1rs.rds.Cmd(nil, "DEL", key)
}
//SharedGroup methods
@@ -304,8 +303,8 @@ func (v1rs *redisMigrator) getV1SharedGroup() (v1sg *v1SharedGroup, err error) {
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v1sg); err != nil {
@@ -326,7 +325,7 @@ func (v1rs *redisMigrator) setV1SharedGroup(x *v1SharedGroup) (err error) {
if err != nil {
return err
}
if err = v1rs.rds.Cmd("SET", key, bit).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(bit)); err != nil {
return err
}
return
@@ -345,8 +344,8 @@ func (v1rs *redisMigrator) getV1Stats() (v1st *v1Stat, err error) {
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v1st); err != nil {
@@ -371,8 +370,8 @@ func (v1rs *redisMigrator) getV3Stats() (v1st *engine.StatQueueProfile, err erro
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v1st); err != nil {
@@ -393,7 +392,7 @@ func (v1rs *redisMigrator) setV1Stats(x *v1Stat) (err error) {
if err != nil {
return err
}
if err = v1rs.rds.Cmd("SET", key, bit).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(bit)); err != nil {
return err
}
return
@@ -411,8 +410,8 @@ func (v1rs *redisMigrator) getV2Stats() (v2 *engine.StatQueue, err error) {
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v2); err != nil {
@@ -433,7 +432,7 @@ func (v1rs *redisMigrator) setV2Stats(v2 *engine.StatQueue) (err error) {
if err != nil {
return err
}
if err = v1rs.rds.Cmd("SET", key, bit).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(bit)); err != nil {
return err
}
return
@@ -452,8 +451,8 @@ func (v1rs *redisMigrator) getV2ActionTrigger() (v2at *v2ActionTrigger, err erro
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v2at); err != nil {
@@ -474,7 +473,7 @@ func (v1rs *redisMigrator) setV2ActionTrigger(x *v2ActionTrigger) (err error) {
if err != nil {
return err
}
if err = v1rs.rds.Cmd("SET", key, bit).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(bit)); err != nil {
return err
}
return
@@ -494,8 +493,8 @@ func (v1rs *redisMigrator) getV1AttributeProfile() (v1attrPrf *v1AttributeProfil
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v1attr); err != nil {
@@ -516,7 +515,7 @@ func (v1rs *redisMigrator) setV1AttributeProfile(x *v1AttributeProfile) (err err
if err != nil {
return err
}
if err = v1rs.rds.Cmd("SET", key, bit).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(bit)); err != nil {
return err
}
return
@@ -536,8 +535,8 @@ func (v1rs *redisMigrator) getV2ThresholdProfile() (v2T *v2Threshold, err error)
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v2Th); err != nil {
@@ -562,8 +561,8 @@ func (v1rs *redisMigrator) getV3ThresholdProfile() (v2T *engine.ThresholdProfile
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v2T); err != nil {
@@ -584,7 +583,7 @@ func (v1rs *redisMigrator) setV2ThresholdProfile(x *v2Threshold) (err error) {
if err != nil {
return err
}
if err = v1rs.rds.Cmd("SET", key, bit).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(bit)); err != nil {
return err
}
return
@@ -593,7 +592,7 @@ func (v1rs *redisMigrator) setV2ThresholdProfile(x *v2Threshold) (err error) {
//rem
func (v1rs *redisMigrator) remV2ThresholdProfile(tenant, id string) (err error) {
key := utils.ThresholdProfilePrefix + utils.ConcatenatedKey(tenant, id)
return v1rs.rds.Cmd("DEL", key).Err
return v1rs.rds.Cmd(nil, "DEL", key)
}
//ThresholdProfile methods
@@ -611,8 +610,8 @@ func (v1rs *redisMigrator) getV1Alias() (v1a *v1Alias, err error) {
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
key := v1rs.dataKeys[*v1rs.qryIdx]
strVal, err := v1rs.rds.Cmd("GET", key).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", key); err != nil {
return nil, err
}
v1a.SetId(strings.TrimPrefix(key, AliasesPrefix))
@@ -635,7 +634,7 @@ func (v1rs *redisMigrator) setV1Alias(al *v1Alias) (err error) {
return
}
key := AliasesPrefix + al.GetId()
if err = v1rs.rds.Cmd("SET", key, result).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(result)); err != nil {
return
}
return
@@ -647,11 +646,11 @@ func (v1rs *redisMigrator) remV1Alias(key string) (err error) {
// get alias for values list
var values []byte
if values, err = v1rs.rds.Cmd("GET",
AliasesPrefix+key).Bytes(); err != nil {
if err == redis.ErrRespNil { // did not find the destination
err = utils.ErrNotFound
}
if err = v1rs.rds.Cmd(&values, "GET",
AliasesPrefix+key); err != nil {
return
} else if len(values) == 0 {
err = utils.ErrNotFound
return
}
al := &v1Alias{Values: make(v1AliasValues, 0)}
@@ -660,7 +659,7 @@ func (v1rs *redisMigrator) remV1Alias(key string) (err error) {
return err
}
err = v1rs.rds.Cmd("DEL", AliasesPrefix+key).Err
err = v1rs.rds.Cmd(nil, "DEL", AliasesPrefix+key)
if err != nil {
return err
}
@@ -669,7 +668,7 @@ func (v1rs *redisMigrator) remV1Alias(key string) (err error) {
for target, pairs := range value.Pairs {
for _, alias := range pairs {
revID := alias + target + al.Context
err = v1rs.rds.Cmd("SREM", reverseAliasesPrefix+revID, tmpKey).Err
err = v1rs.rds.Cmd(nil, "SREM", reverseAliasesPrefix+revID, tmpKey)
if err != nil {
return err
}
@@ -678,7 +677,7 @@ func (v1rs *redisMigrator) remV1Alias(key string) (err error) {
}
return
return v1rs.rds.Cmd("DEL", key).Err
return v1rs.rds.Cmd(nil, "DEL", key)
}
// User methods
@@ -694,8 +693,8 @@ func (v1rs *redisMigrator) getV1User() (v1u *v1UserProfile, err error) {
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
v1u = new(v1UserProfile)
@@ -715,12 +714,12 @@ func (v1rs *redisMigrator) setV1User(us *v1UserProfile) (err error) {
if err != nil {
return err
}
return v1rs.rds.Cmd("SET", utils.USERS_PREFIX+us.GetId(), bit).Err
return v1rs.rds.Cmd(nil, "SET", utils.USERS_PREFIX+us.GetId(), string(bit))
}
//rem
func (v1rs *redisMigrator) remV1User(key string) (err error) {
return v1rs.rds.Cmd("DEL", utils.USERS_PREFIX+key).Err
return v1rs.rds.Cmd(nil, "DEL", utils.USERS_PREFIX+key)
}
// DerivedChargers methods
@@ -736,8 +735,8 @@ func (v1rs *redisMigrator) getV1DerivedChargers() (v1d *v1DerivedChargersWithKey
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
v1d = new(v1DerivedChargersWithKey)
@@ -762,12 +761,12 @@ func (v1rs *redisMigrator) setV1DerivedChargers(dc *v1DerivedChargersWithKey) (e
if err != nil {
return err
}
return v1rs.rds.Cmd("SET", utils.DERIVEDCHARGERS_PREFIX+dc.Key, bit).Err
return v1rs.rds.Cmd(nil, "SET", utils.DERIVEDCHARGERS_PREFIX+dc.Key, string(bit))
}
//rem
func (v1rs *redisMigrator) remV1DerivedChargers(key string) (err error) {
return v1rs.rds.Cmd("DEL", utils.DERIVEDCHARGERS_PREFIX+key).Err
return v1rs.rds.Cmd(nil, "DEL", utils.DERIVEDCHARGERS_PREFIX+key)
}
//AttributeProfile methods
@@ -784,8 +783,8 @@ func (v1rs *redisMigrator) getV2AttributeProfile() (v2attrPrf *v2AttributeProfil
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v2attr); err != nil {
@@ -806,7 +805,7 @@ func (v1rs *redisMigrator) setV2AttributeProfile(x *v2AttributeProfile) (err err
if err != nil {
return err
}
if err = v1rs.rds.Cmd("SET", key, bit).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(bit)); err != nil {
return err
}
return
@@ -815,7 +814,7 @@ func (v1rs *redisMigrator) setV2AttributeProfile(x *v2AttributeProfile) (err err
//rem
func (v1rs *redisMigrator) remV2AttributeProfile(tenant, id string) (err error) {
key := utils.AttributeProfilePrefix + utils.ConcatenatedKey(tenant, id)
return v1rs.rds.Cmd("DEL", key).Err
return v1rs.rds.Cmd(nil, "DEL", key)
}
//AttributeProfile methods
@@ -832,8 +831,8 @@ func (v1rs *redisMigrator) getV3AttributeProfile() (v3attrPrf *v3AttributeProfil
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v3attr); err != nil {
@@ -854,7 +853,7 @@ func (v1rs *redisMigrator) setV3AttributeProfile(x *v3AttributeProfile) (err err
if err != nil {
return err
}
if err = v1rs.rds.Cmd("SET", key, bit).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(bit)); err != nil {
return err
}
return
@@ -863,7 +862,7 @@ func (v1rs *redisMigrator) setV3AttributeProfile(x *v3AttributeProfile) (err err
//rem
func (v1rs *redisMigrator) remV3AttributeProfile(tenant, id string) (err error) {
key := utils.AttributeProfilePrefix + utils.ConcatenatedKey(tenant, id)
return v1rs.rds.Cmd("DEL", key).Err
return v1rs.rds.Cmd(nil, "DEL", key)
}
//AttributeProfile methods
@@ -880,8 +879,8 @@ func (v1rs *redisMigrator) getV4AttributeProfile() (v3attrPrf *v4AttributeProfil
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v4attr); err != nil {
@@ -906,8 +905,8 @@ func (v1rs *redisMigrator) getV5AttributeProfile() (v5attr *engine.AttributeProf
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v5attr); err != nil {
@@ -928,7 +927,7 @@ func (v1rs *redisMigrator) setV4AttributeProfile(x *v4AttributeProfile) (err err
if err != nil {
return err
}
if err = v1rs.rds.Cmd("SET", key, bit).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(bit)); err != nil {
return err
}
return
@@ -937,7 +936,7 @@ func (v1rs *redisMigrator) setV4AttributeProfile(x *v4AttributeProfile) (err err
//rem
func (v1rs *redisMigrator) remV4AttributeProfile(tenant, id string) (err error) {
key := utils.AttributeProfilePrefix + utils.ConcatenatedKey(tenant, id)
return v1rs.rds.Cmd("DEL", key).Err
return v1rs.rds.Cmd(nil, "DEL", key)
}
// Filter Methods
@@ -953,8 +952,8 @@ func (v1rs *redisMigrator) getV1Filter() (v1Fltr *v1Filter, err error) {
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v1Fltr); err != nil {
@@ -979,8 +978,8 @@ func (v1rs *redisMigrator) getV4Filter() (v4Fltr *engine.Filter, err error) {
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v4Fltr); err != nil {
@@ -1001,13 +1000,13 @@ func (v1rs *redisMigrator) setV1Filter(x *v1Filter) (err error) {
if err != nil {
return err
}
return v1rs.rds.Cmd("SET", key, bit).Err
return v1rs.rds.Cmd(nil, "SET", key, string(bit))
}
//rem
func (v1rs *redisMigrator) remV1Filter(tenant, id string) (err error) {
key := utils.FilterPrefix + utils.ConcatenatedKey(tenant, id)
return v1rs.rds.Cmd("DEL", key).Err
return v1rs.rds.Cmd(nil, "DEL", key)
}
// SupplierMethods
@@ -1022,8 +1021,8 @@ func (v1rs *redisMigrator) getSupplier() (spl *SupplierProfile, err error) {
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &spl); err != nil {
@@ -1044,7 +1043,7 @@ func (v1rs *redisMigrator) setSupplier(spl *SupplierProfile) (err error) {
if err != nil {
return err
}
if err = v1rs.rds.Cmd("SET", key, bit).Err; err != nil {
if err = v1rs.rds.Cmd(nil, "SET", key, string(bit)); err != nil {
return err
}
return
@@ -1053,7 +1052,7 @@ func (v1rs *redisMigrator) setSupplier(spl *SupplierProfile) (err error) {
//rem
func (v1rs *redisMigrator) remSupplier(tenant, id string) (err error) {
key := SupplierProfilePrefix + utils.ConcatenatedKey(tenant, id)
return v1rs.rds.Cmd("DEL", key).Err
return v1rs.rds.Cmd(nil, "DEL", key)
}
func (v1rs *redisMigrator) getV1ChargerProfile() (v1chrPrf *engine.ChargerProfile, err error) {
@@ -1067,8 +1066,8 @@ func (v1rs *redisMigrator) getV1ChargerProfile() (v1chrPrf *engine.ChargerProfil
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v1chrPrf); err != nil {
@@ -1093,8 +1092,8 @@ func (v1rs *redisMigrator) getV1DispatcherProfile() (v1chrPrf *engine.Dispatcher
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v1chrPrf); err != nil {
@@ -1119,8 +1118,8 @@ func (v1rs *redisMigrator) getV1RouteProfile() (v1chrPrf *engine.RouteProfile, e
v1rs.qryIdx = utils.IntPointer(0)
}
if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
strVal, err := v1rs.rds.Cmd("GET", v1rs.dataKeys[*v1rs.qryIdx]).Bytes()
if err != nil {
var strVal []byte
if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
return nil, err
}
if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v1chrPrf); err != nil {