Updated rpcclient library

This commit is contained in:
Trial97
2020-10-01 17:25:36 +03:00
committed by Dan Christian Bogos
parent 14336e29f5
commit f353f12b68
6 changed files with 49 additions and 33 deletions

View File

@@ -128,11 +128,11 @@ func testDspChcLoadAfterFolder(t *testing.T) {
t.Error(reply)
}
expStats[utils.CacheActions].Items = 2
expStats[utils.CacheAttributeProfiles].Items = 10
expStats[utils.CacheAttributeProfiles].Items = 11
expStats[utils.CacheChargerProfiles].Items = 2
expStats[utils.CacheFilters].Items = 7
expStats[utils.CacheRatingPlans].Items = 6
expStats[utils.CacheRatingProfiles].Items = 5
expStats[utils.CacheRatingProfiles].Items = 7
expStats[utils.CacheResourceProfiles].Items = 1
expStats[utils.CacheResources].Items = 1
expStats[utils.CacheReverseDestinations].Items = 4
@@ -153,7 +153,7 @@ func testDspChcLoadAfterFolder(t *testing.T) {
expStats[utils.CacheResourceFilterIndexes].Groups = 1
expStats[utils.CacheChargerFilterIndexes].Items = 1
expStats[utils.CacheChargerFilterIndexes].Groups = 1
expStats[utils.CacheAttributeFilterIndexes].Items = 10
expStats[utils.CacheAttributeFilterIndexes].Items = 11
expStats[utils.CacheAttributeFilterIndexes].Groups = 4
expStats[utils.CacheReverseFilterIndexes].Items = 8
expStats[utils.CacheReverseFilterIndexes].Groups = 6

View File

@@ -109,6 +109,14 @@ func (at *ActionTiming) Clone() (cln *ActionTiming) {
return
}
// getDayOrEndOfMonth returns the day if is a valid date relative to t1 month
func getDayOrEndOfMonth(day int, t1 time.Time) int {
if lastDay := utils.GetEndOfMonth(t1).Day(); lastDay <= day { // clamp the day to last day of month in order to corectly compare the time
day = lastDay
}
return day
}
func (at *ActionTiming) GetNextStartTime(t1 time.Time) (t time.Time) {
if !at.stCache.IsZero() {
return at.stCache
@@ -129,35 +137,17 @@ func (at *ActionTiming) GetNextStartTime(t1 time.Time) (t time.Time) {
}
at.stCache = cronexpr.MustParse(i.Timing.CronString()).Next(t1)
if i.Timing.ID == utils.MetaMonthlyEstimated {
day := at.Timing.Timing.MonthDays[0]
if lastDay := utils.GetEndOfMonth(t1).Day(); lastDay <= day { // clamp the day to last day of month in order to corectly compare the time
day = lastDay
}
// substract a month from at.stCache only if we skip 2 months
// or we skip a month because mentioned MonthDay is after the last day of the current month
if at.stCache.Month() == t1.Month()+2 ||
(utils.GetEndOfMonth(t1).Day() < at.Timing.Timing.MonthDays[0] &&
at.stCache.Month() == t1.Month()+1) {
lastDay := utils.GetEndOfMonth(at.stCache).Day()
at.stCache = at.stCache.AddDate(0, 0, -lastDay)
}
/*clnRITiming := at.Timing.Timing.Clone()
mnt := t1.Month()
day := clnRITiming.MonthDays[0]
if lastDay := utils.GetEndOfMonth(t1).Day(); lastDay <= day { // clamp the day to last day of month in order to corectly compare the time
day = lastDay
}
if t1.Day() > day || // in case we missed the day
(t1.Day() == day && // did not miss the day but need to check if we missed the start time
t1.Sub(t1.Truncate(24*time.Hour)) >=
at.stCache.Sub(at.stCache.Truncate(24*time.Hour))) {
// the StartTime is before t1 so try nextMonth
if mnt++; mnt == 13 { // special case in case of december next month is January
mnt = 1
// only change the time if the new one is after t1
if tmp := at.stCache.AddDate(0, 0, -lastDay); tmp.After(t1) {
at.stCache = tmp
}
}
for at.stCache.Month() > mnt {
clnRITiming.MonthDays[0]--
at.stCache = cronexpr.MustParse(clnRITiming.CronString()).Next(t1)
}*/
}
return at.stCache
}

View File

@@ -3430,3 +3430,33 @@ func (dm *DataManager) GetAPIBan(ip string, apiKeys []string, single, cacheRead,
}
return
}
// CheckFilters returns the filters IDs are valid
func (dm *DataManager) CheckFilters(tenant string, ids []string) (ok bool) {
for _, id := range ids {
if strings.HasPrefix(id, utils.Meta) {
if _, err := NewFilterFromInline(tenant, id); err != nil {
return
}
} else if dm == nil {
return
} else if x, has := Cache.Get(utils.CacheFilters, utils.ConcatenatedKey(tenant, id)); has && x == nil {
return
} else if has, err := dm.DataDB().HasDataDrv(utils.FilterPrefix, id, tenant); err != nil || !has {
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaFilters]; err == utils.ErrNotFound && itm.Remote {
var fltr *Filter
err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil, utils.ReplicatorSv1GetFilter,
&utils.TenantIDWithOpts{
TenantID: &utils.TenantID{Tenant: tenant, ID: id},
Opts: map[string]interface{}{
utils.OptsAPIKey: itm.APIKey,
utils.OptsRouteID: itm.RouteID,
}}, &fltr)
}
if err != nil {
return
}
}
}
return true
}

2
go.mod
View File

@@ -24,7 +24,7 @@ require (
github.com/cgrates/kamevapi v0.0.0-20191001125829-7dbc3ad58817
github.com/cgrates/ltcache v0.0.0-20181016092649-92fb7fa77cca
github.com/cgrates/radigo v0.0.0-20200324152710-35e651804ad1
github.com/cgrates/rpcclient v0.0.0-20200528120144-984f478f0a69
github.com/cgrates/rpcclient v0.0.0-20201001135303-bd71813702b8
github.com/cgrates/sipingo v1.0.1-0.20200514112313-699ebc1cdb8e
github.com/creack/pty v1.1.11
github.com/dgrijalva/jwt-go v3.2.0+incompatible

6
go.sum
View File

@@ -64,8 +64,6 @@ github.com/cenkalti/rpc2 v0.0.0-20200203073230-5ce2854ce0fd/go.mod h1:v2npkhrXyk
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cgrates/aringo v0.0.0-20191121125609-d85002bd1667 h1:eNku7bwLtSTpn6FQUUTnqohuGWC8jij1KNqDZ2QkGRE=
github.com/cgrates/aringo v0.0.0-20191121125609-d85002bd1667/go.mod h1:l0xi5JUVqxL4P7RZ9YitbSCiOtjMY2j7JBOCJIysRWk=
github.com/cgrates/baningo v0.0.0-20200925101338-ccea0136bbb1 h1:MM3w9bIb8DpJ+px6BQ0CkEmn0CLneAS4VHmmdZnje14=
github.com/cgrates/baningo v0.0.0-20200925101338-ccea0136bbb1/go.mod h1:3SwVROaS1Iml5lqEhj0gRhDRtmbBgypZpKcEkVTSleU=
github.com/cgrates/baningo v0.0.0-20200925111414-e65b237006c9 h1:WwluddhgQoHkB72AzbC781qtB2xJLt+B9Rc2+NYy0Ts=
github.com/cgrates/baningo v0.0.0-20200925111414-e65b237006c9/go.mod h1:3SwVROaS1Iml5lqEhj0gRhDRtmbBgypZpKcEkVTSleU=
github.com/cgrates/cron v0.0.0-20200906113840-dd008627fdca h1:neuTTEjWsM+WXRyJ+MF1OzsNc+e7DGjrNZKIEIr8x4A=
@@ -78,8 +76,8 @@ github.com/cgrates/ltcache v0.0.0-20181016092649-92fb7fa77cca h1:Ejj4m0Ccl8dMMVn
github.com/cgrates/ltcache v0.0.0-20181016092649-92fb7fa77cca/go.mod h1:q7c996DUu8OrJRnewVSQzM+y/bRcxZAHoo+zCD8bFBo=
github.com/cgrates/radigo v0.0.0-20200324152710-35e651804ad1 h1:QvA6Nbwq9kTd7hsvu1xo5kwia68cLwnp0sYCq1u40TU=
github.com/cgrates/radigo v0.0.0-20200324152710-35e651804ad1/go.mod h1:HZbsg3Y+xw4lsfCqX9rzj429wrg0XOug6pFT3B6VHZY=
github.com/cgrates/rpcclient v0.0.0-20200528120144-984f478f0a69 h1:4vKQbGGdle7SyHMXm9obE2DgSDnsf5ayFSS0cqO16vI=
github.com/cgrates/rpcclient v0.0.0-20200528120144-984f478f0a69/go.mod h1:xXLqAKVvcdWeDYwHJYwDgAI3ZOg5LZYxzb72kLjsLZU=
github.com/cgrates/rpcclient v0.0.0-20201001135303-bd71813702b8 h1:g/jQWGMnriTP+HOggROpkcLyEIPsiAp/BdQq8fd0y/E=
github.com/cgrates/rpcclient v0.0.0-20201001135303-bd71813702b8/go.mod h1:xXLqAKVvcdWeDYwHJYwDgAI3ZOg5LZYxzb72kLjsLZU=
github.com/cgrates/sipingo v1.0.1-0.20200514112313-699ebc1cdb8e h1:izFjZB83/XRXInc+gMIssUxdbleGsGIuGCPj2u7RQo0=
github.com/cgrates/sipingo v1.0.1-0.20200514112313-699ebc1cdb8e/go.mod h1:0f2+3dq5Iiv3VlcuY83VPJ0QzqRlzDG1Cr8okogQE3g=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=

View File

@@ -3759,7 +3759,6 @@ func (sS *SessionS) processThreshold(cgrEv *utils.CGREvent, thIDs []string, opts
thEv.ThresholdIDs = thIDs
}
//initialize the returned variable
tIDs = make([]string, 0)
err = sS.connMgr.Call(sS.cgrCfg.SessionSCfg().ThreshSConns, nil, utils.ThresholdSv1ProcessEvent, thEv, &tIDs)
return
}
@@ -3781,7 +3780,6 @@ func (sS *SessionS) processStats(cgrEv *utils.CGREvent, stsIDs []string, opts ma
statArgs.StatIDs = stsIDs
}
//initialize the returned variable
sIDs = make([]string, 0)
err = sS.connMgr.Call(sS.cgrCfg.SessionSCfg().StatSConns, nil, utils.StatSv1ProcessEvent, statArgs, &sIDs)
return
}