logging on one time action and delete action timing key empty

This commit is contained in:
Radu Ioan Fericean
2012-08-10 18:47:30 +03:00
parent a7033f88c8
commit 1c56418f40
3 changed files with 11 additions and 0 deletions

View File

@@ -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:]...)

View File

@@ -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

View File

@@ -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)
}