diff --git a/apier/v1/apier.go b/apier/v1/apier.go
index c628fd5b2..f4766d930 100644
--- a/apier/v1/apier.go
+++ b/apier/v1/apier.go
@@ -26,6 +26,7 @@ import (
"path"
"strconv"
"strings"
+ "time"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
@@ -379,7 +380,7 @@ func (self *ApierV1) SetRatingProfile(attrs utils.AttrSetRatingProfile, reply *s
return utils.NewErrServerError(err)
}
//generate a loadID for CacheRatingProfiles and store it in database
- if err := self.DataManager.SetLoadIDs(map[string]string{utils.CacheRatingProfiles: utils.UUIDSha1Prefix()}); err != nil {
+ if err := self.DataManager.SetLoadIDs(map[string]int64{utils.CacheRatingProfiles: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
*reply = OK
@@ -499,7 +500,7 @@ func (self *ApierV1) SetActions(attrs V1AttrSetActions, reply *string) (err erro
return utils.NewErrServerError(err)
}
//generate a loadID for CacheActions and store it in database
- if err := self.DataManager.SetLoadIDs(map[string]string{utils.CacheActions: utils.UUIDSha1Prefix()}); err != nil {
+ if err := self.DataManager.SetLoadIDs(map[string]int64{utils.CacheActions: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
*reply = OK
@@ -632,7 +633,7 @@ func (self *ApierV1) SetActionPlan(attrs AttrSetActionPlan, reply *string) (err
sched.Reload()
}
//generate a loadID for CacheActionPlans and store it in database
- if err := self.DataManager.SetLoadIDs(map[string]string{utils.CacheActionPlans: utils.UUIDSha1Prefix()}); err != nil {
+ if err := self.DataManager.SetLoadIDs(map[string]int64{utils.CacheActionPlans: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
*reply = OK
@@ -805,7 +806,7 @@ func (self *ApierV1) RemoveRatingProfile(attr AttrRemoveRatingProfile, reply *st
return utils.NewErrServerError(err)
}
//generate a loadID for CacheActionPlans and store it in database
- if err := self.DataManager.SetLoadIDs(map[string]string{utils.CacheRatingProfiles: utils.UUIDSha1Prefix()}); err != nil {
+ if err := self.DataManager.SetLoadIDs(map[string]int64{utils.CacheRatingProfiles: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
@@ -895,7 +896,7 @@ func (self *ApierV1) RemoveActions(attr AttrRemoveActions, reply *string) error
}
}
//generate a loadID for CacheActions and store it in database
- if err := self.DataManager.SetLoadIDs(map[string]string{utils.CacheActions: utils.UUIDSha1Prefix()}); err != nil {
+ if err := self.DataManager.SetLoadIDs(map[string]int64{utils.CacheActions: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
@@ -1039,7 +1040,7 @@ func (v1 *ApierV1) CallCache(cacheOpt string, args engine.ArgsGetCacheItem) (err
return
}
-func (v1 *ApierV1) GetCacheVersions(args string, reply *map[string]string) (err error) {
+func (v1 *ApierV1) GetLoadIDs(args string, reply *map[string]int64) (err error) {
if loadIDs, err := v1.DataManager.GetItemLoadIDs(args, false); err != nil {
return err
} else {
@@ -1047,3 +1048,25 @@ func (v1 *ApierV1) GetCacheVersions(args string, reply *map[string]string) (err
}
return
}
+
+type LoadTimeArgs struct {
+ Timezone string
+ Item string
+}
+
+func (v1 *ApierV1) GetLoadTimes(args LoadTimeArgs, reply *map[string]string) (err error) {
+ if loadIDs, err := v1.DataManager.GetItemLoadIDs(args.Item, false); err != nil {
+ return err
+ } else {
+ provMp := make(map[string]string)
+ for key, val := range loadIDs {
+ timeVal, err := utils.ParseTimeDetectLayout(strconv.FormatInt(val, 10), args.Timezone)
+ if err != nil {
+ return err
+ }
+ provMp[key] = timeVal.String()
+ }
+ *reply = provMp
+ }
+ return
+}
diff --git a/apier/v1/attributes.go b/apier/v1/attributes.go
index 47f8a5321..061ba7f78 100644
--- a/apier/v1/attributes.go
+++ b/apier/v1/attributes.go
@@ -19,6 +19,8 @@ along with this program. If not, see
package v1
import (
+ "time"
+
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -86,7 +88,7 @@ func (apierV1 *ApierV1) SetAttributeProfile(alsWrp *AttributeWithCache, reply *s
return utils.APIErrorHandler(err)
}
//generate a loadID for CacheAttributeProfiles and store it in database
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheAttributeProfiles: utils.UUIDSha1Prefix()}); err != nil {
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheAttributeProfiles: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
args := engine.ArgsGetCacheItem{
@@ -110,7 +112,7 @@ func (apierV1 *ApierV1) RemoveAttributeProfile(arg *utils.TenantIDWrapper, reply
return utils.APIErrorHandler(err)
}
//generate a loadID for CacheAttributeProfiles and store it in database
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheAttributeProfiles: utils.UUIDSha1Prefix()}); err != nil {
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheAttributeProfiles: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
args := engine.ArgsGetCacheItem{
diff --git a/apier/v1/chargers.go b/apier/v1/chargers.go
index 89709bf11..1a1a236f4 100644
--- a/apier/v1/chargers.go
+++ b/apier/v1/chargers.go
@@ -19,6 +19,8 @@ along with this program. If not, see
package v1
import (
+ "time"
+
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -68,7 +70,7 @@ func (apierV1 *ApierV1) SetChargerProfile(arg *ChargerWithCache, reply *string)
return utils.APIErrorHandler(err)
}
//generate a loadID for CacheChargerProfiles and store it in database
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheChargerProfiles: utils.UUIDSha1Prefix()}); err != nil {
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheChargerProfiles: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for ChargerProfile
@@ -93,7 +95,7 @@ func (apierV1 *ApierV1) RemoveChargerProfile(arg utils.TenantIDWrapper, reply *s
return utils.APIErrorHandler(err)
}
//generate a loadID for CacheChargerProfiles and store it in database
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheChargerProfiles: utils.UUIDSha1Prefix()}); err != nil {
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheChargerProfiles: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for ChargerProfile
diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go
index 2c5cf0e6d..879c07a77 100755
--- a/apier/v1/dispatcher.go
+++ b/apier/v1/dispatcher.go
@@ -73,7 +73,7 @@ func (apierV1 *ApierV1) SetDispatcherProfile(args *DispatcherWithCache, reply *s
return utils.APIErrorHandler(err)
}
//generate a loadID for CacheDispatcherProfiles and store it in database
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheDispatcherProfiles: utils.UUIDSha1Prefix()}); err != nil {
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheDispatcherProfiles: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for DispatcherProfile
@@ -98,7 +98,7 @@ func (apierV1 *ApierV1) RemoveDispatcherProfile(arg *utils.TenantIDWrapper, repl
return utils.APIErrorHandler(err)
}
//generate a loadID for CacheDispatcherProfiles and store it in database
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheDispatcherProfiles: utils.UUIDSha1Prefix()}); err != nil {
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheDispatcherProfiles: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for DispatcherProfile
@@ -158,7 +158,7 @@ func (apierV1 *ApierV1) SetDispatcherHost(args *DispatcherHostWrapper, reply *st
return utils.APIErrorHandler(err)
}
//generate a loadID for CacheDispatcherHosts and store it in database
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheDispatcherHosts: utils.UUIDSha1Prefix()}); err != nil {
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheDispatcherHosts: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for DispatcherProfile
@@ -183,7 +183,7 @@ func (apierV1 *ApierV1) RemoveDispatcherHost(arg *utils.TenantIDWrapper, reply *
return utils.APIErrorHandler(err)
}
//generate a loadID for CacheDispatcherHosts and store it in database
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheDispatcherHosts: utils.UUIDSha1Prefix()}); err != nil {
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheDispatcherHosts: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for DispatcherProfile
diff --git a/apier/v1/filters.go b/apier/v1/filters.go
index 67082894c..e227f7cf8 100644
--- a/apier/v1/filters.go
+++ b/apier/v1/filters.go
@@ -19,6 +19,8 @@ along with this program. If not, see
package v1
import (
+ "time"
+
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -37,7 +39,7 @@ func (apierV1 *ApierV1) SetFilter(arg *FilterWithCache, reply *string) error {
return utils.APIErrorHandler(err)
}
//generate a loadID for CacheFilters and store it in database
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheFilters: utils.UUIDSha1Prefix()}); err != nil {
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheFilters: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for Filter
@@ -92,7 +94,7 @@ func (apierV1 *ApierV1) RemoveFilter(arg utils.TenantIDWrapper, reply *string) e
return utils.APIErrorHandler(err)
}
//generate a loadID for CacheFilters and store it in database
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheFilters: utils.UUIDSha1Prefix()}); err != nil {
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheFilters: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for Filter
diff --git a/apier/v1/resourcesv1.go b/apier/v1/resourcesv1.go
index 187ea6b4b..105eea26f 100644
--- a/apier/v1/resourcesv1.go
+++ b/apier/v1/resourcesv1.go
@@ -19,6 +19,8 @@ along with this program. If not, see
package v1
import (
+ "time"
+
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -116,8 +118,8 @@ func (apierV1 *ApierV1) SetResourceProfile(arg *ResourceWithCache, reply *string
}
//generate a loadID for CacheResourceProfiles and CacheResources and store it in database
//make 1 insert for both ResourceProfile and Resources instead of 2
- loadID := utils.UUIDSha1Prefix()
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheResourceProfiles: loadID, utils.CacheResources: loadID}); err != nil {
+ loadID := time.Now().UnixNano()
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheResourceProfiles: loadID, utils.CacheResources: loadID}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for ResourceProfile
@@ -167,8 +169,8 @@ func (apierV1 *ApierV1) RemoveResourceProfile(arg utils.TenantIDWrapper, reply *
}
//generate a loadID for CacheResourceProfiles and CacheResources and store it in database
//make 1 insert for both ResourceProfile and Resources instead of 2
- loadID := utils.UUIDSha1Prefix()
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheResourceProfiles: loadID, utils.CacheResources: loadID}); err != nil {
+ loadID := time.Now().UnixNano()
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheResourceProfiles: loadID, utils.CacheResources: loadID}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for Resource
diff --git a/apier/v1/stats.go b/apier/v1/stats.go
index 19dcc3ce8..e61bbc631 100644
--- a/apier/v1/stats.go
+++ b/apier/v1/stats.go
@@ -19,6 +19,8 @@ along with this program. If not, see
package v1
import (
+ "time"
+
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -70,8 +72,8 @@ func (apierV1 *ApierV1) SetStatQueueProfile(arg *StatQueueWithCache, reply *stri
}
//generate a loadID for CacheStatQueueProfiles and CacheStatQueues and store it in database
//make 1 insert for both StatQueueProfile and StatQueue instead of 2
- loadID := utils.UUIDSha1Prefix()
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheStatQueueProfiles: loadID, utils.CacheStatQueues: loadID}); err != nil {
+ loadID := time.Now().UnixNano()
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheStatQueueProfiles: loadID, utils.CacheStatQueues: loadID}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for StatQueueProfile
@@ -128,8 +130,8 @@ func (apierV1 *ApierV1) RemStatQueueProfile(args *utils.TenantIDWrapper, reply *
}
//generate a loadID for CacheStatQueueProfiles and CacheStatQueues and store it in database
//make 1 insert for both StatQueueProfile and StatQueue instead of 2
- loadID := utils.UUIDSha1Prefix()
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheStatQueueProfiles: loadID, utils.CacheStatQueues: loadID}); err != nil {
+ loadID := time.Now().UnixNano()
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheStatQueueProfiles: loadID, utils.CacheStatQueues: loadID}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for StatQueues
diff --git a/apier/v1/suppliers.go b/apier/v1/suppliers.go
index 1495e775a..15ab95c87 100644
--- a/apier/v1/suppliers.go
+++ b/apier/v1/suppliers.go
@@ -19,6 +19,8 @@ along with this program. If not, see
package v1
import (
+ "time"
+
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -68,7 +70,7 @@ func (apierV1 *ApierV1) SetSupplierProfile(args *SupplierWithCache, reply *strin
return utils.APIErrorHandler(err)
}
//generate a loadID for CacheSupplierProfiles and store it in database
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheSupplierProfiles: utils.UUIDSha1Prefix()}); err != nil {
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheSupplierProfiles: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for SupplierProfile
@@ -92,7 +94,7 @@ func (apierV1 *ApierV1) RemoveSupplierProfile(args *utils.TenantIDWrapper, reply
return utils.APIErrorHandler(err)
}
//generate a loadID for CacheSupplierProfiles and store it in database
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheSupplierProfiles: utils.UUIDSha1Prefix()}); err != nil {
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheSupplierProfiles: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for SupplierProfile
diff --git a/apier/v1/thresholds.go b/apier/v1/thresholds.go
index 5b7c0f7e2..ecdba7cd7 100644
--- a/apier/v1/thresholds.go
+++ b/apier/v1/thresholds.go
@@ -19,6 +19,8 @@ along with this program. If not, see
package v1
import (
+ "time"
+
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -104,8 +106,8 @@ func (apierV1 *ApierV1) SetThresholdProfile(args *ThresholdWithCache, reply *str
}
//generate a loadID for CacheThresholdProfiles and CacheThresholds and store it in database
//make 1 insert for both ThresholdProfile and Threshold instead of 2
- loadID := utils.UUIDSha1Prefix()
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheThresholdProfiles: loadID, utils.CacheThresholds: loadID}); err != nil {
+ loadID := time.Now().UnixNano()
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheThresholdProfiles: loadID, utils.CacheThresholds: loadID}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for ThresholdProfile
@@ -152,8 +154,8 @@ func (apierV1 *ApierV1) RemoveThresholdProfile(args *utils.TenantIDWrapper, repl
}
//generate a loadID for CacheThresholdProfiles and CacheThresholds and store it in database
//make 1 insert for both ThresholdProfile and Threshold instead of 2
- loadID := utils.UUIDSha1Prefix()
- if err := apierV1.DataManager.SetLoadIDs(map[string]string{utils.CacheThresholdProfiles: loadID, utils.CacheThresholds: loadID}); err != nil {
+ loadID := time.Now().UnixNano()
+ if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheThresholdProfiles: loadID, utils.CacheThresholds: loadID}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for Threshold
diff --git a/apier/v2/apier.go b/apier/v2/apier.go
index b650c4dd4..8bede9d58 100644
--- a/apier/v2/apier.go
+++ b/apier/v2/apier.go
@@ -26,6 +26,7 @@ import (
"path"
"strconv"
"strings"
+ "time"
v1 "github.com/cgrates/cgrates/apier/v1"
"github.com/cgrates/cgrates/config"
@@ -327,7 +328,7 @@ func (self *ApierV2) SetActions(attrs utils.AttrSetActions, reply *string) error
return utils.NewErrServerError(err)
}
//generate a loadID for CacheActions and store it in database
- if err := self.DataManager.SetLoadIDs(map[string]string{utils.CacheActions: utils.UUIDSha1Prefix()}); err != nil {
+ if err := self.DataManager.SetLoadIDs(map[string]int64{utils.CacheActions: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
diff --git a/apier/v2/attributes.go b/apier/v2/attributes.go
index c37f2ee80..bfe1b582e 100644
--- a/apier/v2/attributes.go
+++ b/apier/v2/attributes.go
@@ -19,6 +19,8 @@ along with this program. If not, see
package v2
import (
+ "time"
+
v1 "github.com/cgrates/cgrates/apier/v1"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
@@ -42,7 +44,7 @@ func (apierV2 *ApierV2) SetAttributeProfile(extAlsPrfWrp *AttributeWithCache, re
return utils.APIErrorHandler(err)
}
//generate a loadID for CacheAttributeProfiles and store it in database
- if err := apierV2.DataManager.SetLoadIDs(map[string]string{utils.CacheAttributeProfiles: utils.UUIDSha1Prefix()}); err != nil {
+ if err := apierV2.DataManager.SetLoadIDs(map[string]int64{utils.CacheAttributeProfiles: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
args := engine.ArgsGetCacheItem{
diff --git a/console/cache_versions.go b/console/load_ids.go
similarity index 93%
rename from console/cache_versions.go
rename to console/load_ids.go
index 94e250a32..9cb1bbe2b 100644
--- a/console/cache_versions.go
+++ b/console/load_ids.go
@@ -20,8 +20,8 @@ package console
func init() {
c := &CmdCacheVersions{
- name: "cache_versions",
- rpcMethod: "ApierV1.GetCacheVersions",
+ name: "get_load_ids",
+ rpcMethod: "ApierV1.GetLoadIDs",
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
@@ -55,6 +55,6 @@ func (self *CmdCacheVersions) PostprocessRpcParams() error {
}
func (self *CmdCacheVersions) RpcResult() interface{} {
- a := make(map[string]string, 0)
+ a := make(map[string]int64, 0)
return &a
}
diff --git a/console/load_times.go b/console/load_times.go
new file mode 100644
index 000000000..226ed5bf0
--- /dev/null
+++ b/console/load_times.go
@@ -0,0 +1,65 @@
+/*
+Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
+Copyright (C) ITsysCOM GmbH
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
+package console
+
+import (
+ v1 "github.com/cgrates/cgrates/apier/v1"
+)
+
+func init() {
+ c := &CmdLoadTimes{
+ name: "get_load_times",
+ rpcMethod: "ApierV1.GetLoadTimes",
+ rpcParams: &v1.LoadTimeArgs{},
+ }
+ commands[c.Name()] = c
+ c.CommandExecuter = &CommandExecuter{c}
+}
+
+// Commander implementation
+type CmdLoadTimes struct {
+ name string
+ rpcMethod string
+ rpcParams *v1.LoadTimeArgs
+ *CommandExecuter
+}
+
+func (self *CmdLoadTimes) Name() string {
+ return self.name
+}
+
+func (self *CmdLoadTimes) RpcMethod() string {
+ return self.rpcMethod
+}
+
+func (self *CmdLoadTimes) RpcParams(reset bool) interface{} {
+ if reset || self.rpcParams == nil {
+ self.rpcParams = &v1.LoadTimeArgs{}
+ }
+ return self.rpcParams
+}
+
+func (self *CmdLoadTimes) PostprocessRpcParams() error {
+ return nil
+}
+
+func (self *CmdLoadTimes) RpcResult() interface{} {
+ a := make(map[string]string, 0)
+ return &a
+}
diff --git a/engine/caches.go b/engine/caches.go
index 654651f1d..3b61361e1 100644
--- a/engine/caches.go
+++ b/engine/caches.go
@@ -470,8 +470,8 @@ func (chS *CacheS) V1FlushCache(args utils.AttrReloadCache, reply *string) (err
}
//populateCacheLoadIDs populate cacheLoadIDs based on attrs
-func populateCacheLoadIDs(loadIDs map[string]string, attrs utils.AttrReloadCache) (cacheLoadIDs map[string]string) {
- cacheLoadIDs = make(map[string]string)
+func populateCacheLoadIDs(loadIDs map[string]int64, attrs utils.AttrReloadCache) (cacheLoadIDs map[string]int64) {
+ cacheLoadIDs = make(map[string]int64)
//based on IDs of each type populate cacheLoadIDs and add into cache
if attrs.DestinationIDs == nil || len(*attrs.DestinationIDs) != 0 {
cacheLoadIDs[utils.CacheDestinations] = loadIDs[utils.CacheDestinations]
diff --git a/engine/datamanager.go b/engine/datamanager.go
index 7fd62f6b0..2ae12e80f 100644
--- a/engine/datamanager.go
+++ b/engine/datamanager.go
@@ -1363,7 +1363,7 @@ func (dm *DataManager) RemoveDispatcherHost(tenant, id string,
return
}
-func (dm *DataManager) GetItemLoadIDs(itemIDPrefix string, cacheWrite bool) (loadIDs map[string]string, err error) {
+func (dm *DataManager) GetItemLoadIDs(itemIDPrefix string, cacheWrite bool) (loadIDs map[string]int64, err error) {
loadIDs, err = dm.DataDB().GetItemLoadIDsDrv(itemIDPrefix)
if err != nil {
if err == utils.ErrNotFound && cacheWrite {
@@ -1383,6 +1383,6 @@ func (dm *DataManager) GetItemLoadIDs(itemIDPrefix string, cacheWrite bool) (loa
return
}
-func (dm *DataManager) SetLoadIDs(loadIDs map[string]string) error {
+func (dm *DataManager) SetLoadIDs(loadIDs map[string]int64) error {
return dm.DataDB().SetLoadIDsDrv(loadIDs)
}
diff --git a/engine/storage_interface.go b/engine/storage_interface.go
index 7c914b037..966c4141e 100644
--- a/engine/storage_interface.go
+++ b/engine/storage_interface.go
@@ -128,8 +128,8 @@ type DataDB interface {
GetDispatcherProfileDrv(string, string) (*DispatcherProfile, error)
SetDispatcherProfileDrv(*DispatcherProfile) error
RemoveDispatcherProfileDrv(string, string) error
- GetItemLoadIDsDrv(itemIDPrefix string) (loadIDs map[string]string, err error)
- SetLoadIDsDrv(loadIDs map[string]string) error
+ GetItemLoadIDsDrv(itemIDPrefix string) (loadIDs map[string]int64, err error)
+ SetLoadIDsDrv(loadIDs map[string]int64) error
GetDispatcherHostDrv(string, string) (*DispatcherHost, error)
SetDispatcherHostDrv(*DispatcherHost) error
RemoveDispatcherHostDrv(string, string) error
diff --git a/engine/storage_map_datadb.go b/engine/storage_map_datadb.go
index 1409ae762..6fb85b2c8 100644
--- a/engine/storage_map_datadb.go
+++ b/engine/storage_map_datadb.go
@@ -1423,7 +1423,7 @@ func (ms *MapStorage) GetStorageType() string {
return utils.MAPSTOR
}
-func (ms *MapStorage) GetItemLoadIDsDrv(itemIDPrefix string) (loadIDs map[string]string, err error) {
+func (ms *MapStorage) GetItemLoadIDsDrv(itemIDPrefix string) (loadIDs map[string]int64, err error) {
ms.mu.Lock()
defer ms.mu.Unlock()
values, ok := ms.dict[utils.LoadIDs]
@@ -1435,12 +1435,12 @@ func (ms *MapStorage) GetItemLoadIDsDrv(itemIDPrefix string) (loadIDs map[string
return nil, err
}
if itemIDPrefix != "" {
- return map[string]string{itemIDPrefix: loadIDs[itemIDPrefix]}, nil
+ return map[string]int64{itemIDPrefix: loadIDs[itemIDPrefix]}, nil
}
return loadIDs, nil
}
-func (ms *MapStorage) SetLoadIDsDrv(loadIDs map[string]string) (err error) {
+func (ms *MapStorage) SetLoadIDsDrv(loadIDs map[string]int64) (err error) {
var result []byte
result, err = ms.ms.Marshal(loadIDs)
if err != nil {
diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go
index 74eeb5a50..d71b70577 100644
--- a/engine/storage_mongo_datadb.go
+++ b/engine/storage_mongo_datadb.go
@@ -2191,7 +2191,7 @@ func (ms *MongoStorage) RemoveDispatcherHostDrv(tenant, id string) (err error) {
})
}
-func (ms *MongoStorage) GetItemLoadIDsDrv(itemIDPrefix string) (loadIDs map[string]string, err error) {
+func (ms *MongoStorage) GetItemLoadIDsDrv(itemIDPrefix string) (loadIDs map[string]int64, err error) {
fop := options.FindOne()
if itemIDPrefix != "" {
fop.SetProjection(bson.M{itemIDPrefix: 1, "_id": 0})
@@ -2216,7 +2216,7 @@ func (ms *MongoStorage) GetItemLoadIDsDrv(itemIDPrefix string) (loadIDs map[stri
return
}
-func (ms *MongoStorage) SetLoadIDsDrv(loadIDs map[string]string) (err error) {
+func (ms *MongoStorage) SetLoadIDsDrv(loadIDs map[string]int64) (err error) {
return ms.query(func(sctx mongo.SessionContext) (err error) {
_, err = ms.getCol(colLID).UpdateOne(sctx, bson.D{}, bson.M{"$set": loadIDs},
options.Update().SetUpsert(true),
diff --git a/engine/storage_redis.go b/engine/storage_redis.go
index 1046d8b00..8bd3795ae 100644
--- a/engine/storage_redis.go
+++ b/engine/storage_redis.go
@@ -1594,27 +1594,35 @@ func (rs *RedisStorage) GetStorageType() string {
return utils.REDIS
}
-func (rs *RedisStorage) GetItemLoadIDsDrv(itemIDPrefix string) (loadIDs map[string]string, err error) {
+func (rs *RedisStorage) GetItemLoadIDsDrv(itemIDPrefix string) (loadIDs map[string]int64, err error) {
if itemIDPrefix != "" {
- fldVal, err := rs.Cmd("HGET", utils.LoadIDs, itemIDPrefix).Str()
+ fldVal, err := rs.Cmd("HGET", utils.LoadIDs, itemIDPrefix).Int64()
if err != nil {
if err == redis.ErrRespNil {
err = utils.ErrNotFound
}
return nil, err
}
- return map[string]string{itemIDPrefix: fldVal}, nil
+ return map[string]int64{itemIDPrefix: fldVal}, nil
}
- loadIDs, err = rs.Cmd("HGETALL", utils.LoadIDs).Map()
+ mpLoadIDs, err := rs.Cmd("HGETALL", utils.LoadIDs).Map()
if err != nil {
return nil, err
}
+ loadIDs = make(map[string]int64)
+ for key, val := range mpLoadIDs {
+ intVal, err := strconv.ParseInt(val, 10, 64)
+ if err != nil {
+ return nil, err
+ }
+ loadIDs[key] = intVal
+ }
if len(loadIDs) == 0 {
return nil, utils.ErrNotFound
}
return
}
-func (rs *RedisStorage) SetLoadIDsDrv(loadIDs map[string]string) error {
+func (rs *RedisStorage) SetLoadIDsDrv(loadIDs map[string]int64) error {
return rs.Cmd("HMSET", utils.LoadIDs, loadIDs).Err
}
diff --git a/engine/tpreader.go b/engine/tpreader.go
index b34df6e24..ad71d8e3f 100644
--- a/engine/tpreader.go
+++ b/engine/tpreader.go
@@ -24,6 +24,7 @@ import (
"log"
"strconv"
"strings"
+ "time"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/structmatcher"
@@ -1413,8 +1414,8 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err
// }
}
//generate a loadID
- loadID := utils.UUIDSha1Prefix()
- loadIDs := make(map[string]string)
+ loadID := time.Now().UnixNano()
+ loadIDs := make(map[string]int64)
if verbose {
log.Print("Destinations:")
}
diff --git a/utils/coreutils.go b/utils/coreutils.go
index d9b39157e..bb4760e75 100644
--- a/utils/coreutils.go
+++ b/utils/coreutils.go
@@ -186,6 +186,7 @@ func ParseTimeDetectLayout(tmStr string, timezone string) (time.Time, error) {
astTimestamp := regexp.MustCompile(`^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d*[+,-]\d+$`)
unixTimestampRule := regexp.MustCompile(`^\d{10}$`)
unixTimestampMilisecondsRule := regexp.MustCompile(`^\d{13}$`)
+ unixTimestampNanosecondsRule := regexp.MustCompile(`^\d{19}$`)
oneLineTimestampRule := regexp.MustCompile(`^\d{14}$`)
oneSpaceTimestampRule := regexp.MustCompile(`^\d{2}\.\d{2}.\d{4}\s{1}\d{2}:\d{2}:\d{2}$`)
eamonTimestampRule := regexp.MustCompile(`^\d{2}/\d{2}/\d{4}\s{1}\d{2}:\d{2}:\d{2}$`)
@@ -237,6 +238,12 @@ func ParseTimeDetectLayout(tmStr string, timezone string) (time.Time, error) {
} else {
return time.Unix(0, tmstmp*int64(time.Millisecond)).In(loc), nil
}
+ case unixTimestampNanosecondsRule.MatchString(tmStr):
+ if tmstmp, err := strconv.ParseInt(tmStr, 10, 64); err != nil {
+ return nilTime, err
+ } else {
+ return time.Unix(0, tmstmp).In(loc), nil
+ }
case tmStr == "0" || len(tmStr) == 0: // Time probably missing from request
return nilTime, nil
case oneLineTimestampRule.MatchString(tmStr):