mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-14 20:59:53 +05:00
Storage.SetStoredSQ and GetStoredSQ
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user