From ac96e53c434be6dff9ff64a9fac8dcec1f1e9219 Mon Sep 17 00:00:00 2001 From: arberkatellari Date: Fri, 28 Jun 2024 14:05:41 +0200 Subject: [PATCH] Update rpcclient revising error handling --- dispatchers/dispatchers.go | 4 ++-- dispatchers/libdispatcher.go | 8 ++++---- engine/connmanager.go | 4 ++-- go.mod | 8 +++----- go.sum | 8 ++++---- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/dispatchers/dispatchers.go b/dispatchers/dispatchers.go index ab8b5e7e2..2ecf43d19 100644 --- a/dispatchers/dispatchers.go +++ b/dispatchers/dispatchers.go @@ -225,7 +225,7 @@ func (dS *DispatcherService) Dispatch(ctx *context.Context, ev *utils.CGREvent, } if err = d.Dispatch(dS.dm, dS.fltrS, dS.cfg, ctx, dS.connMgr.GetDispInternalChan(), 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 } } @@ -262,7 +262,7 @@ func (dS *DispatcherService) Dispatch(ctx *context.Context, ev *utils.CGREvent, Tenant: dPrfl.Tenant, ProfileID: dPrfl.ID, }, - serviceMethod, args, reply); !rpcclient.IsNetworkError(err) { + serviceMethod, args, reply); !rpcclient.IsConnectionErr(err) && !rpcclient.IsServiceErr(err) { return } } diff --git a/dispatchers/libdispatcher.go b/dispatchers/libdispatcher.go index 86d74aa29..6880b9c64 100644 --- a/dispatchers/libdispatcher.go +++ b/dispatchers/libdispatcher.go @@ -241,7 +241,7 @@ func (sd *singleResultDispatcher) Dispatch(dm *engine.DataManager, flts *engine. if err = callDHwithID(ctx, tnt, hostID, routeID, dRh, dm, cfg, iPRCCh, 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 { @@ -332,7 +332,7 @@ func (ld *loadDispatcher) Dispatch(dm *engine.DataManager, flts *engine.FilterS, lM.decrementLoad(ctx, 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 @@ -360,7 +360,7 @@ func (ld *loadDispatcher) Dispatch(dm *engine.DataManager, flts *engine.FilterS, lM.decrementLoad(ctx, 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 { @@ -478,7 +478,7 @@ func callDH(ctx *context.Context, GroupIDs: []string{utils.ConcatenatedKey(utils.CacheDispatcherProfiles, dR.Tenant, dR.ProfileID)}, } if err = engine.Cache.SetWithReplicate(ctx, argsCache); err != nil { - if !rpcclient.IsNetworkError(err) { + if !rpcclient.IsConnectionErr(err) && !rpcclient.IsServiceErr(err) { return } // did not dispatch properly, fail-back to standard dispatching diff --git a/engine/connmanager.go b/engine/connmanager.go index 173834d4b..787838460 100644 --- a/engine/connmanager.go +++ b/engine/connmanager.go @@ -158,7 +158,7 @@ func (cM *ConnManager) Call(ctx *context.Context, connIDs []string, if conn, err = cM.getConn(ctx, connID); err != nil { continue } - if err = conn.Call(ctx, method, arg, reply); !rpcclient.IsNetworkError(err) { + if err = conn.Call(ctx, method, arg, reply); !rpcclient.IsConnectionErr(err) && !rpcclient.IsServiceErr(err) { return } } @@ -198,7 +198,7 @@ func (cM *ConnManager) CallWithConnIDs(connIDs []string, ctx *context.Context, s if conn, err = cM.getConnWithConfig(ctx, connID, newCfg, nil, false); err != nil { continue } - if err = conn.Call(ctx, method, arg, reply); !rpcclient.IsNetworkError(err) { + if err = conn.Call(ctx, method, arg, reply); !rpcclient.IsConnectionErr(err) && !rpcclient.IsServiceErr(err) { return } } diff --git a/go.mod b/go.mod index 7c53c5bd5..f16b82649 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/cgrates/cgrates -go 1.22 - -toolchain go1.22.0 +go 1.22.4 // replace github.com/cgrates/radigo => ../radigo @@ -21,7 +19,7 @@ require ( github.com/cgrates/kamevapi v0.0.0-20240307160311-26273f03eedf github.com/cgrates/ltcache v0.0.0-20210405185848-da943e80c1ab github.com/cgrates/radigo v0.0.0-20210902121842-ea2f9a730627 - github.com/cgrates/rpcclient v0.0.0-20220922181803-b3ddc74ad65a + github.com/cgrates/rpcclient v0.0.0-20240628101047-cb29aae6b006 github.com/cgrates/sipingo v1.0.1-0.20200514112313-699ebc1cdb8e github.com/creack/pty v1.1.20 github.com/dgrijalva/jwt-go v3.2.0+incompatible @@ -74,7 +72,7 @@ require ( github.com/blevesearch/zap/v13 v13.0.6 // indirect github.com/blevesearch/zap/v14 v14.0.5 // indirect github.com/blevesearch/zap/v15 v15.0.3 // indirect - github.com/cenkalti/hub v1.0.1 // indirect + github.com/cenkalti/hub v1.0.2 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/couchbase/ghistogram v0.1.0 // indirect github.com/couchbase/moss v0.1.0 // indirect diff --git a/go.sum b/go.sum index d85bd7270..22a8161e7 100644 --- a/go.sum +++ b/go.sum @@ -40,10 +40,10 @@ github.com/blevesearch/zap/v14 v14.0.5 h1:NdcT+81Nvmp2zL+NhwSvGSLh7xNgGL8QRVZ67n github.com/blevesearch/zap/v14 v14.0.5/go.mod h1:bWe8S7tRrSBTIaZ6cLRbgNH4TUDaC9LZSpRGs85AsGY= github.com/blevesearch/zap/v15 v15.0.3 h1:Ylj8Oe+mo0P25tr9iLPp33lN6d4qcztGjaIsP51UxaY= github.com/blevesearch/zap/v15 v15.0.3/go.mod h1:iuwQrImsh1WjWJ0Ue2kBqY83a0rFtJTqfa9fp1rbVVU= -github.com/cenk/hub v1.0.1 h1:RBwXNOF4a8KjD8BJ08XqN8KbrqaGiQLDrgvUGJSHuPA= github.com/cenk/hub v1.0.1/go.mod h1:rJM1LNAW0ppT8FMMuPK6c2NP/R2nH/UthtuRySSaf6Y= -github.com/cenkalti/hub v1.0.1 h1:UMtjc6dHSaOQTO15SVA50MBIR9zQwvsukQupDrkIRtg= github.com/cenkalti/hub v1.0.1/go.mod h1:tcYwtS3a2d9NO/0xDXVJWx3IedurUjYCqFCmpi0lpHs= +github.com/cenkalti/hub v1.0.2 h1:Nqv9TNaA9boeO2wQFW8o87BY3zKthtnzXmWGmJqhAV8= +github.com/cenkalti/hub v1.0.2/go.mod h1:8LAFAZcCasb83vfxatMUnZHRoQcffho2ELpHb+kaTJU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -63,8 +63,8 @@ github.com/cgrates/ltcache v0.0.0-20210405185848-da943e80c1ab h1:dKdAUwrij6vYwew github.com/cgrates/ltcache v0.0.0-20210405185848-da943e80c1ab/go.mod h1:9oSG/6gUoab/vKm/eQ3QcX6KeTR0wRw88N33iCnC/k4= github.com/cgrates/radigo v0.0.0-20210902121842-ea2f9a730627 h1:foxHlpQxYj15khhlpbj+EiIM/W9Gk0HP800NQ/DVPpU= github.com/cgrates/radigo v0.0.0-20210902121842-ea2f9a730627/go.mod h1:PizDxlLTjVQpyPU0ksWYfmM9UbYGu7q6at0nzuiZprI= -github.com/cgrates/rpcclient v0.0.0-20220922181803-b3ddc74ad65a h1:eZKp/pqv46latOHmyeMOHpAukERoG76qyzx2l74l+1I= -github.com/cgrates/rpcclient v0.0.0-20220922181803-b3ddc74ad65a/go.mod h1:+Ed0GFdz/rsSY/trWo+k0NFtAi3VP1l3CngZcRSErdw= +github.com/cgrates/rpcclient v0.0.0-20240628101047-cb29aae6b006 h1:HxmDpmCesrwbi+ag/4+PDRhuSy0gpemMRQ19fAWmDTE= +github.com/cgrates/rpcclient v0.0.0-20240628101047-cb29aae6b006/go.mod h1:WxTEIJvgI4c3eiPWW0WeAhHGd49Oi1Voe9lahotJiNo= github.com/cgrates/sipingo v1.0.1-0.20200514112313-699ebc1cdb8e h1:izFjZB83/XRXInc+gMIssUxdbleGsGIuGCPj2u7RQo0= github.com/cgrates/sipingo v1.0.1-0.20200514112313-699ebc1cdb8e/go.mod h1:0f2+3dq5Iiv3VlcuY83VPJ0QzqRlzDG1Cr8okogQE3g= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=