From aef49598a550f74df7b324a867bbb4e2db43588b Mon Sep 17 00:00:00 2001 From: DanB Date: Thu, 28 Sep 2017 13:07:36 +0200 Subject: [PATCH] Threshold structure --- data/tariffplans/tutorial/Stats.csv | 2 +- data/tariffplans/tutorial/Thresholds.csv | 2 +- engine/thresholds.go | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/data/tariffplans/tutorial/Stats.csv b/data/tariffplans/tutorial/Stats.csv index db4cccbad..0c0b64a49 100755 --- a/data/tariffplans/tutorial/Stats.csv +++ b/data/tariffplans/tutorial/Stats.csv @@ -1,2 +1,2 @@ -#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],QueueLength[6],TTL[7],Metrics[8],Blocker[9],Stored[10],Weight[11],Thresholds[12] +#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],QueueLength[6],TTL[7],Metrics[8],Blocker[9],Stored[10],Weight[11],MinItems[12],Thresholds[13] cgrates.org,STATS_1,*string,Account,1001;1002,2014-07-29T15:00:00Z,100,1s,*asr;*acc;*tcc;*acd;*tcd,true,true,20,THRESH1;THRESH2 diff --git a/data/tariffplans/tutorial/Thresholds.csv b/data/tariffplans/tutorial/Thresholds.csv index d6916857f..0f7b77e1c 100644 --- a/data/tariffplans/tutorial/Thresholds.csv +++ b/data/tariffplans/tutorial/Thresholds.csv @@ -1,2 +1,2 @@ -#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],MinItems[6],Recurrent[7],MinSleep[8],Blocker[9],Stored[10],Weight[11],ActionIDs[12] +#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],Recurrent[6],MinSleep[7],Blocker[8],Stored[9],Weight[10],ActionIDs[11] Threshold1,*string,Account,1001;1002,2014-07-29T15:00:00Z,,1.2,10,true,1s,true,true,10,THRESH1;THRESH2 \ No newline at end of file diff --git a/engine/thresholds.go b/engine/thresholds.go index ee6c737d5..0d3b773c7 100644 --- a/engine/thresholds.go +++ b/engine/thresholds.go @@ -41,3 +41,22 @@ type ThresholdProfile struct { func (tp *ThresholdProfile) TenantID() string { return utils.ConcatenatedKey(tp.Tenant, tp.ID) } + +// ThresholdEvent is an event processed by ThresholdService +type ThresholdEvent struct { + Tenant string + ID string + Fields map[string]interface{} +} + +// Threshold is the unit matched by filters +// It's WakeupTime is stored on demand +type Threshold struct { + Tenant string + ID string + LastExecuted time.Time + WakeupTime time.Time // prevent threshold to run too early + + tPrfl *ThresholdProfile + dirty *bool // needs save +}