This commit is contained in:
TeoV
2018-08-22 05:50:54 -04:00
committed by Dan Christian Bogos
parent 69637784c5
commit 75eb2183e1
2 changed files with 31 additions and 3 deletions

View File

@@ -82,6 +82,7 @@ const (
TopUpZeroNegative = "*topup_zero_negative"
SetExpiry = "*set_expiry"
MetaPublishAccount = "*publish_account"
MetaPublishBalance = "*publish_balance"
)
func (a *Action) Clone() *Action {
@@ -121,6 +122,7 @@ func getActionFunc(typ string) (actionTypeFunc, bool) {
TopUpZeroNegative: topupZeroNegativeAction,
SetExpiry: setExpiryAction,
MetaPublishAccount: publishAccount,
MetaPublishBalance: publishBalance,
}
f, exists := actionFuncMap[typ]
return f, exists
@@ -878,6 +880,23 @@ func publishAccount(acnt *Account, sq *CDRStatsQueueTriggered,
return nil
}
// publishAccount will publish the account as well as each balance received to ThresholdS
func publishBalance(acnt *Account, sq *CDRStatsQueueTriggered,
a *Action, acs Actions) error {
if acnt == nil {
return errors.New("nil account")
}
for bType := range acnt.BalanceMap {
for _, b := range acnt.BalanceMap[bType] {
if b.account == nil {
b.account = acnt
}
b.Publish()
}
}
return nil
}
// Structure to store actions according to weight
type Actions []*Action