action triggers expiration and activation times

This commit is contained in:
Radu Ioan Fericean
2016-02-04 18:46:06 +02:00
parent c0dd58c438
commit b2a39ed867
18 changed files with 266 additions and 75 deletions

View File

@@ -36,6 +36,8 @@ type ActionTrigger struct {
ThresholdValue float64
Recurrent bool // reset excuted flag each run
MinSleep time.Duration // Minimum duration between two executions in case of recurrent triggers
ExpirationDate time.Time
ActivationDate time.Time
BalanceId string
BalanceType string // *monetary/*voice etc
BalanceDirections utils.StringMap // filter for balance
@@ -188,6 +190,14 @@ func (at *ActionTrigger) Equals(oat *ActionTrigger) bool {
return at.ID == oat.ID && at.UniqueID == oat.UniqueID
}
func (at *ActionTrigger) IsActive(t time.Time) bool {
return at.ActivationDate.IsZero() || t.After(at.ActivationDate)
}
func (at *ActionTrigger) IsExpired(t time.Time) bool {
return !at.ExpirationDate.IsZero() && t.After(at.ExpirationDate)
}
// Structure to store actions according to weight
type ActionTriggers []*ActionTrigger