Threshold structure

This commit is contained in:
DanB
2017-09-28 13:07:36 +02:00
parent b81914629e
commit aef49598a5
3 changed files with 21 additions and 2 deletions

View File

@@ -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
1 #Tenant[0] #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] Id[1] FilterType[2] FilterFieldName[3] FilterFieldValues[4] ActivationInterval[5] QueueLength[6] TTL[7] Metrics[8] Blocker[9] Stored[10] Weight[11] Thresholds[12]
2 cgrates.org 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 STATS_1 *string Account 1001;1002 2014-07-29T15:00:00Z 100 1s *asr;*acc;*tcc;*acd;*tcd true true 20 THRESH1;THRESH2

View File

@@ -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
1 #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]
2 Threshold1,*string,Account,1001;1002,2014-07-29T15:00:00Z,,1.2,10,true,1s,true,true,10,THRESH1;THRESH2 Threshold1,*string,Account,1001;1002,2014-07-29T15:00:00Z,,1.2,10,true,1s,true,true,10,THRESH1;THRESH2

View File

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