Storage.SetStoredSQ and GetStoredSQ

This commit is contained in:
DanB
2017-07-14 21:34:02 +02:00
parent 02e5e26c1f
commit c63760942e
6 changed files with 46 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ type SQItem struct {
// SQStored contains values saved in DB on store
type StoredSQ struct {
SqID string // StatsQueueID
SEvents map[string]StatsEvent // Events used by SQItems
SQItems []*SQItem // SQItems
SQMetrics map[string][]byte

View File

@@ -110,6 +110,8 @@ type DataDB 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)
SetStoredSQ(ssq *StoredSQ) (err error) // stores StatsQueue
GetStoredSQ(sqID string) (ssq *StoredSQ, 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 // ToDo: Move this to dataManager
}

View File

@@ -1548,3 +1548,25 @@ func (ms *MapStorage) SetVersions(vrs Versions, overwrite bool) (err error) {
func (ms *MapStorage) RemoveVersions(vrs Versions) (err error) {
return
}
// SetStoredSQ stores the variable part of a StatsQueue
func (ms *MapStorage) SetStoredSQ(ssq *StoredSQ) (err error) {
ms.mu.Lock()
defer ms.mu.Unlock()
var result []byte
result, err = ms.ms.Marshal(ssq)
ms.dict[utils.StoredSQPrefix+ssq.SqID] = result
return
}
// GetStoredSQ retrieves the variable part of a StatsQueue
func (ms *MapStorage) GetStoredSQ(sqID string) (ssq *StoredSQ, err error) {
ms.mu.RLock()
defer ms.mu.RUnlock()
values, ok := ms.dict[utils.StoredSQPrefix+ssq.SqID]
if !ok {
return nil, utils.ErrNotFound
}
err = ms.ms.Unmarshal(values, &ssq)
return
}

View File

@@ -2008,3 +2008,13 @@ func (ms *MongoStorage) MatchReqFilterIndex(dbKey, fieldValKey string) (itemIDs
cache.Set(cacheKey, itemIDs, true, utils.NonTransactional)
return
}
// SetStoredSQ stores the variable part of a StatsQueue
func (ms *MongoStorage) SetStoredSQ(ssq *StoredSQ) (err error) {
return
}
// GetStoredSQ retrieves the variable part of a StatsQueue
func (ms *MongoStorage) GetStoredSQ(sqID string) (ssq *StoredSQ, err error) {
return
}

View File

@@ -1566,3 +1566,13 @@ func (rs *RedisStorage) SetVersions(vrs Versions, overwrite bool) (err error) {
func (rs *RedisStorage) RemoveVersions(vrs Versions) (err error) {
return
}
// SetStoredSQ stores the variable part of a StatsQueue
func (rs *RedisStorage) SetStoredSQ(ssq *StoredSQ) (err error) {
return
}
// GetStoredSQ retrieves the variable part of a StatsQueue
func (rs *RedisStorage) GetStoredSQ(sqID string) (ssq *StoredSQ, err error) {
return
}