update rpcclient library (#4413)

for more details: https://github.com/cgrates/rpcclient/pull/37
This commit is contained in:
ionutboangiu
2024-08-13 19:10:38 +03:00
committed by Dan Christian Bogos
parent abba61723a
commit 6474c1076f
6 changed files with 15 additions and 21 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.IsConnectionErr(err) && !rpcclient.IsServiceErr(err) {
serviceMethod, args, reply); !rpcclient.ShouldFailover(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.IsConnectionErr(err) && !rpcclient.IsServiceErr(err) {
serviceMethod, args, reply); !rpcclient.ShouldFailover(err) {
return
}
}

View File

@@ -229,9 +229,8 @@ 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.IsConnectionErr(err) && !rpcclient.IsServiceErr(err)) { // successful dispatch with normal errors
serviceMethod, args, reply); err != utils.ErrDSPHostNotFound &&
!rpcclient.ShouldFailover(err) { // successful dispatch with normal errors
return
}
if err != nil {
@@ -314,10 +313,8 @@ func (ld *loadDispatcher) Dispatch(dm *engine.DataManager, flts *engine.FilterS,
lM.incrementLoad(dR.HostID, ld.tntID)
err = callDHwithID(tnt, dR.HostID, routeID, dR, dm,
serviceMethod, args, reply)
lM.decrementLoad(dR.HostID, ld.tntID) // call ended
if err == nil ||
(err != utils.ErrDSPHostNotFound &&
!rpcclient.IsConnectionErr(err) && !rpcclient.IsServiceErr(err)) { // successful dispatch with normal errors
lM.decrementLoad(dR.HostID, ld.tntID) // call ended
if err != utils.ErrDSPHostNotFound && !rpcclient.ShouldFailover(err) { // successful dispatch with normal errors
return
}
// not found or network errors will continue with standard dispatching
@@ -342,10 +339,8 @@ func (ld *loadDispatcher) Dispatch(dm *engine.DataManager, flts *engine.FilterS,
lM.incrementLoad(hostID, ld.tntID)
err = callDHwithID(tnt, hostID, routeID, dRh, dm,
serviceMethod, args, reply)
lM.decrementLoad(hostID, ld.tntID) // call ended
if err == nil ||
(err != utils.ErrDSPHostNotFound &&
!rpcclient.IsConnectionErr(err) && !rpcclient.IsServiceErr(err)) { // successful dispatch with normal errors
lM.decrementLoad(hostID, ld.tntID) // call ended
if err != utils.ErrDSPHostNotFound && !rpcclient.ShouldFailover(err) { // successful dispatch with normal errors
return
}
if err != nil {
@@ -457,7 +452,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.IsConnectionErr(err) && !rpcclient.IsServiceErr(err) {
if !rpcclient.ShouldFailover(err) {
return
}
// did not dispatch properly, fail-back to standard dispatching

View File

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

View File

@@ -183,7 +183,7 @@ func (cM *ConnManager) Call(ctx *context.Context, connIDs []string, method strin
if err != nil {
continue
}
if err = conn.Call(ctx, method, arg, reply); !rpcclient.IsConnectionErr(err) && !rpcclient.IsServiceErr(err) {
if err = conn.Call(ctx, method, arg, reply); !rpcclient.ShouldFailover(err) {
return
}
}
@@ -222,7 +222,7 @@ func (cM *ConnManager) CallWithConnIDs(connIDs []string, subsHostIDs utils.Strin
if conn, err = cM.getConnWithConfig(context.TODO(), connID, newCfg, nil); err != nil {
continue
}
if err = conn.Call(context.TODO(), method, arg, reply); !!rpcclient.IsConnectionErr(err) && !rpcclient.IsServiceErr(err) {
if err = conn.Call(context.TODO(), method, arg, reply); !rpcclient.ShouldFailover(err) {
return
}
}

2
go.mod
View File

@@ -25,7 +25,7 @@ require (
github.com/cgrates/kamevapi v0.0.0-20240307160311-26273f03eedf
github.com/cgrates/ltcache v0.0.0-20240411152156-e673692056db
github.com/cgrates/radigo v0.0.0-20240123163129-491c899df727
github.com/cgrates/rpcclient v0.0.0-20240628101047-cb29aae6b006
github.com/cgrates/rpcclient v0.0.0-20240813140209-439c79036e27
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

4
go.sum
View File

@@ -80,8 +80,8 @@ github.com/cgrates/ltcache v0.0.0-20240411152156-e673692056db h1:JRgzMS5kJ1Wxave
github.com/cgrates/ltcache v0.0.0-20240411152156-e673692056db/go.mod h1:jVYq943GCWxhXXxi/1NthN9ATeyFUSbwJRbN/bb+ADQ=
github.com/cgrates/radigo v0.0.0-20240123163129-491c899df727 h1:rhYHlbfEPDNreekd1ZtUYi/NbFm5cEl8twQZ3c/0nYU=
github.com/cgrates/radigo v0.0.0-20240123163129-491c899df727/go.mod h1:W/5LcOm9jaz0NfIFT09bxjddEai8DTSfw9poqDqtAX4=
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/rpcclient v0.0.0-20240813140209-439c79036e27 h1:wnaRqfM3+c/fjH0gtP6jJANcKipE9LfnYr9UysYg/+o=
github.com/cgrates/rpcclient v0.0.0-20240813140209-439c79036e27/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=