mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-13 02:56:24 +05:00
Replacing CGREvent with *CGRevent when inherited for ThresholdService
This commit is contained in:
committed by
Dan Christian Bogos
parent
6ebdb4bbdf
commit
14ebcb3812
@@ -140,7 +140,7 @@ func testV1FIdxCaFromFolder(t *testing.T) {
|
||||
//ThresholdProfile
|
||||
func testV1FIdxCaProcessEventWithNotFound(t *testing.T) {
|
||||
tEv := &engine.ArgsProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event1",
|
||||
Event: map[string]interface{}{
|
||||
@@ -205,7 +205,7 @@ func testV1FIdxCaSetThresholdProfile(t *testing.T) {
|
||||
//matches TEST_PROFILE1
|
||||
tEv := &engine.ArgsProcessEvent{
|
||||
ThresholdIDs: []string{"TEST_PROFILE1"},
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event1",
|
||||
Event: map[string]interface{}{
|
||||
@@ -226,7 +226,7 @@ func testV1FIdxCaGetThresholdFromTP(t *testing.T) {
|
||||
//matches THD_ACNT_BALANCE_1
|
||||
tEv := &engine.ArgsProcessEvent{
|
||||
ThresholdIDs: []string{"THD_ACNT_BALANCE_1"},
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event1",
|
||||
Event: map[string]interface{}{
|
||||
@@ -295,7 +295,7 @@ func testV1FIdxCaUpdateThresholdProfile(t *testing.T) {
|
||||
}
|
||||
//make sure doesn't match the thresholdprofile after update
|
||||
tEv := &engine.ArgsProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event1",
|
||||
Event: map[string]interface{}{
|
||||
@@ -310,7 +310,7 @@ func testV1FIdxCaUpdateThresholdProfile(t *testing.T) {
|
||||
}
|
||||
//matches thresholdprofile after update
|
||||
tEv2 := &engine.ArgsProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event1",
|
||||
Event: map[string]interface{}{
|
||||
@@ -374,7 +374,7 @@ func testV1FIdxCaUpdateThresholdProfileFromTP(t *testing.T) {
|
||||
t.Error("Unexpected reply returned", result)
|
||||
}
|
||||
tEv := &engine.ArgsProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event1",
|
||||
Event: map[string]interface{}{
|
||||
@@ -387,7 +387,7 @@ func testV1FIdxCaUpdateThresholdProfileFromTP(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
tEv2 := &engine.ArgsProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event3",
|
||||
Event: map[string]interface{}{
|
||||
@@ -405,7 +405,7 @@ func testV1FIdxCaUpdateThresholdProfileFromTP(t *testing.T) {
|
||||
func testV1FIdxCaRemoveThresholdProfile(t *testing.T) {
|
||||
var resp string
|
||||
tEv := &engine.ArgsProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event8",
|
||||
Event: map[string]interface{}{
|
||||
@@ -420,7 +420,7 @@ func testV1FIdxCaRemoveThresholdProfile(t *testing.T) {
|
||||
}
|
||||
|
||||
tEv2 := &engine.ArgsProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "event9",
|
||||
Event: map[string]interface{}{
|
||||
|
||||
@@ -247,53 +247,53 @@ func testV1TSGetThresholds(t *testing.T) {
|
||||
func testV1TSProcessEvent(t *testing.T) {
|
||||
var ids []string
|
||||
eIDs := []string{}
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, tEvs[0], &ids); err == nil ||
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, &tEvs[0], &ids); err == nil ||
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
eIDs = []string{"THD_ACNT_BALANCE_1"}
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, tEvs[1], &ids); err != nil {
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, &tEvs[1], &ids); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(ids, eIDs) {
|
||||
t.Errorf("Expecting ids: %s, received: %s", eIDs, ids)
|
||||
}
|
||||
eIDs = []string{"THD_STATS_1"}
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, tEvs[2], &ids); err != nil {
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, &tEvs[2], &ids); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(ids, eIDs) {
|
||||
t.Errorf("Expecting ids: %s, received: %s", eIDs, ids)
|
||||
}
|
||||
eIDs = []string{"THD_STATS_2", "THD_STATS_1"}
|
||||
eIDs2 := []string{"THD_STATS_1", "THD_STATS_2"}
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, tEvs[3], &ids); err != nil {
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, &tEvs[3], &ids); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(ids, eIDs) && !reflect.DeepEqual(ids, eIDs2) {
|
||||
t.Errorf("Expecting ids: %s, received: %s", eIDs, ids)
|
||||
}
|
||||
eIDs = []string{"THD_STATS_3"}
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, tEvs[4], &ids); err != nil {
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, &tEvs[4], &ids); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(ids, eIDs) {
|
||||
t.Errorf("Expecting ids: %s, received: %s", eIDs, ids)
|
||||
}
|
||||
eIDs = []string{"THD_RES_1"}
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, tEvs[5], &ids); err != nil {
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, &tEvs[5], &ids); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(ids, eIDs) {
|
||||
t.Errorf("Expecting ids: %s, received: %s", eIDs, ids)
|
||||
}
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, tEvs[6], &ids); err != nil {
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, &tEvs[6], &ids); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(ids, eIDs) {
|
||||
t.Errorf("Expecting ids: %s, received: %s", eIDs, ids)
|
||||
}
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, tEvs[7], &ids); err != nil {
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, &tEvs[7], &ids); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(ids, eIDs) {
|
||||
t.Errorf("Expecting ids: %s, received: %s", eIDs, ids)
|
||||
}
|
||||
eIDs = []string{"THD_CDRS_1"}
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, tEvs[8], &ids); err != nil {
|
||||
if err := tSv1Rpc.Call(utils.ThresholdSv1ProcessEvent, &tEvs[8], &ids); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(ids, eIDs) {
|
||||
t.Errorf("Expecting ids: %s, received: %s", eIDs, ids)
|
||||
|
||||
@@ -57,11 +57,15 @@ func (dS *DispatcherService) ThresholdSv1GetThresholdsForEvent(args *engine.Args
|
||||
return
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&args.CGREvent, utils.MetaThresholds, routeID,
|
||||
=======
|
||||
return dS.Dispatch(args.CGREvent, utils.MetaThresholds, args.RouteID,
|
||||
>>>>>>> Replacing CGREvent with *CGRevent when inherited for ThresholdService
|
||||
utils.ThresholdSv1GetThresholdsForEvent, args, t)
|
||||
}
|
||||
|
||||
@@ -77,11 +81,15 @@ func (dS *DispatcherService) ThresholdSv1ProcessEvent(args *engine.ArgsProcessEv
|
||||
return
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&args.CGREvent, utils.MetaThresholds, routeID,
|
||||
=======
|
||||
return dS.Dispatch(args.CGREvent, utils.MetaThresholds, args.RouteID,
|
||||
>>>>>>> Replacing CGREvent with *CGRevent when inherited for ThresholdService
|
||||
utils.ThresholdSv1ProcessEvent, args, tIDs)
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ func testDspThProcessEventFailover(t *testing.T) {
|
||||
eIDs := []string{"THD_ACNT_1001"}
|
||||
nowTime := time.Now()
|
||||
args := &engine.ArgsProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Time: &nowTime,
|
||||
@@ -139,7 +139,7 @@ func testDspThTestAuthKey(t *testing.T) {
|
||||
var ids []string
|
||||
nowTime := time.Now()
|
||||
args := &engine.ArgsProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Time: &nowTime,
|
||||
@@ -167,7 +167,7 @@ func testDspThTestAuthKey2(t *testing.T) {
|
||||
eIDs := []string{"THD_ACNT_1002"}
|
||||
nowTime := time.Now()
|
||||
args := &engine.ArgsProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Time: &nowTime,
|
||||
|
||||
@@ -535,7 +535,7 @@ func (ub *Account) debitCreditBalance(cd *CallDescriptor, count bool, dryRun boo
|
||||
//send default balance to thresholdS to be processed
|
||||
acntTnt := utils.NewTenantID(ub.ID)
|
||||
thEv := &ArgsProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: acntTnt.Tenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
@@ -1106,7 +1106,7 @@ func (acnt *Account) Publish() {
|
||||
if thresholdS != nil {
|
||||
var tIDs []string
|
||||
if err := thresholdS.Call(utils.ThresholdSv1ProcessEvent,
|
||||
&ArgsProcessEvent{CGREvent: cgrEv}, &tIDs); err != nil &&
|
||||
&ArgsProcessEvent{CGREvent: &cgrEv}, &tIDs); err != nil &&
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<AccountS> error: %s processing account event %+v with ThresholdS.", err.Error(), cgrEv))
|
||||
|
||||
@@ -715,7 +715,7 @@ func (b *Balance) Publish() {
|
||||
}
|
||||
if thresholdS != nil {
|
||||
var tIDs []string
|
||||
if err := thresholdS.Call(utils.ThresholdSv1ProcessEvent, &ArgsProcessEvent{CGREvent: cgrEv}, &tIDs); err != nil &&
|
||||
if err := thresholdS.Call(utils.ThresholdSv1ProcessEvent, &ArgsProcessEvent{CGREvent: &cgrEv}, &tIDs); err != nil &&
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<AccountS> error: %s processing balance event %+v with ThresholdS.",
|
||||
@@ -807,7 +807,7 @@ func (bc Balances) SaveDirtyBalances(acc *Account) {
|
||||
}
|
||||
acntTnt := utils.NewTenantID(b.account.ID)
|
||||
thEv := &ArgsProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: acntTnt.Tenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
@@ -838,7 +838,7 @@ func (bc Balances) SaveDirtyBalances(acc *Account) {
|
||||
for _, acnt := range savedAccounts {
|
||||
acntTnt := utils.NewTenantID(acnt.ID)
|
||||
thEv := &ArgsProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: acntTnt.Tenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
|
||||
@@ -348,7 +348,7 @@ func (cdrS *CDRServer) attrSProcessEvent(cgrEv *utils.CGREventWithArgDispatcher)
|
||||
// thdSProcessEvent will send the event to ThresholdS if the connection is configured
|
||||
func (cdrS *CDRServer) thdSProcessEvent(cgrEv *utils.CGREventWithArgDispatcher) {
|
||||
var tIDs []string
|
||||
thArgs := &ArgsProcessEvent{CGREvent: *(cgrEv.CGREvent)}
|
||||
thArgs := &ArgsProcessEvent{CGREvent: cgrEv.CGREvent}
|
||||
if cgrEv.ArgDispatcher != nil {
|
||||
thArgs.ArgDispatcher = cgrEv.ArgDispatcher
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ func (rS *ResourceService) processThresholds(r *Resource, argDispatcher *utils.A
|
||||
thIDs = r.rPrf.ThresholdIDs
|
||||
}
|
||||
thEv := &ArgsProcessEvent{ThresholdIDs: thIDs,
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: r.Tenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
|
||||
@@ -276,7 +276,7 @@ func (sS *StatService) processEvent(args *StatsArgsProcessEvent) (statQueueIDs [
|
||||
}
|
||||
thEv := &ArgsProcessEvent{
|
||||
ThresholdIDs: thIDs,
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: sq.Tenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
|
||||
@@ -278,7 +278,7 @@ func (tS *ThresholdService) matchingThresholdsForEvent(args *ArgsProcessEvent) (
|
||||
|
||||
type ArgsProcessEvent struct {
|
||||
ThresholdIDs []string
|
||||
utils.CGREvent
|
||||
*utils.CGREvent
|
||||
*utils.ArgDispatcher
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ func (tS *ThresholdService) processEvent(args *ArgsProcessEvent) (thresholdsIDs
|
||||
func (tS *ThresholdService) V1ProcessEvent(args *ArgsProcessEvent, reply *[]string) (err error) {
|
||||
if missing := utils.MissingStructFields(args, []string{"Tenant", "ID"}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
} else if args.CGREvent.Event == nil {
|
||||
} else if args.CGREvent == nil || args.CGREvent.Event == nil {
|
||||
return utils.NewErrMandatoryIeMissing("Event")
|
||||
}
|
||||
if ids, err := tS.processEvent(args); err != nil {
|
||||
@@ -357,7 +357,7 @@ func (tS *ThresholdService) V1ProcessEvent(args *ArgsProcessEvent, reply *[]stri
|
||||
func (tS *ThresholdService) V1GetThresholdsForEvent(args *ArgsProcessEvent, reply *Thresholds) (err error) {
|
||||
if missing := utils.MissingStructFields(args, []string{"Tenant", "ID"}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
} else if args.CGREvent.Event == nil {
|
||||
} else if args.CGREvent == nil || args.CGREvent.Event == nil {
|
||||
return utils.NewErrMandatoryIeMissing("Event")
|
||||
}
|
||||
var ts Thresholds
|
||||
|
||||
@@ -91,7 +91,7 @@ var (
|
||||
}
|
||||
argsGetThresholds = []*ArgsProcessEvent{
|
||||
{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Ev1",
|
||||
Event: map[string]interface{}{
|
||||
@@ -101,7 +101,7 @@ var (
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Ev1",
|
||||
Event: map[string]interface{}{
|
||||
@@ -111,7 +111,7 @@ var (
|
||||
},
|
||||
},
|
||||
{
|
||||
CGREvent: utils.CGREvent{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Ev1",
|
||||
Event: map[string]interface{}{
|
||||
|
||||
@@ -1857,7 +1857,7 @@ func (sS *SessionS) BiRPCv1AuthorizeEvent(clnt rpcclient.RpcClientConnection,
|
||||
}
|
||||
var tIDs []string
|
||||
thEv := &engine.ArgsProcessEvent{
|
||||
CGREvent: args.CGREvent,
|
||||
CGREvent: &args.CGREvent,
|
||||
ArgDispatcher: args.ArgDispatcher,
|
||||
}
|
||||
if err := sS.thdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &tIDs); err != nil &&
|
||||
@@ -2105,7 +2105,7 @@ func (sS *SessionS) BiRPCv1InitiateSession(clnt rpcclient.RpcClientConnection,
|
||||
}
|
||||
var tIDs []string
|
||||
thEv := &engine.ArgsProcessEvent{
|
||||
CGREvent: args.CGREvent,
|
||||
CGREvent: &args.CGREvent,
|
||||
ArgDispatcher: args.ArgDispatcher,
|
||||
}
|
||||
if err := sS.thdS.Call(utils.ThresholdSv1ProcessEvent,
|
||||
@@ -2431,7 +2431,7 @@ func (sS *SessionS) BiRPCv1TerminateSession(clnt rpcclient.RpcClientConnection,
|
||||
}
|
||||
var tIDs []string
|
||||
thEv := &engine.ArgsProcessEvent{
|
||||
CGREvent: args.CGREvent,
|
||||
CGREvent: &args.CGREvent,
|
||||
ArgDispatcher: args.ArgDispatcher,
|
||||
}
|
||||
if err := sS.thdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &tIDs); err != nil &&
|
||||
@@ -2741,7 +2741,7 @@ func (sS *SessionS) BiRPCv1ProcessEvent(clnt rpcclient.RpcClientConnection,
|
||||
}
|
||||
var tIDs []string
|
||||
thEv := &engine.ArgsProcessEvent{
|
||||
CGREvent: args.CGREvent,
|
||||
CGREvent: &args.CGREvent,
|
||||
ArgDispatcher: args.ArgDispatcher,
|
||||
}
|
||||
if err := sS.thdS.Call(utils.ThresholdSv1ProcessEvent,
|
||||
|
||||
Reference in New Issue
Block a user