diff --git a/engine/storage_interface.go b/engine/storage_interface.go index 482b76072..4aab3a610 100644 --- a/engine/storage_interface.go +++ b/engine/storage_interface.go @@ -36,6 +36,7 @@ type Storage interface { GetVersions(itm string) (vrs Versions, err error) SetVersions(vrs Versions) (err error) RemoveVersions(vrs Versions) (err error) + SelectDatabase(dbName string) (err error) } // Interface for storage providers. @@ -77,8 +78,7 @@ type RatingStorage interface { RemAccountActionPlans(acntID string, aPlIDs []string) (err error) PushTask(*Task) error PopTask() (*Task, error) - // CacheDataFromDB loads data to cache, prefix represents the cache prefix, IDs should be nil if all available data should be loaded - CacheDataFromDB(prefix string, IDs []string, mustBeCached bool) error // ToDo: Move this to dataManager + CacheDataFromDB(prefix string, IDs []string, mustBeCached bool) error } type AccountingStorage interface { @@ -111,7 +111,6 @@ type AccountingStorage interface { GetReqFilterIndexes(dbKey string) (indexes map[string]map[string]utils.StringMap, err error) SetReqFilterIndexes(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) MatchReqFilterIndex(dbKey, fieldValKey string) (itemIDs utils.StringMap, err error) - // CacheDataFromDB loads data to cache, prefix represents the cache prefix, IDs should be nil if all available data should be loaded CacheDataFromDB(prefix string, IDs []string, mustBeCached bool) error } diff --git a/engine/storage_map.go b/engine/storage_map.go index 5138f2cfe..0cdbc0685 100644 --- a/engine/storage_map.go +++ b/engine/storage_map.go @@ -86,6 +86,10 @@ func (ms *MapStorage) Flush(ignore string) error { return nil } +func (ms *MapStorage) SelectDatabase(dbName string) (err error) { + return +} + func (ms *MapStorage) RebuildReverseForPrefix(prefix string) error { // FIXME: should do transaction keys, err := ms.GetKeysForPrefix(prefix) diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go index e65f58799..8e54ad5be 100644 --- a/engine/storage_mongo_datadb.go +++ b/engine/storage_mongo_datadb.go @@ -322,6 +322,11 @@ func (ms *MongoStorage) Flush(ignore string) (err error) { return dbSession.DB(ms.db).DropDatabase() } +func (ms *MongoStorage) SelectDatabase(dbName string) (err error) { + ms.db = dbName + return +} + func (ms *MongoStorage) RebuildReverseForPrefix(prefix string) (err error) { if !utils.IsSliceMember([]string{utils.REVERSE_DESTINATION_PREFIX, utils.REVERSE_ALIASES_PREFIX, utils.AccountActionPlansPrefix}, prefix) { return utils.ErrInvalidKey diff --git a/engine/storage_redis.go b/engine/storage_redis.go index 9ee96ec88..2dd9188cc 100644 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -109,6 +109,10 @@ func (rs *RedisStorage) Flush(ignore string) error { return rs.Cmd("FLUSHDB").Err } +func (rs *RedisStorage) SelectDatabase(dbName string) (err error) { + return rs.Cmd("SELECT", dbName).Err +} + func (rs *RedisStorage) LoadRatingCache(dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, aplIDs, aaPlIDs, atrgIDs, sgIDs, lcrIDs, dcIDs []string) (err error) { for key, ids := range map[string][]string{ utils.DESTINATION_PREFIX: dstIDs, diff --git a/engine/storage_sql.go b/engine/storage_sql.go index a6a3fb6bb..73972156f 100644 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -53,6 +53,10 @@ func (self *SQLStorage) Flush(scriptsPath string) (err error) { return nil } +func (rs *SQLStorage) SelectDatabase(dbName string) (err error) { + return +} + func (self *SQLStorage) GetKeysForPrefix(prefix string) ([]string, error) { return nil, utils.ErrNotImplemented }