mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-19 22:28:45 +05:00
logging on one time action and delete action timing key empty
This commit is contained in:
@@ -76,6 +76,7 @@ func loadActionTimings(storage timespans.StorageGetter) {
|
||||
for i, at := range ats {
|
||||
toBeSaved = toBeSaved || at.CheckForASAP()
|
||||
if at.IsOneTimeRun() {
|
||||
timespans.Logger.Info(fmt.Sprintf("Time for one time action on %v", at)
|
||||
go at.Execute()
|
||||
// remove it from list
|
||||
ats = append(ats[:i], ats[i+1:]...)
|
||||
|
||||
@@ -112,6 +112,11 @@ func (ms *MapStorage) GetActionTimings(key string) (ats []*ActionTiming, err err
|
||||
}
|
||||
|
||||
func (ms *MapStorage) SetActionTimings(key string, ats []*ActionTiming) (err error) {
|
||||
if len(ats) == 0 {
|
||||
// delete the key
|
||||
delete(ms.dict, key)
|
||||
return
|
||||
}
|
||||
result, err := ms.ms.Marshal(ats)
|
||||
ms.dict[key] = result
|
||||
return
|
||||
|
||||
@@ -112,6 +112,11 @@ func (rs *RedisStorage) GetActionTimings(key string) (ats []*ActionTiming, err e
|
||||
}
|
||||
|
||||
func (rs *RedisStorage) SetActionTimings(key string, ats []*ActionTiming) (err error) {
|
||||
if len(ats) == 0 {
|
||||
// delete the key
|
||||
_, err = rs.db.Del(key)
|
||||
return
|
||||
}
|
||||
result, err := rs.ms.Marshal(ats)
|
||||
return rs.db.Set(key, result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user