Update rpcclient revising error handling

This commit is contained in:
arberkatellari
2024-06-28 13:21:04 +02:00
committed by Dan Christian Bogos
parent dddd34f0db
commit b88602cdf3
6 changed files with 16 additions and 16 deletions

View File

@@ -269,7 +269,7 @@ func (dS *DispatcherService) Dispatch(ev *utils.CGREvent, subsys string,
ev.APIOpts[k] = v // dispatcher loop protection opts
}
if err = d.Dispatch(dS.dm, dS.fltrS, evNm, tnt, utils.EmptyString, dR,
serviceMethod, args, reply); !rpcclient.IsNetworkError(err) {
serviceMethod, args, reply); !rpcclient.IsConnectionErr(err) && !rpcclient.IsServiceErr(err) {
return // dispatch success or specific error coming from upstream
}
}
@@ -303,7 +303,7 @@ func (dS *DispatcherService) Dispatch(ev *utils.CGREvent, subsys string,
Tenant: dPrfl.Tenant,
ProfileID: dPrfl.ID,
},
serviceMethod, args, reply); !rpcclient.IsNetworkError(err) {
serviceMethod, args, reply); !rpcclient.IsConnectionErr(err) && !rpcclient.IsServiceErr(err) {
return
}
}

View File

@@ -231,7 +231,7 @@ func (sd *singleResultDispatcher) Dispatch(dm *engine.DataManager, flts *engine.
if err = callDHwithID(tnt, hostID, routeID, dRh, dm,
serviceMethod, args, reply); err == nil ||
(err != utils.ErrDSPHostNotFound &&
!rpcclient.IsNetworkError(err)) { // successful dispatch with normal errors
!rpcclient.IsConnectionErr(err) && !rpcclient.IsServiceErr(err)) { // successful dispatch with normal errors
return
}
if err != nil {
@@ -317,7 +317,7 @@ func (ld *loadDispatcher) Dispatch(dm *engine.DataManager, flts *engine.FilterS,
lM.decrementLoad(dR.HostID, ld.tntID) // call ended
if err == nil ||
(err != utils.ErrDSPHostNotFound &&
!rpcclient.IsNetworkError(err)) { // successful dispatch with normal errors
!rpcclient.IsConnectionErr(err) && !rpcclient.IsServiceErr(err)) { // successful dispatch with normal errors
return
}
// not found or network errors will continue with standard dispatching
@@ -345,7 +345,7 @@ func (ld *loadDispatcher) Dispatch(dm *engine.DataManager, flts *engine.FilterS,
lM.decrementLoad(hostID, ld.tntID) // call ended
if err == nil ||
(err != utils.ErrDSPHostNotFound &&
!rpcclient.IsNetworkError(err)) { // successful dispatch with normal errors
!rpcclient.IsConnectionErr(err) && !rpcclient.IsServiceErr(err)) { // successful dispatch with normal errors
return
}
if err != nil {
@@ -457,7 +457,7 @@ func callDH(dh *engine.DispatcherHost, routeID string, dR *DispatcherRoute,
GroupIDs: []string{utils.ConcatenatedKey(utils.CacheDispatcherProfiles, dR.Tenant, dR.ProfileID)},
}
if err = engine.Cache.SetWithReplicate(argsCache); err != nil {
if !rpcclient.IsNetworkError(err) {
if !rpcclient.IsConnectionErr(err) && !rpcclient.IsServiceErr(err) {
return
}
// did not dispatch properly, fail-back to standard dispatching

View File

@@ -195,7 +195,7 @@ func testDspResponderBroadcast(t *testing.T) {
time.Sleep(10 * time.Millisecond)
pingReply = ""
if err := dispEngine.RPC.Call(context.Background(), utils.ResponderPing, pingEv, &pingReply); err == nil ||
!rpcclient.IsNetworkError(err) {
!rpcclient.IsConnectionErr(err) && !rpcclient.IsServiceErr(err) {
t.Errorf("Expected error: %s received error: %v and reply %q", utils.ErrPartiallyExecuted.Error(), err, pingReply)
}
allEngine.startEngine(t)