Update rpcclient library to latest version

Replace all instances of rpcclient.ClientConnector with birpc.ClientConnector.

Pass context, maxReconnectInterval, delayFunc and birpcClient to rpcclient
constructors.

Remove redundant time.Duration conversions (e.g. time.Duration(1*time.Second)
now becomes time.Second.

Add context where needed (context.Background() for tests, context.TODO()
for places where it should be passed from somewhere else).

Implement that functionality of the SessionSv1.Sleep call, in sessions/sessions
instead of apier/v1.

Make changes in utils/server.go (replacing the old rpc2 library with github.com/cgrates/birpc).

Change the way we register birpc methods for sessions in services, using a helper function
defined in engine/libengine.go.
This commit is contained in:
ionutboangiu
2023-03-30 11:27:15 -04:00
committed by Dan Christian Bogos
parent 0560fa63f8
commit cb7ea790de
94 changed files with 767 additions and 687 deletions

View File

@@ -25,6 +25,7 @@ import (
"strings"
"sync"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
@@ -49,7 +50,7 @@ type ServiceManager struct {
subsystems map[string]Service
}
func (srvMngr *ServiceManager) Call(serviceMethod string, args interface{}, reply interface{}) error {
func (srvMngr *ServiceManager) Call(ctx *context.Context, serviceMethod string, args interface{}, reply interface{}) error {
parts := strings.Split(serviceMethod, ".")
if len(parts) != 2 {
return rpcclient.ErrUnsupporteServiceMethod