Add Get/Set ReqFilterIndexes in Datamanager

This commit is contained in:
TeoV
2017-10-31 14:27:15 +02:00
committed by Dan Christian Bogos
parent 2cad9cfc8f
commit 24b59c4329
7 changed files with 21 additions and 13 deletions

View File

@@ -781,3 +781,11 @@ func (dm *DataManager) RemoveSubscriber(key string) (err error) {
func (dm *DataManager) HasData(category, subject string) (has bool, err error) {
return dm.DataDB().HasDataDrv(category, subject)
}
func (dm *DataManager) GetReqFilterIndexes(dbKey string) (indexes map[string]map[string]utils.StringMap, err error) {
return dm.DataDB().GetReqFilterIndexesDrv(dbKey)
}
func (dm *DataManager) SetReqFilterIndexes(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) {
return dm.DataDB().SetReqFilterIndexesDrv(dbKey, indexes)
}

View File

@@ -23,7 +23,7 @@ import (
)
func NewReqFilterIndexer(dm *DataManager, dbKey string) (*ReqFilterIndexer, error) {
indexes, err := dm.DataDB().GetReqFilterIndexes(dbKey)
indexes, err := dm.GetReqFilterIndexes(dbKey)
if err != nil && err != utils.ErrNotFound {
return nil, err
}
@@ -113,5 +113,5 @@ func (rfi *ReqFilterIndexer) IndexTPFilter(tpFltr *utils.TPFilter, itemID string
// StoreIndexes handles storing the indexes to dataDB
func (rfi *ReqFilterIndexer) StoreIndexes() error {
return rfi.dm.DataDB().SetReqFilterIndexes(rfi.dbKey, rfi.indexes)
return rfi.dm.SetReqFilterIndexes(rfi.dbKey, rfi.indexes)
}

View File

@@ -208,7 +208,7 @@ func testOnStorITSetReqFilterIndexes(t *testing.T) {
},
},
}
if err := onStor.DataDB().SetReqFilterIndexes(utils.ResourceProfilesStringIndex, idxes); err != nil {
if err := onStor.SetReqFilterIndexes(utils.ResourceProfilesStringIndex, idxes); err != nil {
t.Error(err)
}
}
@@ -239,12 +239,12 @@ func testOnStorITGetReqFilterIndexes(t *testing.T) {
},
},
}
if idxes, err := onStor.DataDB().GetReqFilterIndexes(utils.ResourceProfilesStringIndex); err != nil {
if idxes, err := onStor.GetReqFilterIndexes(utils.ResourceProfilesStringIndex); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eIdxes, idxes) {
t.Errorf("Expecting: %+v, received: %+v", eIdxes, idxes)
}
if _, err := onStor.DataDB().GetReqFilterIndexes("unknown_key"); err == nil || err != utils.ErrNotFound {
if _, err := onStor.GetReqFilterIndexes("unknown_key"); err == nil || err != utils.ErrNotFound {
t.Error(err)
}
}

View File

@@ -110,8 +110,8 @@ type DataDB interface {
RemoveTimingDrv(string) error
GetLoadHistory(int, bool, string) ([]*utils.LoadInstance, error)
AddLoadHistory(*utils.LoadInstance, int, string) error
GetReqFilterIndexes(dbKey string) (indexes map[string]map[string]utils.StringMap, err error)
SetReqFilterIndexes(dbKey string, indexes map[string]map[string]utils.StringMap) (err error)
GetReqFilterIndexesDrv(dbKey string) (indexes map[string]map[string]utils.StringMap, err error)
SetReqFilterIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap) (err error)
MatchReqFilterIndex(dbKey, fieldName, fieldVal string) (itemIDs utils.StringMap, err error)
GetStatQueueProfileDrv(tenant string, ID string) (sq *StatQueueProfile, err error)
SetStatQueueProfileDrv(sq *StatQueueProfile) (err error)

View File

@@ -1149,7 +1149,7 @@ func (ms *MapStorage) RemoveTimingDrv(id string) error {
return nil
}
func (ms *MapStorage) GetReqFilterIndexes(dbKey string) (indexes map[string]map[string]utils.StringMap, err error) {
func (ms *MapStorage) GetReqFilterIndexesDrv(dbKey string) (indexes map[string]map[string]utils.StringMap, err error) {
ms.mu.RLock()
defer ms.mu.RUnlock()
values, ok := ms.dict[dbKey]
@@ -1162,7 +1162,7 @@ func (ms *MapStorage) GetReqFilterIndexes(dbKey string) (indexes map[string]map[
}
return
}
func (ms *MapStorage) SetReqFilterIndexes(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) {
func (ms *MapStorage) SetReqFilterIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) {
ms.mu.Lock()
defer ms.mu.Unlock()
result, err := ms.ms.Marshal(indexes)

View File

@@ -1753,7 +1753,7 @@ func (ms *MongoStorage) RemoveTimingDrv(id string) (err error) {
return nil
}
func (ms *MongoStorage) GetReqFilterIndexes(dbKey string) (indexes map[string]map[string]utils.StringMap, err error) {
func (ms *MongoStorage) GetReqFilterIndexesDrv(dbKey string) (indexes map[string]map[string]utils.StringMap, err error) {
session, col := ms.conn(colRFI)
defer session.Close()
var result struct {
@@ -1769,7 +1769,7 @@ func (ms *MongoStorage) GetReqFilterIndexes(dbKey string) (indexes map[string]ma
return result.Value, nil
}
func (ms *MongoStorage) SetReqFilterIndexes(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) {
func (ms *MongoStorage) SetReqFilterIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) {
session, col := ms.conn(colRFI)
defer session.Close()
_, err = col.Upsert(bson.M{"key": dbKey}, &struct {

View File

@@ -1252,7 +1252,7 @@ func (rs *RedisStorage) RemoveTimingDrv(id string) (err error) {
return
}
func (rs *RedisStorage) GetReqFilterIndexes(dbKey string) (indexes map[string]map[string]utils.StringMap, err error) {
func (rs *RedisStorage) GetReqFilterIndexesDrv(dbKey string) (indexes map[string]map[string]utils.StringMap, err error) {
mp, err := rs.Cmd("HGETALL", dbKey).Map()
if err != nil {
return
@@ -1280,7 +1280,7 @@ func (rs *RedisStorage) GetReqFilterIndexes(dbKey string) (indexes map[string]ma
return
}
func (rs *RedisStorage) SetReqFilterIndexes(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) {
func (rs *RedisStorage) SetReqFilterIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) {
mp := make(map[string]string)
for fldName, fldValMp := range indexes {
for fldVal, strMp := range fldValMp {