mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-12 18:46:24 +05:00
Add *reset_stat_queue and *reset_threshold action in ActionS
This commit is contained in:
committed by
Dan Christian Bogos
parent
216426da33
commit
ce91a404b2
@@ -108,7 +108,11 @@ func newActioner(cfg *config.CGRConfig, fltrS *engine.FilterS, dm *engine.DataMa
|
||||
case utils.MetaHTTPPost:
|
||||
return &actHTTPPost{aCfg: aCfg}, nil
|
||||
case utils.MetaExport:
|
||||
return &actExport{config: cfg, connMgr: connMgr, aCfg: aCfg, tnt: tnt}, err
|
||||
return &actExport{config: cfg, connMgr: connMgr, aCfg: aCfg, tnt: tnt}, nil
|
||||
case utils.MetaResetStatQueue:
|
||||
return &actResetStat{config: cfg, connMgr: connMgr, aCfg: aCfg}, nil
|
||||
case utils.MetaResetThreshold:
|
||||
return &actResetThreshold{config: cfg, connMgr: connMgr, aCfg: aCfg}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported action type: <%s>", aCfg.Type)
|
||||
|
||||
@@ -287,3 +291,53 @@ func (aL *actExport) execute(ctx context.Context, data utils.MapStorage) (err er
|
||||
return aL.connMgr.Call(aL.config.ActionSCfg().EEsConns, nil,
|
||||
utils.EeSv1ProcessEvent, args, &rply)
|
||||
}
|
||||
|
||||
type actResetStat struct {
|
||||
config *config.CGRConfig
|
||||
connMgr *engine.ConnManager
|
||||
aCfg *engine.APAction
|
||||
}
|
||||
|
||||
func (aL *actResetStat) id() string {
|
||||
return aL.aCfg.ID
|
||||
}
|
||||
|
||||
func (aL *actResetStat) cfg() *engine.APAction {
|
||||
return aL.aCfg
|
||||
}
|
||||
|
||||
// execute implements actioner interface
|
||||
func (aL *actResetStat) execute(ctx context.Context, data utils.MapStorage) (err error) {
|
||||
var tenID string
|
||||
if tenID, err = aL.cfg().Value.ParseDataProvider(data); err != nil {
|
||||
return
|
||||
}
|
||||
var rply string
|
||||
return aL.connMgr.Call(aL.config.ActionSCfg().StatSConns, nil,
|
||||
utils.StatSv1ResetStatQueue, &utils.TenantIDWithOpts{TenantID: utils.NewTenantID(tenID)}, &rply)
|
||||
}
|
||||
|
||||
type actResetThreshold struct {
|
||||
config *config.CGRConfig
|
||||
connMgr *engine.ConnManager
|
||||
aCfg *engine.APAction
|
||||
}
|
||||
|
||||
func (aL *actResetThreshold) id() string {
|
||||
return aL.aCfg.ID
|
||||
}
|
||||
|
||||
func (aL *actResetThreshold) cfg() *engine.APAction {
|
||||
return aL.aCfg
|
||||
}
|
||||
|
||||
// execute implements actioner interface
|
||||
func (aL *actResetThreshold) execute(ctx context.Context, data utils.MapStorage) (err error) {
|
||||
var tenID string
|
||||
if tenID, err = aL.cfg().Value.ParseDataProvider(data); err != nil {
|
||||
return
|
||||
}
|
||||
var rply string
|
||||
return aL.connMgr.Call(aL.config.ActionSCfg().ThresholdSConns, nil,
|
||||
utils.ThresholdSv1ResetThreshold, &utils.TenantIDWithOpts{TenantID: utils.NewTenantID(tenID)}, &rply)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user