Added all Responder Methods to DispatacherS.Fixes #2954

This commit is contained in:
Trial97
2021-05-19 10:20:36 +03:00
committed by Dan Christian Bogos
parent ca3befb5e5
commit b35f6c3485
5 changed files with 41 additions and 0 deletions

View File

@@ -109,6 +109,8 @@ type ResponderInterface interface {
RefundIncrements(arg *engine.CallDescriptorWithAPIOpts, reply *engine.Account) (err error)
RefundRounding(arg *engine.CallDescriptorWithAPIOpts, reply *float64) (err error)
GetMaxSessionTime(arg *engine.CallDescriptorWithAPIOpts, reply *time.Duration) (err error)
GetCostOnRatingPlans(arg *utils.GetCostOnRatingPlansArgs, reply *map[string]interface{}) (err error)
GetMaxSessionTimeOnAccounts(arg *utils.GetMaxSessionTimeOnAccountsArgs, reply *map[string]interface{}) (err error)
Shutdown(arg *utils.TenantWithAPIOpts, reply *string) (err error)
Ping(ign *utils.CGREvent, reply *string) error
}

View File

@@ -576,6 +576,13 @@ func (dS *DispatcherResponder) Shutdown(args *utils.TenantWithAPIOpts, reply *st
return dS.dS.ResponderShutdown(args, reply)
}
func (dS *DispatcherResponder) GetCostOnRatingPlans(arg *utils.GetCostOnRatingPlansArgs, reply *map[string]interface{}) (err error) {
return dS.dS.ResponderGetCostOnRatingPlans(arg, reply)
}
func (dS *DispatcherResponder) GetMaxSessionTimeOnAccounts(arg *utils.GetMaxSessionTimeOnAccountsArgs, reply *map[string]interface{}) (err error) {
return dS.dS.ResponderGetMaxSessionTimeOnAccounts(arg, reply)
}
// Ping used to detreminate if component is active
func (dS *DispatcherResponder) Ping(args *utils.CGREvent, reply *string) error {
return dS.dS.ResponderPing(args, reply)

View File

@@ -121,3 +121,31 @@ func (dS *DispatcherService) ResponderShutdown(args *utils.TenantWithAPIOpts,
APIOpts: args.APIOpts,
}, utils.MetaResponder, utils.ResponderShutdown, args, reply)
}
func (dS *DispatcherService) ResponderGetCostOnRatingPlans(arg *utils.GetCostOnRatingPlansArgs, reply *map[string]interface{}) (err error) {
tnt := utils.FirstNonEmpty(arg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
if err = dS.authorize(utils.ResponderShutdown, tnt,
utils.IfaceAsString(arg.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil {
return
}
}
return dS.Dispatch(&utils.CGREvent{
Tenant: tnt,
APIOpts: arg.APIOpts,
}, utils.MetaResponder, utils.ResponderGetCostOnRatingPlans, arg, reply)
}
func (dS *DispatcherService) ResponderGetMaxSessionTimeOnAccounts(arg *utils.GetMaxSessionTimeOnAccountsArgs, reply *map[string]interface{}) (err error) {
tnt := utils.FirstNonEmpty(arg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
if err = dS.authorize(utils.ResponderShutdown, tnt,
utils.IfaceAsString(arg.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil {
return
}
}
return dS.Dispatch(&utils.CGREvent{
Tenant: tnt,
APIOpts: arg.APIOpts,
}, utils.MetaResponder, utils.ResponderGetMaxSessionTimeOnAccounts, arg, reply)
}

View File

@@ -231,6 +231,7 @@ func (rpS *RouteService) costForEvent(ev *utils.CGREvent,
SetupTime: sTime,
Usage: usage,
AccountIDs: acntIDs,
APIOpts: ev.APIOpts,
}, &acntCost); err != nil {
return nil, err
}
@@ -265,6 +266,7 @@ func (rpS *RouteService) costForEvent(ev *utils.CGREvent,
SetupTime: sTime,
Usage: usage,
RatingPlanIDs: rpIDs,
APIOpts: ev.APIOpts,
}, &rpCost); err != nil {
return nil, err
}

View File

@@ -1397,6 +1397,7 @@ type GetCostOnRatingPlansArgs struct {
SetupTime time.Time
Usage time.Duration
RatingPlanIDs []string
APIOpts map[string]interface{}
}
type GetMaxSessionTimeOnAccountsArgs struct {
@@ -1406,6 +1407,7 @@ type GetMaxSessionTimeOnAccountsArgs struct {
SetupTime time.Time
Usage time.Duration
AccountIDs []string
APIOpts map[string]interface{}
}
type ArgExportToFolder struct {