StoreDisable implementation for both CDRS and Mediator

This commit is contained in:
DanB
2014-08-02 13:58:15 +02:00
parent f72568054b
commit bcf4c3d08e
3 changed files with 11 additions and 7 deletions

View File

@@ -1277,7 +1277,7 @@ func TestResetDataAfterLoadFromFolder(t *testing.T) {
t.Error("Calling ApierV1.ReloadCache got reply: ", reply)
}
var rcvStats *utils.CacheStats
expectedStats := &utils.CacheStats{Destinations: 4, RatingPlans: 3, RatingProfiles: 3, Actions: 4, DerivedChargers: 2}
expectedStats := &utils.CacheStats{Destinations: 4, RatingPlans: 3, RatingProfiles: 3, Actions: 5, DerivedChargers: 2}
var args utils.AttrCacheStats
if err := rater.Call("ApierV1.GetCacheStats", args, &rcvStats); err != nil {
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())

View File

@@ -36,6 +36,11 @@ var (
// Returns error if not able to properly store the CDR, mediation is async since we can always recover offline
func storeAndMediate(storedCdr *utils.StoredCdr) error {
if !cfg.CDRSStoreDisable {
if err := storage.SetCdr(storedCdr); err != nil {
return err
}
}
if stats != nil {
go func() {
if err := stats.AppendCDR(storedCdr, nil); err != nil {
@@ -43,9 +48,6 @@ func storeAndMediate(storedCdr *utils.StoredCdr) error {
}
}()
}
if err := storage.SetCdr(storedCdr); err != nil {
return err
}
if cfg.CDRSMediator == utils.INTERNAL {
go func() {
if err := medi.RateCdr(storedCdr, true); err != nil {

View File

@@ -168,9 +168,11 @@ func (self *Mediator) RateCdr(storedCdr *utils.StoredCdr, sendToStats bool) erro
if err := self.rateCDR(cdr); err != nil {
extraInfo = err.Error()
}
if err := self.cdrDb.SetRatedCdr(cdr, extraInfo); err != nil {
Logger.Err(fmt.Sprintf("<Mediator> Could not record cost for cgrid: <%s>, ERROR: <%s>, cost: %f, extraInfo: %s",
cdr.CgrId, err.Error(), cdr.Cost, extraInfo))
if !self.cgrCfg.MediatorStoreDisable {
if err := self.cdrDb.SetRatedCdr(cdr, extraInfo); err != nil {
Logger.Err(fmt.Sprintf("<Mediator> Could not record cost for cgrid: <%s>, ERROR: <%s>, cost: %f, extraInfo: %s",
cdr.CgrId, err.Error(), cdr.Cost, extraInfo))
}
}
if sendToStats && self.stats != nil { // We send to stats only after saving to db since there are chances we cannot store and then no way to reproduce stats offline
go func() {