diff --git a/agents/astagent.go b/agents/astagent.go
index ca1aba353..2f5570089 100644
--- a/agents/astagent.go
+++ b/agents/astagent.go
@@ -369,11 +369,6 @@ func (sma *AsteriskAgent) handleChannelDestroyed(ev *SMAsteriskEvent) {
}
}
-// Call implements birpc.ClientConnector interface
-func (sma *AsteriskAgent) Call(ctx *context.Context, serviceMethod string, args any, reply any) error {
- return utils.RPCCall(sma, serviceMethod, args, reply)
-}
-
// V1DisconnectSession is internal method to disconnect session in asterisk
func (sma *AsteriskAgent) V1DisconnectSession(ctx *context.Context, cgrEv utils.CGREvent, reply *string) error {
channelID := engine.NewMapEvent(cgrEv.Event).GetStringIgnoreErrors(utils.OriginID)
diff --git a/agents/astagent_test.go b/agents/astagent_test.go
index 86e9ffa25..f17971bc7 100644
--- a/agents/astagent_test.go
+++ b/agents/astagent_test.go
@@ -18,7 +18,6 @@ along with this program. If not, see
package agents
import (
- "errors"
"testing"
"github.com/cgrates/birpc"
@@ -120,45 +119,3 @@ func TestAsteriskAgentV1AlterSession(t *testing.T) {
t.Errorf("Expected error: %v, got: %v", utils.ErrNotImplemented, err)
}
}
-
-func TestAsteriskAgentCall(t *testing.T) {
- sma := &AsteriskAgent{}
- ctx := context.Background()
-
- tests := []struct {
- name string
- serviceMethod string
- args any
- reply any
- expectedError error
- }{
- {
- name: "Valid service method",
- serviceMethod: "testMethod",
- args: nil,
- reply: nil,
- expectedError: nil,
- },
- {
- name: "Invalid service method",
- serviceMethod: "invalidMethod",
- args: nil,
- reply: nil,
- expectedError: errors.New("unexpected method"),
- },
- }
-
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- err := sma.Call(ctx, tt.serviceMethod, tt.args, tt.reply)
-
- if err == nil && tt.expectedError == nil {
- t.Errorf("expected no error, but got: %v", err)
- } else if err == nil && tt.expectedError != nil {
- t.Errorf("expected error: %v, but got no error", tt.expectedError)
- } else if err == nil && tt.expectedError != nil {
- t.Errorf("expected error: %v, but got: %v", tt.expectedError, err)
- }
- })
- }
-}
diff --git a/agents/diamagent.go b/agents/diamagent.go
index cd74b849b..b7a185ab6 100644
--- a/agents/diamagent.go
+++ b/agents/diamagent.go
@@ -325,11 +325,6 @@ func (da *DiameterAgent) handleMessage(c diam.Conn, m *diam.Message) {
writeOnConn(c, a)
}
-// Call implements birpc.ClientConnector interface
-func (da *DiameterAgent) Call(ctx *context.Context, serviceMethod string, args any, reply any) error {
- return utils.RPCCall(da, serviceMethod, args, reply)
-}
-
// V1DisconnectSession is part of the sessions.BiRPClient
func (da *DiameterAgent) V1DisconnectSession(ctx *context.Context, cgrEv utils.CGREvent, reply *string) (err error) {
ssID, has := cgrEv.Event[utils.OriginID]
diff --git a/agents/diamagent_test.go b/agents/diamagent_test.go
index 1c220a183..c4f80f3c5 100644
--- a/agents/diamagent_test.go
+++ b/agents/diamagent_test.go
@@ -19,6 +19,7 @@ package agents
import (
"reflect"
+ "strings"
"testing"
"time"
@@ -449,8 +450,14 @@ func TestProcessRequest(t *testing.T) {
filterS: filters,
connMgr: connMgr,
}
- ctx := context.WithClient(context.Background(), da)
- pr, err := processRequest(ctx, reqProcessor, agReq, utils.DiameterAgent, connMgr, da.cgrCfg.DiameterAgentCfg().SessionSConns, da.filterS)
+ srv, err := birpc.NewServiceWithMethodsRename(da, utils.AgentV1, true, func(oldFn string) (newFn string) {
+ return strings.TrimPrefix(oldFn, "V1")
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ da.ctx = context.WithClient(context.TODO(), srv)
+ pr, err := processRequest(da.ctx, reqProcessor, agReq, utils.DiameterAgent, connMgr, da.cgrCfg.DiameterAgentCfg().SessionSConns, da.filterS)
if err != nil {
t.Error(err)
} else if !pr {
@@ -467,7 +474,7 @@ func TestProcessRequest(t *testing.T) {
reqProcessor.Tenant, config.CgrConfig().GeneralCfg().DefaultTenant,
config.CgrConfig().GeneralCfg().DefaultTimezone, filters, nil)
- pr, err = processRequest(ctx, reqProcessor, agReq, utils.DiameterAgent, connMgr, da.cgrCfg.DiameterAgentCfg().SessionSConns, da.filterS)
+ pr, err = processRequest(da.ctx, reqProcessor, agReq, utils.DiameterAgent, connMgr, da.cgrCfg.DiameterAgentCfg().SessionSConns, da.filterS)
if err != nil {
t.Error(err)
} else if !pr {
@@ -484,7 +491,7 @@ func TestProcessRequest(t *testing.T) {
reqProcessor.Tenant, config.CgrConfig().GeneralCfg().DefaultTenant,
config.CgrConfig().GeneralCfg().DefaultTimezone, filters, nil)
- pr, err = processRequest(ctx, reqProcessor, agReq, utils.DiameterAgent, connMgr, da.cgrCfg.DiameterAgentCfg().SessionSConns, da.filterS)
+ pr, err = processRequest(da.ctx, reqProcessor, agReq, utils.DiameterAgent, connMgr, da.cgrCfg.DiameterAgentCfg().SessionSConns, da.filterS)
if err != nil {
t.Error(err)
} else if !pr {
@@ -507,7 +514,7 @@ func TestProcessRequest(t *testing.T) {
reqProcessor.Tenant, config.CgrConfig().GeneralCfg().DefaultTenant,
config.CgrConfig().GeneralCfg().DefaultTimezone, filters, nil)
- pr, err = processRequest(ctx, reqProcessor, agReq, utils.DiameterAgent, connMgr, da.cgrCfg.DiameterAgentCfg().SessionSConns, da.filterS)
+ pr, err = processRequest(da.ctx, reqProcessor, agReq, utils.DiameterAgent, connMgr, da.cgrCfg.DiameterAgentCfg().SessionSConns, da.filterS)
if err != nil {
t.Error(err)
} else if !pr {
@@ -524,7 +531,7 @@ func TestProcessRequest(t *testing.T) {
reqProcessor.Tenant, config.CgrConfig().GeneralCfg().DefaultTenant,
config.CgrConfig().GeneralCfg().DefaultTimezone, filters, nil)
- pr, err = processRequest(ctx, reqProcessor, agReq, utils.DiameterAgent, connMgr, da.cgrCfg.DiameterAgentCfg().SessionSConns, da.filterS)
+ pr, err = processRequest(da.ctx, reqProcessor, agReq, utils.DiameterAgent, connMgr, da.cgrCfg.DiameterAgentCfg().SessionSConns, da.filterS)
if err != nil {
t.Error(err)
} else if !pr {
@@ -573,20 +580,3 @@ func TestV1DisconnectPeer(t *testing.T) {
t.Errorf("Expected ErrNotFound, got: %v", err)
}
}
-
-func TestDiamanAgentCall(t *testing.T) {
- agent := &DiameterAgent{}
- ctx := context.Background()
- serviceMethod := "serviceTest"
- args := struct{ TestArg string }{"TestValue"}
- var reply struct{ TestReply string }
-
- err := agent.Call(ctx, serviceMethod, args, &reply)
- if err == nil {
- t.Errorf("Unexpected error: %v", err)
- }
- expectedReply := ""
- if reply.TestReply != expectedReply {
- t.Errorf("Expected reply %s, got %s", expectedReply, reply.TestReply)
- }
-}
diff --git a/agents/fsagent.go b/agents/fsagent.go
index a85a8066e..97456dab4 100644
--- a/agents/fsagent.go
+++ b/agents/fsagent.go
@@ -390,11 +390,6 @@ func (fsa *FSsessions) Shutdown() (err error) {
return
}
-// Call implements birpc.ClientConnector interface
-func (fsa *FSsessions) Call(ctx *context.Context, serviceMethod string, args any, reply any) error {
- return utils.RPCCall(fsa, serviceMethod, args, reply)
-}
-
// V1DisconnectSession internal method to disconnect session in FreeSWITCH
func (fsa *FSsessions) V1DisconnectSession(ctx *context.Context, cgrEv utils.CGREvent, reply *string) (err error) {
ev := engine.NewMapEvent(cgrEv.Event)
diff --git a/agents/fsagent_test.go b/agents/fsagent_test.go
index 8010f5928..ba622c7b9 100644
--- a/agents/fsagent_test.go
+++ b/agents/fsagent_test.go
@@ -208,18 +208,6 @@ func TestFsAgentShutdown(t *testing.T) {
}
}
-func TestFsAgentCall(t *testing.T) {
- ctx := context.Background()
- serviceMethod := "Method"
- args := "Args"
- reply := new(interface{})
- fsa := &FSsessions{}
- err := fsa.Call(ctx, serviceMethod, args, reply)
- if err == nil {
- t.Errorf("UNSUPPORTED_SERVICE_METHOD, got %v", err)
- }
-}
-
func TestFsAgentNewFSsessions(t *testing.T) {
fsAgentConfig := &config.FsAgentCfg{
EventSocketConns: []*config.FsConnCfg{
diff --git a/agents/kamagent.go b/agents/kamagent.go
index 83479ad4a..1e4d62ec2 100644
--- a/agents/kamagent.go
+++ b/agents/kamagent.go
@@ -116,11 +116,6 @@ func (self *KamailioAgent) Shutdown() (err error) {
return
}
-// birpc.ClientConnector interface
-func (ka *KamailioAgent) Call(serviceMethod string, args any, reply any) error {
- return utils.RPCCall(ka, serviceMethod, args, reply)
-}
-
// onCgrAuth is called when new event of type CGR_AUTH_REQUEST is coming
func (ka *KamailioAgent) onCgrAuth(evData []byte, connIdx int) {
if connIdx >= len(ka.conns) { // protection against index out of range panic
diff --git a/agents/libdns_test.go b/agents/libdns_test.go
index de9d0c428..39338594e 100644
--- a/agents/libdns_test.go
+++ b/agents/libdns_test.go
@@ -25,12 +25,7 @@ import (
"strings"
"testing"
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/sessions"
"github.com/cgrates/cgrates/utils"
- "github.com/cgrates/kamevapi"
"github.com/miekg/dns"
)
@@ -397,36 +392,6 @@ func TestLibdnsUpdateDnsQuestions(t *testing.T) {
}
-func TestKamailioAgentCall(t *testing.T) {
- cfg := &config.KamAgentCfg{}
- connMgr := &engine.ConnManager{}
- conns := []*kamevapi.KamEvapi{}
- activeSessionIDs := make(chan []*sessions.SessionID)
- ctx := &context.Context{}
- ka := &KamailioAgent{
- cfg: cfg,
- connMgr: connMgr,
- timezone: "UTC",
- conns: conns,
- activeSessionIDs: activeSessionIDs,
- ctx: ctx,
- }
- args := struct {
- Message string
- }{
- Message: "message",
- }
- var reply string
- err := ka.Call("UNSUPPORTED_SERVICE_METHOD", args, &reply)
- if err == nil {
- t.Errorf("UNSUPPORTED_SERVICE_METHOD %v", err)
- }
- expectedReply := ""
- if reply != expectedReply {
- t.Errorf("Expected reply %q, got %q", expectedReply, reply)
- }
-}
-
func TestLibDnsUpdateDnsOption(t *testing.T) {
ednsOptions := []dns.EDNS0{
diff --git a/apier/v1/analyzer.go b/apier/v1/analyzer.go
index 7b4ab17d5..e948867c9 100644
--- a/apier/v1/analyzer.go
+++ b/apier/v1/analyzer.go
@@ -21,7 +21,6 @@ package v1
import (
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/analyzers"
- "github.com/cgrates/cgrates/utils"
)
// NewAnalyzerSv1 initializes AnalyzerSv1
@@ -34,18 +33,6 @@ type AnalyzerSv1 struct {
aS *analyzers.AnalyzerService
}
-// Call implements birpc.ClientConnector interface for internal RPC
-func (aSv1 *AnalyzerSv1) Call(ctx *context.Context, serviceMethod string,
- args any, reply any) error {
- return utils.APIerRPCCall(aSv1, serviceMethod, args, reply)
-}
-
-// Ping return pong if the service is active
-func (aSv1 *AnalyzerSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
-
// StringQuery returns a list of API that match the query
func (aSv1 *AnalyzerSv1) StringQuery(ctx *context.Context, search *analyzers.QueryArgs, reply *[]map[string]any) error {
return aSv1.aS.V1StringQuery(ctx, search, reply)
diff --git a/apier/v1/analyzer_test.go b/apier/v1/analyzer_test.go
index 41565b796..3c036bcd8 100644
--- a/apier/v1/analyzer_test.go
+++ b/apier/v1/analyzer_test.go
@@ -21,9 +21,7 @@ package v1
import (
"testing"
- "github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/analyzers"
- "github.com/cgrates/cgrates/utils"
)
func TestNewAnalyzerSv1(t *testing.T) {
@@ -37,59 +35,6 @@ func TestNewAnalyzerSv1(t *testing.T) {
}
}
-func TestAnalyzerSv1Call(t *testing.T) {
-
- aSv1 := &AnalyzerSv1{aS: &analyzers.AnalyzerService{}}
- ctx := context.Background()
- serviceMethod := "TestServiceMethod"
- args := "test args"
- var reply string
-
- err := aSv1.Call(ctx, serviceMethod, args, &reply)
-
- if err == nil {
- t.Errorf("expected no error, got %v", err)
- }
-
- if reply == "reply" {
- t.Errorf("expected reply 'reply', got '%v'", reply)
- }
-}
-
-func TestAnalyzerSv1Ping(t *testing.T) { //
-
- aSv1 := &AnalyzerSv1{}
- ctx := context.Background()
- var reply string
-
- err := aSv1.Ping(ctx, nil, &reply)
- if err != nil {
- t.Errorf("expected no error, got %v", err)
- }
-
- if reply != utils.Pong {
- t.Errorf("expected reply '%v', got '%v'", utils.Pong, reply)
- }
-}
-
-func TestAPIerSv1Call(t *testing.T) {
-
- apierSv1 := &APIerSv1{}
- ctx := context.Background()
- serviceMethod := "TestServiceMethod"
- args := "test args"
- var reply string
- err := apierSv1.Call(ctx, serviceMethod, args, &reply)
-
- if err == nil {
- t.Errorf("expected error, got %v", err)
- }
-
- if reply == "test reply" {
- t.Errorf("expected reply 'test reply', got '%v'", reply)
- }
-}
-
func TestVerifyFormat(t *testing.T) {
tests := []struct {
tStr string
diff --git a/apier/v1/api_interfaces.go b/apier/v1/api_interfaces.go
index 25de9b924..9cb1fbe0d 100644
--- a/apier/v1/api_interfaces.go
+++ b/apier/v1/api_interfaces.go
@@ -35,7 +35,6 @@ type ThresholdSv1Interface interface {
GetThresholdsForEvent(ctx *context.Context, args *utils.CGREvent, reply *engine.Thresholds) error
GetThreshold(ctx *context.Context, tntID *utils.TenantIDWithAPIOpts, t *engine.Threshold) error
ProcessEvent(ctx *context.Context, args *utils.CGREvent, tIDs *[]string) error
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
}
type StatSv1Interface interface {
@@ -44,7 +43,6 @@ type StatSv1Interface interface {
GetStatQueuesForEvent(ctx *context.Context, args *utils.CGREvent, reply *[]string) (err error)
GetQueueStringMetrics(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *map[string]string) (err error)
GetQueueFloatMetrics(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *map[string]float64) (err error)
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
}
type ResourceSv1Interface interface {
@@ -54,24 +52,20 @@ type ResourceSv1Interface interface {
ReleaseResources(ctx *context.Context, args *utils.CGREvent, reply *string) error
GetResource(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.Resource) error
GetResourceWithConfig(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.ResourceWithConfig) error
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
}
type RouteSv1Interface interface {
GetRoutes(ctx *context.Context, args *utils.CGREvent, reply *engine.SortedRoutesList) error
GetRouteProfilesForEvent(ctx *context.Context, args *utils.CGREvent, reply *[]*engine.RouteProfile) error
GetRoutesList(ctx *context.Context, args *utils.CGREvent, reply *[]string) error
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
}
type AttributeSv1Interface interface {
GetAttributeForEvent(ctx *context.Context, args *utils.CGREvent, reply *engine.AttributeProfile) (err error)
ProcessEvent(ctx *context.Context, args *utils.CGREvent, reply *engine.AttrSProcessEventReply) error
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
}
type ChargerSv1Interface interface {
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
GetChargersForEvent(ctx *context.Context, cgrEv *utils.CGREvent, reply *engine.ChargerProfiles) error
ProcessEvent(ctx *context.Context, args *utils.CGREvent, reply *[]*engine.ChrgSProcessEventReply) error
}
@@ -94,7 +88,6 @@ type SessionSv1Interface interface {
AlterSessions(ctx *context.Context, args utils.SessionFilterWithEvent, rply *string) error
GetPassiveSessions(ctx *context.Context, args *utils.SessionFilter, rply *[]*sessions.ExternalSession) error
GetPassiveSessionsCount(ctx *context.Context, args *utils.SessionFilter, rply *int) error
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
ReplicateSessions(ctx *context.Context, args *dispatchers.ArgsReplicateSessionsWithAPIOpts, rply *string) error
SetPassiveSession(ctx *context.Context, args *sessions.Session, reply *string) error
ActivateSessions(ctx *context.Context, args *utils.SessionIDsWithArgsDispatcher, reply *string) error
@@ -114,7 +107,6 @@ type ResponderInterface interface {
GetCostOnRatingPlans(ctx *context.Context, arg *utils.GetCostOnRatingPlansArgs, reply *map[string]any) (err error)
GetMaxSessionTimeOnAccounts(ctx *context.Context, arg *utils.GetMaxSessionTimeOnAccountsArgs, reply *map[string]any) (err error)
Shutdown(ctx *context.Context, arg *utils.TenantWithAPIOpts, reply *string) (err error)
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
}
type CacheSv1Interface interface {
@@ -133,18 +125,15 @@ type CacheSv1Interface interface {
LoadCache(ctx *context.Context, args *utils.AttrReloadCacheWithAPIOpts, reply *string) error
ReplicateSet(ctx *context.Context, args *utils.ArgCacheReplicateSet, reply *string) (err error)
ReplicateRemove(ctx *context.Context, args *utils.ArgCacheReplicateRemove, reply *string) (err error)
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
}
type GuardianSv1Interface interface {
RemoteLock(ctx *context.Context, attr *dispatchers.AttrRemoteLockWithAPIOpts, reply *string) (err error)
RemoteUnlock(ctx *context.Context, refID *dispatchers.AttrRemoteUnlockWithAPIOpts, reply *[]string) (err error)
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
}
type SchedulerSv1Interface interface {
Reload(ctx *context.Context, arg *utils.CGREvent, reply *string) error
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
ExecuteActions(ctx *context.Context, attr *utils.AttrsExecuteActions, reply *string) error
ExecuteActionPlans(ctx *context.Context, attr *utils.AttrsExecuteActionPlans, reply *string) error
}
@@ -157,19 +146,16 @@ type CDRsV1Interface interface {
StoreSessionCost(ctx *context.Context, attr *engine.AttrCDRSStoreSMCost, reply *string) error
GetCDRsCount(ctx *context.Context, args *utils.RPCCDRsFilterWithAPIOpts, reply *int64) error
GetCDRs(ctx *context.Context, args *utils.RPCCDRsFilterWithAPIOpts, reply *[]*engine.CDR) error
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
}
type ServiceManagerV1Interface interface {
StartService(ctx *context.Context, args *dispatchers.ArgStartServiceWithAPIOpts, reply *string) error
StopService(ctx *context.Context, args *dispatchers.ArgStartServiceWithAPIOpts, reply *string) error
ServiceStatus(ctx *context.Context, args *dispatchers.ArgStartServiceWithAPIOpts, reply *string) error
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
}
type RALsV1Interface interface {
GetRatingPlansCost(ctx *context.Context, arg *utils.RatingPlanCostArg, reply *dispatchers.RatingPlanCost) error
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
}
type ConfigSv1Interface interface {
@@ -182,12 +168,10 @@ type ConfigSv1Interface interface {
type CoreSv1Interface interface {
Status(ctx *context.Context, arg *utils.TenantWithAPIOpts, reply *map[string]any) error
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
Sleep(ctx *context.Context, arg *utils.DurationArgs, reply *string) error
}
type ReplicatorSv1Interface interface {
- Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error
GetAccount(ctx *context.Context, args *utils.StringWithAPIOpts, reply *engine.Account) error
GetDestination(ctx *context.Context, key *utils.StringWithAPIOpts, reply *engine.Destination) error
GetReverseDestination(ctx *context.Context, key *utils.StringWithAPIOpts, reply *[]string) error
diff --git a/apier/v1/apier.go b/apier/v1/apier.go
index 72dbb4b0e..b6f2baeb3 100644
--- a/apier/v1/apier.go
+++ b/apier/v1/apier.go
@@ -59,12 +59,6 @@ type APIerSv1 struct {
ResponderChan chan *engine.Responder
}
-// Call implements birpc.ClientConnector interface for internal RPC
-func (apierSv1 *APIerSv1) Call(ctx *context.Context, serviceMethod string,
- args any, reply any) error {
- return utils.APIerRPCCall(apierSv1, serviceMethod, args, reply)
-}
-
func (apierSv1 *APIerSv1) GetDestination(ctx *context.Context, dstId *string, reply *engine.Destination) error {
if dst, err := apierSv1.DataManager.GetDestination(*dstId, true, true, utils.NonTransactional); err != nil {
return utils.ErrNotFound
@@ -1573,12 +1567,6 @@ func (apierSv1 *APIerSv1) ListenAndServe(stopChan chan struct{}) {
}
}
-// Ping return pong if the service is active
-func (apierSv1 *APIerSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
-
// ExportToFolder export specific items (or all items if items is empty) from DataDB back to CSV
func (apierSv1 *APIerSv1) ExportToFolder(ctx *context.Context, arg *utils.ArgExportToFolder, reply *string) error {
// if items is empty we need to export all items
diff --git a/apier/v1/attributes.go b/apier/v1/attributes.go
index e047a7372..80d898187 100644
--- a/apier/v1/attributes.go
+++ b/apier/v1/attributes.go
@@ -168,12 +168,6 @@ type AttributeSv1 struct {
attrS *engine.AttributeService
}
-// Call implements birpc.ClientConnector interface for internal RPC
-func (alSv1 *AttributeSv1) Call(ctx *context.Context, serviceMethod string,
- args any, reply any) error {
- return utils.APIerRPCCall(alSv1, serviceMethod, args, reply)
-}
-
// GetAttributeForEvent returns matching AttributeProfile for Event
func (alSv1 *AttributeSv1) GetAttributeForEvent(ctx *context.Context, args *utils.CGREvent,
reply *engine.AttributeProfile) (err error) {
@@ -185,9 +179,3 @@ func (alSv1 *AttributeSv1) ProcessEvent(ctx *context.Context, args *utils.CGREve
reply *engine.AttrSProcessEventReply) error {
return alSv1.attrS.V1ProcessEvent(ctx, args, reply)
}
-
-// Ping return pong if the service is active
-func (alSv1 *AttributeSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
diff --git a/apier/v1/caches.go b/apier/v1/caches.go
index 5cab6d0c7..23f997525 100644
--- a/apier/v1/caches.go
+++ b/apier/v1/caches.go
@@ -123,12 +123,6 @@ func (chSv1 *CacheSv1) LoadCache(ctx *context.Context, args *utils.AttrReloadCac
return chSv1.cacheS.V1LoadCache(ctx, args, reply)
}
-// Ping used to determinate if component is active
-func (chSv1 *CacheSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
-
// ReplicateSet replicate an item
func (chSv1 *CacheSv1) ReplicateSet(ctx *context.Context, args *utils.ArgCacheReplicateSet, reply *string) (err error) {
return chSv1.cacheS.V1ReplicateSet(ctx, args, reply)
@@ -138,9 +132,3 @@ func (chSv1 *CacheSv1) ReplicateSet(ctx *context.Context, args *utils.ArgCacheRe
func (chSv1 *CacheSv1) ReplicateRemove(ctx *context.Context, args *utils.ArgCacheReplicateRemove, reply *string) (err error) {
return chSv1.cacheS.V1ReplicateRemove(ctx, args, reply)
}
-
-// Call implements birpc.ClientConnector interface for internal RPC
-func (chSv1 *CacheSv1) Call(ctx *context.Context, serviceMethod string,
- args any, reply any) error {
- return utils.APIerRPCCall(chSv1, serviceMethod, args, reply)
-}
diff --git a/apier/v1/caches_test.go b/apier/v1/caches_test.go
index 3260ab39b..e5422af2c 100644
--- a/apier/v1/caches_test.go
+++ b/apier/v1/caches_test.go
@@ -354,27 +354,6 @@ func TestCacheSv1RemoveGroup(t *testing.T) {
}
}
-func TestCacheSv1Ping(t *testing.T) {
- cache := &CacheSv1{}
- ctx := context.Background()
- ign := &utils.CGREvent{}
- var reply string
- err := cache.Ping(ctx, ign, &reply)
- if err != nil {
- t.Errorf("expected no error, got %v", err)
- }
- if reply != utils.Pong {
- t.Errorf("expected reply to be '%s', but got '%s'", utils.Pong, reply)
- }
- err = cache.Ping(nil, ign, &reply)
- if err != nil {
- t.Errorf("expected no error with nil context, got %v", err)
- }
- if reply != utils.Pong {
- t.Errorf("expected reply to be '%s' with nil context, but got '%s'", utils.Pong, reply)
- }
-}
-
func TestCacheSv1ReplicateSet(t *testing.T) {
cfg := config.NewDefaultCGRConfig()
data := engine.NewInternalDB(nil, nil, true, nil)
@@ -420,20 +399,3 @@ func TestCacheSv1ReplicateRemove(t *testing.T) {
t.Errorf("expected no error with nil context, got %v", err)
}
}
-
-func TestCacheSv1Call(t *testing.T) {
- cache := &CacheSv1{}
- ctx := context.Background()
- serviceMethod := "TestMethod"
- args := "TestArg"
- var reply string
- err := cache.Call(ctx, serviceMethod, args, &reply)
- err = cache.Call(ctx, serviceMethod, 123, &reply)
- if err == nil {
- t.Errorf("expected an error with invalid arguments, but got nil")
- }
- err = cache.Call(ctx, "UnknownMethod", args, &reply)
- if err == nil {
- t.Errorf("expected an error with unknown service method, but got nil")
- }
-}
diff --git a/apier/v1/cdrs.go b/apier/v1/cdrs.go
index 2756e7a99..6697e032a 100644
--- a/apier/v1/cdrs.go
+++ b/apier/v1/cdrs.go
@@ -127,8 +127,3 @@ func (cdrSv1 *CDRsV1) GetCDRsCount(ctx *context.Context, args *utils.RPCCDRsFilt
func (cdrSv1 *CDRsV1) GetCDRs(ctx *context.Context, args *utils.RPCCDRsFilterWithAPIOpts, reply *[]*engine.CDR) error {
return cdrSv1.CDRs.V1GetCDRs(ctx, *args, reply)
}
-
-func (cdrSv1 *CDRsV1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
diff --git a/apier/v1/chargers.go b/apier/v1/chargers.go
index e7ff5af91..62a739edb 100644
--- a/apier/v1/chargers.go
+++ b/apier/v1/chargers.go
@@ -140,17 +140,6 @@ type ChargerSv1 struct {
cS *engine.ChargerService
}
-// Call implements birpc.ClientConnector interface for internal RPC
-func (cSv1 *ChargerSv1) Call(ctx *context.Context, serviceMethod string,
- args any, reply any) error {
- return utils.APIerRPCCall(cSv1, serviceMethod, args, reply)
-}
-
-func (cSv1 *ChargerSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
-
// GetChargerForEvent returns matching ChargerProfile for Event
func (cSv1 *ChargerSv1) GetChargersForEvent(ctx *context.Context, cgrEv *utils.CGREvent,
reply *engine.ChargerProfiles) error {
diff --git a/apier/v1/config.go b/apier/v1/config.go
index 3544548c7..c5ca46c3e 100644
--- a/apier/v1/config.go
+++ b/apier/v1/config.go
@@ -21,7 +21,6 @@ package v1
import (
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/utils"
)
// NewConfigSv1 returns a new ConfigSv1
@@ -58,9 +57,3 @@ func (cSv1 *ConfigSv1) SetConfigFromJSON(ctx *context.Context, args *config.SetC
func (cSv1 *ConfigSv1) GetConfigAsJSON(ctx *context.Context, args *config.SectionWithAPIOpts, reply *string) (err error) {
return cSv1.cfg.V1GetConfigAsJSON(ctx, args, reply)
}
-
-// Call implements birpc.ClientConnector interface for internal RPC
-func (cSv1 *ConfigSv1) Call(ctx *context.Context, serviceMethod string,
- args any, reply any) error {
- return utils.APIerRPCCall(cSv1, serviceMethod, args, reply)
-}
diff --git a/apier/v1/core.go b/apier/v1/core.go
index 038e1818f..e05789d1b 100644
--- a/apier/v1/core.go
+++ b/apier/v1/core.go
@@ -33,22 +33,10 @@ type CoreSv1 struct {
cS *cores.CoreService
}
-// Call implements birpc.ClientConnector interface for internal RPC
-func (cS *CoreSv1) Call(ctx *context.Context, serviceMethod string,
- args any, reply any) error {
- return utils.APIerRPCCall(cS, serviceMethod, args, reply)
-}
-
func (cS *CoreSv1) Status(ctx *context.Context, arg *utils.TenantWithAPIOpts, reply *map[string]any) error {
return cS.cS.V1Status(ctx, arg, reply)
}
-// Ping used to determinate if component is active
-func (cS *CoreSv1) Ping(ctx *context.Context, _ *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
-
// Sleep is used to test the concurrent requests mechanism
func (cS *CoreSv1) Sleep(ctx *context.Context, args *utils.DurationArgs, reply *string) error {
return cS.cS.V1Sleep(ctx, args, reply)
diff --git a/apier/v1/ees.go b/apier/v1/ees.go
index 91a44d0c1..4e5428e0e 100644
--- a/apier/v1/ees.go
+++ b/apier/v1/ees.go
@@ -22,7 +22,6 @@ import (
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/ees"
"github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
)
func NewEeSv1(eeS *ees.EventExporterS) *EeSv1 {
@@ -33,11 +32,6 @@ type EeSv1 struct {
eeS *ees.EventExporterS
}
-func (eeSv1 *EeSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
-
// ProcessEvent triggers exports on EEs side
func (eeSv1 *EeSv1) ProcessEvent(ctx *context.Context, args *engine.CGREventWithEeIDs,
reply *map[string]map[string]any) error {
diff --git a/apier/v1/ees_test.go b/apier/v1/ees_test.go
index aaa3e2aaf..83d854ba7 100644
--- a/apier/v1/ees_test.go
+++ b/apier/v1/ees_test.go
@@ -21,10 +21,7 @@ package v1
import (
"testing"
- "github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/ees"
- "github.com/cgrates/cgrates/ers"
- "github.com/cgrates/cgrates/utils"
)
func TestNewEeSv1(t *testing.T) {
@@ -37,37 +34,3 @@ func TestNewEeSv1(t *testing.T) {
t.Errorf("Expected eeS field to be set correctly")
}
}
-
-func TestEeSv1Ping(t *testing.T) {
- eeSv1 := &EeSv1{}
- ctx := context.Background()
- event := &utils.CGREvent{}
- var reply string
- err := eeSv1.Ping(ctx, event, &reply)
- if err != nil {
- t.Fatalf("Expected no error, got %v", err)
- }
- if reply != utils.Pong {
- t.Errorf("Expected reply to be %s, got %s", utils.Pong, reply)
- }
-}
-
-func TestErSv1NewErSv1AndPing(t *testing.T) {
- mockErS := &ers.ERService{}
- erSv1 := NewErSv1(mockErS)
- if erSv1 == nil {
- t.Fatalf("Expected non-nil ErSv1, got nil")
- }
- if erSv1.erS != mockErS {
- t.Errorf("Expected erS field to be set correctly")
- }
- ctx := context.Background()
- var reply string
- err := erSv1.Ping(ctx, nil, &reply)
- if err != nil {
- t.Fatalf("Expected no error from Ping, got %v", err)
- }
- if reply != utils.Pong {
- t.Errorf("Expected reply to be %s, got %s", utils.Pong, reply)
- }
-}
diff --git a/apier/v1/ers.go b/apier/v1/ers.go
index 5f99ce36c..bc0ae182c 100644
--- a/apier/v1/ers.go
+++ b/apier/v1/ers.go
@@ -21,7 +21,6 @@ package v1
import (
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/ers"
- "github.com/cgrates/cgrates/utils"
)
func NewErSv1(erS *ers.ERService) *ErSv1 {
@@ -32,11 +31,6 @@ type ErSv1 struct {
erS *ers.ERService
}
-func (eeSv1 *ErSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
-
// V1RunReader processes files in the configured directory for the given reader. This function handles files
// based on the reader's type and configuration. Only available for readers that are not processing files
// automatically (RunDelay should equal 0).
diff --git a/apier/v1/guardian.go b/apier/v1/guardian.go
index 15a0064ca..87f435e6d 100644
--- a/apier/v1/guardian.go
+++ b/apier/v1/guardian.go
@@ -22,7 +22,6 @@ import (
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/dispatchers"
"github.com/cgrates/cgrates/guardian"
- "github.com/cgrates/cgrates/utils"
)
func NewGuardianSv1() *GuardianSv1 {
@@ -42,15 +41,3 @@ func (self *GuardianSv1) RemoteUnlock(ctx *context.Context, refID *dispatchers.A
*reply = guardian.Guardian.UnguardIDs(refID.RefID)
return
}
-
-// Ping return pong if the service is active
-func (self *GuardianSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
-
-// Call implements birpc.ClientConnector interface for internal RPC
-func (self *GuardianSv1) Call(ctx *context.Context, serviceMethod string,
- args any, reply any) error {
- return utils.APIerRPCCall(self, serviceMethod, args, reply)
-}
diff --git a/apier/v1/libapier_test.go b/apier/v1/libapier_test.go
index 2a7d7f7f7..3a7ac20d5 100644
--- a/apier/v1/libapier_test.go
+++ b/apier/v1/libapier_test.go
@@ -281,17 +281,3 @@ func TestCallCacheForFilter(t *testing.T) {
t.Errorf("Expected %s ,received: %s", utils.ToJSON(exp), utils.ToJSON(rpl))
}
}
-
-func TestResourceSv1Ping(t *testing.T) {
- rsv1 := &ResourceSv1{}
- ctx := context.Background()
- ign := &utils.CGREvent{}
- var reply string
- err := rsv1.Ping(ctx, ign, &reply)
- if err != nil {
- t.Errorf("expected no error, got %v", err)
- }
- if reply != utils.Pong {
- t.Errorf("expected reply to be %v, got %v", utils.Pong, reply)
- }
-}
diff --git a/apier/v1/loaders.go b/apier/v1/loaders.go
index 5d09ab219..2e1248db5 100644
--- a/apier/v1/loaders.go
+++ b/apier/v1/loaders.go
@@ -21,7 +21,6 @@ package v1
import (
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/loaders"
- "github.com/cgrates/cgrates/utils"
)
func NewLoaderSv1(ldrS *loaders.LoaderService) *LoaderSv1 {
@@ -33,12 +32,6 @@ type LoaderSv1 struct {
ldrS *loaders.LoaderService
}
-// Call implements birpc.ClientConnector interface for internal RPC
-func (ldrSv1 *LoaderSv1) Call(ctx *context.Context, serviceMethod string,
- args any, reply any) error {
- return utils.APIerRPCCall(ldrSv1, serviceMethod, args, reply)
-}
-
func (ldrSv1 *LoaderSv1) Load(ctx *context.Context, args *loaders.ArgsProcessFolder,
rply *string) error {
return ldrSv1.ldrS.V1Load(ctx, args, rply)
@@ -48,8 +41,3 @@ func (ldrSv1 *LoaderSv1) Remove(ctx *context.Context, args *loaders.ArgsProcessF
rply *string) error {
return ldrSv1.ldrS.V1Remove(ctx, args, rply)
}
-
-func (rsv1 *LoaderSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
diff --git a/apier/v1/loaders_test.go b/apier/v1/loaders_test.go
index e265e50aa..570e91ed3 100644
--- a/apier/v1/loaders_test.go
+++ b/apier/v1/loaders_test.go
@@ -21,25 +21,9 @@ package v1
import (
"testing"
- "github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/loaders"
- "github.com/cgrates/cgrates/utils"
)
-func TestLoaderSv1Ping(t *testing.T) {
- rsv1 := &LoaderSv1{}
- ctx := context.Background()
- var reply string
- ign := &utils.CGREvent{}
- err := rsv1.Ping(ctx, ign, &reply)
- if err != nil {
- t.Errorf("Expected no error, but got: %v", err)
- }
- if reply != utils.Pong {
- t.Errorf("Expected reply to be '%s', but got '%s'", utils.Pong, reply)
- }
-}
-
func TestNewLoaderSv1(t *testing.T) {
mockLoaderService := &loaders.LoaderService{}
result := NewLoaderSv1(mockLoaderService)
@@ -50,16 +34,3 @@ func TestNewLoaderSv1(t *testing.T) {
t.Errorf("Expected ldrS to be %v, but got %v", mockLoaderService, result.ldrS)
}
}
-
-func TestLoaderSv1Call(t *testing.T) {
- ldrSv1 := &LoaderSv1{}
- ctx := context.Background()
- serviceMethod := "testMethod"
- args := "testArgs"
- var reply string
- err := ldrSv1.Call(ctx, serviceMethod, args, &reply)
- if err == nil {
- t.Errorf("Expected error, but got: %v", err)
- }
-
-}
diff --git a/apier/v1/rals.go b/apier/v1/rals.go
index 68f85f765..54b1afed5 100644
--- a/apier/v1/rals.go
+++ b/apier/v1/rals.go
@@ -34,11 +34,6 @@ func NewRALsV1() *RALsV1 {
type RALsV1 struct {
}
-// Call implements birpc.ClientConnector interface for internal RPC
-func (rsv1 *RALsV1) Call(ctx *context.Context, serviceMethod string, args any, reply any) error {
- return utils.APIerRPCCall(rsv1, serviceMethod, args, reply)
-}
-
// GetRatingPlansCost returns EventCosts matching RatingPlanIDs
func (rsv1 *RALsV1) GetRatingPlansCost(ctx *context.Context, arg *utils.RatingPlanCostArg, reply *dispatchers.RatingPlanCost) error {
if missing := utils.MissingStructFields(arg, []string{utils.RatingPlanIDs,
@@ -107,8 +102,3 @@ func (rsv1 *RALsV1) GetRatingPlansCost(ctx *context.Context, arg *utils.RatingPl
}
return nil
}
-
-func (rsv1 *RALsV1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
diff --git a/apier/v1/rankings.go b/apier/v1/rankings.go
index 780b94d19..baabb72e9 100644
--- a/apier/v1/rankings.go
+++ b/apier/v1/rankings.go
@@ -133,8 +133,3 @@ func NewRankingSv1() *RankingSv1 {
}
type RankingSv1 struct{}
-
-func (sa *RankingSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
diff --git a/apier/v1/rankings_test.go b/apier/v1/rankings_test.go
index 5a000eaf1..dc57b0d36 100644
--- a/apier/v1/rankings_test.go
+++ b/apier/v1/rankings_test.go
@@ -21,24 +21,10 @@ package v1
import (
"testing"
- "github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
-func TestRankingSv1Ping(t *testing.T) {
- sa := &RankingSv1{}
- ctx := context.Background()
- ign := &utils.CGREvent{}
- var reply string
- err := sa.Ping(ctx, ign, &reply)
- if err != nil {
- t.Errorf("expected no error, got %v", err)
- }
- if reply != utils.Pong {
- t.Errorf("expected reply to be %v, got %v", utils.Pong, reply)
- }
-}
func TestNewRankingSv1(t *testing.T) {
rankingSvc := NewRankingSv1()
if rankingSvc == nil {
@@ -66,34 +52,3 @@ func TestRemoveRankingProfile(t *testing.T) {
}
}
-
-func TestRalsPing(t *testing.T) {
- rsv1 := &RALsV1{}
- ctx := context.Background()
- var ign *utils.CGREvent
- var reply string
- err := rsv1.Ping(ctx, ign, &reply)
- if err != nil {
- t.Errorf("Expected no error, got %v", err)
- }
- expectedReply := utils.Pong
- if reply != expectedReply {
- t.Errorf("Expected reply %v, got %v", expectedReply, reply)
- }
-}
-
-func TestRalsCall(t *testing.T) {
- rsv1 := &RALsV1{}
- ctx := context.Background()
- serviceMethod := "TestServiceMethod"
- args := "TestArgs"
- var reply string
- err := rsv1.Call(ctx, serviceMethod, args, &reply)
- if err == nil {
- t.Errorf("UNSUPPORTED_SERVICE_METHOD")
- }
- expectedReply := "response"
- if reply == expectedReply {
- t.Errorf("Expected reply %v, got %v", expectedReply, reply)
- }
-}
diff --git a/apier/v1/replicator.go b/apier/v1/replicator.go
index 22b10cf39..4149b34ec 100644
--- a/apier/v1/replicator.go
+++ b/apier/v1/replicator.go
@@ -41,11 +41,6 @@ type ReplicatorSv1 struct {
v1 *APIerSv1 // needed for CallCache only
}
-// Call implements birpc.ClientConnector interface for internal RPC
-func (rplSv1 *ReplicatorSv1) Call(ctx *context.Context, serviceMethod string, args any, reply any) error {
- return utils.APIerRPCCall(rplSv1, serviceMethod, args, reply)
-}
-
// GetAccount is the remote method coresponding to the dataDb driver method
func (rplSv1 *ReplicatorSv1) GetAccount(ctx *context.Context, args *utils.StringWithAPIOpts, reply *engine.Account) error {
engine.UpdateReplicationFilters(utils.AccountPrefix, args.Arg, utils.IfaceAsString(args.APIOpts[utils.RemoteHostOpt]))
@@ -1149,9 +1144,3 @@ func (rplSv1 *ReplicatorSv1) RemoveIndexes(ctx *context.Context, args *utils.Get
*reply = utils.OK
return
}
-
-// Ping used to determine if the RPC is active
-func (rplSv1 *ReplicatorSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
diff --git a/apier/v1/resourcesv1.go b/apier/v1/resourcesv1.go
index 9c52e84c4..f1606daac 100644
--- a/apier/v1/resourcesv1.go
+++ b/apier/v1/resourcesv1.go
@@ -36,11 +36,6 @@ type ResourceSv1 struct {
rls *engine.ResourceService
}
-// Call implements birpc.ClientConnector interface for internal RPC
-func (rsv1 *ResourceSv1) Call(ctx *context.Context, serviceMethod string, args any, reply any) error {
- return utils.APIerRPCCall(rsv1, serviceMethod, args, reply)
-}
-
// GetResourcesForEvent returns Resources matching a specific event
func (rsv1 *ResourceSv1) GetResourcesForEvent(ctx *context.Context, args *utils.CGREvent, reply *engine.Resources) error {
return rsv1.rls.V1GetResourcesForEvent(ctx, args, reply)
@@ -173,8 +168,3 @@ func (apierSv1 *APIerSv1) RemoveResourceProfile(ctx *context.Context, arg *utils
*reply = utils.OK
return nil
}
-
-func (rsv1 *ResourceSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
diff --git a/apier/v1/routes.go b/apier/v1/routes.go
index 37b1f4d38..03750f499 100644
--- a/apier/v1/routes.go
+++ b/apier/v1/routes.go
@@ -139,11 +139,6 @@ type RouteSv1 struct {
rS *engine.RouteService
}
-// Call implements birpc.ClientConnector interface for internal RPC
-func (rS *RouteSv1) Call(ctx *context.Context, serviceMethod string, args any, reply any) error {
- return utils.APIerRPCCall(rS, serviceMethod, args, reply)
-}
-
// GetRoutes returns sorted list of routes for Event
func (rS *RouteSv1) GetRoutes(ctx *context.Context, args *utils.CGREvent, reply *engine.SortedRoutesList) error {
return rS.rS.V1GetRoutes(ctx, args, reply)
@@ -154,11 +149,6 @@ func (rS *RouteSv1) GetRouteProfilesForEvent(ctx *context.Context, args *utils.C
return rS.rS.V1GetRouteProfilesForEvent(ctx, args, reply)
}
-func (rS *RouteSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
-
// GetRoutesList returns sorted list of routes for Event as a string slice
func (rS *RouteSv1) GetRoutesList(ctx *context.Context, args *utils.CGREvent, reply *[]string) error {
return rS.rS.V1GetRoutesList(ctx, args, reply)
diff --git a/apier/v1/schedulers.go b/apier/v1/schedulers.go
index a633e8f28..e613cc17e 100644
--- a/apier/v1/schedulers.go
+++ b/apier/v1/schedulers.go
@@ -172,15 +172,3 @@ func (schdSv1 *SchedulerSv1) ExecuteActionPlans(ctx *context.Context, attr *util
*reply = utils.OK
return nil
}
-
-// Ping returns Pong
-func (schdSv1 *SchedulerSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
-
-// Call implements birpc.ClientConnector interface for internal RPC
-func (schdSv1 *SchedulerSv1) Call(ctx *context.Context, serviceMethod string,
- args any, reply any) error {
- return utils.APIerRPCCall(schdSv1, serviceMethod, args, reply)
-}
diff --git a/apier/v1/schedulers_test.go b/apier/v1/schedulers_test.go
deleted file mode 100644
index b5e3eba59..000000000
--- a/apier/v1/schedulers_test.go
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-package v1
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestSchedulerSv1Ping(t *testing.T) {
-
- scheduler := &SchedulerSv1{}
-
- ctx := context.Background()
- ign := &utils.CGREvent{}
- reply := ""
-
- err := scheduler.Ping(ctx, ign, &reply)
-
- if err != nil {
- t.Fatalf("Expected no error, got %v", err)
- }
-
- if reply != utils.Pong {
- t.Errorf("Expected reply to be %v, got %v", utils.Pong, reply)
- }
-}
-
-func TestSchedulerSv1Call(t *testing.T) {
- scheduler := &SchedulerSv1{}
- ctx := context.Background()
- serviceMethod := "ServiceMethod"
- args := "Args"
- var reply string
- err := scheduler.Call(ctx, serviceMethod, args, &reply)
- if err == nil {
- t.Fatalf("Expected error")
- }
-
-}
diff --git a/apier/v1/servicemanager.go b/apier/v1/servicemanager.go
index 53aa9cf50..1a43aefb0 100644
--- a/apier/v1/servicemanager.go
+++ b/apier/v1/servicemanager.go
@@ -22,7 +22,6 @@ import (
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/dispatchers"
"github.com/cgrates/cgrates/servmanager"
- "github.com/cgrates/cgrates/utils"
)
func NewServiceManagerV1(sm *servmanager.ServiceManager) *ServiceManagerV1 {
@@ -44,15 +43,3 @@ func (servManager *ServiceManagerV1) StopService(ctx *context.Context, args *dis
func (servManager *ServiceManagerV1) ServiceStatus(ctx *context.Context, args *dispatchers.ArgStartServiceWithAPIOpts, reply *string) (err error) {
return servManager.sm.V1ServiceStatus(ctx, args.ArgStartService, reply)
}
-
-// Ping return pong if the service is active
-func (servManager *ServiceManagerV1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
-
-// Call implements birpc.ClientConnector interface for internal RPC
-func (servManager *ServiceManagerV1) Call(ctx *context.Context, serviceMethod string,
- args any, reply any) error {
- return utils.APIerRPCCall(servManager, serviceMethod, args, reply)
-}
diff --git a/apier/v1/sessions.go b/apier/v1/sessions.go
index abaeb454b..00c26c370 100644
--- a/apier/v1/sessions.go
+++ b/apier/v1/sessions.go
@@ -115,11 +115,6 @@ func (ssv1 *SessionSv1) GetPassiveSessionsCount(ctx *context.Context, args *util
return ssv1.sS.BiRPCv1GetPassiveSessionsCount(ctx, args, rply)
}
-func (ssv1 *SessionSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
-
func (ssv1 *SessionSv1) ReplicateSessions(ctx *context.Context, args *dispatchers.ArgsReplicateSessionsWithAPIOpts, rply *string) error {
return ssv1.sS.BiRPCv1ReplicateSessions(ctx, args.ArgsReplicateSessions, rply)
}
diff --git a/apier/v1/stats.go b/apier/v1/stats.go
index 291c1e5b4..bf213efdf 100644
--- a/apier/v1/stats.go
+++ b/apier/v1/stats.go
@@ -140,11 +140,6 @@ type StatSv1 struct {
sS *engine.StatService
}
-// Call implements birpc.ClientConnector interface for internal RPC
-func (stsv1 *StatSv1) Call(ctx *context.Context, serviceMethod string, args any, reply any) error {
- return utils.APIerRPCCall(stsv1, serviceMethod, args, reply)
-}
-
// GetQueueIDs returns list of queueIDs registered for a tenant
func (stsv1 *StatSv1) GetQueueIDs(ctx *context.Context, tenant *utils.TenantWithAPIOpts, qIDs *[]string) error {
return stsv1.sS.V1GetQueueIDs(ctx, tenant.Tenant, qIDs)
@@ -179,9 +174,3 @@ func (stsv1 *StatSv1) GetQueueFloatMetrics(ctx *context.Context, args *utils.Ten
func (stsv1 *StatSv1) ResetStatQueue(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) error {
return stsv1.sS.V1ResetStatQueue(ctx, args.TenantID, reply)
}
-
-// Ping .
-func (stsv1 *StatSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
diff --git a/apier/v1/thresholds.go b/apier/v1/thresholds.go
index ecb678448..56a2236ee 100644
--- a/apier/v1/thresholds.go
+++ b/apier/v1/thresholds.go
@@ -37,11 +37,6 @@ type ThresholdSv1 struct {
tS *engine.ThresholdService
}
-// Call implements birpc.ClientConnector interface for internal RPC
-func (tSv1 *ThresholdSv1) Call(ctx *context.Context, serviceMethod string, args any, reply any) error {
- return utils.APIerRPCCall(tSv1, serviceMethod, args, reply)
-}
-
// GetThresholdIDs returns list of threshold IDs registered for a tenant
func (tSv1 *ThresholdSv1) GetThresholdIDs(ctx *context.Context, tenant *utils.TenantWithAPIOpts, tIDs *[]string) error {
return tSv1.tS.V1GetThresholdIDs(ctx, tenant.Tenant, tIDs)
@@ -187,9 +182,3 @@ func (apierSv1 *APIerSv1) RemoveThresholdProfile(ctx *context.Context, args *uti
*reply = utils.OK
return nil
}
-
-// Ping .
-func (tSv1 *ThresholdSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
diff --git a/apier/v1/trends.go b/apier/v1/trends.go
index 890541a77..1410b38d0 100644
--- a/apier/v1/trends.go
+++ b/apier/v1/trends.go
@@ -112,8 +112,3 @@ func NewTrendSv1(trs *engine.TrendService) *TrendSv1 {
type TrendSv1 struct {
trS *engine.TrendService
}
-
-func (sa *TrendSv1) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
diff --git a/apier/v2/apier.go b/apier/v2/apier.go
index ada2d9568..a7e8a252e 100644
--- a/apier/v2/apier.go
+++ b/apier/v2/apier.go
@@ -39,12 +39,6 @@ type APIerSv2 struct {
v1.APIerSv1
}
-// Call implements birpc.ClientConnector interface for internal RPC
-func (apiv2 *APIerSv2) Call(ctx *context.Context, serviceMethod string,
- args any, reply any) error {
- return utils.APIerRPCCall(apiv2, serviceMethod, args, reply)
-}
-
type AttrLoadRatingProfile struct {
TPid string
RatingProfileID string
@@ -387,9 +381,3 @@ func (apiv2 *APIerSv2) SetActions(ctx *context.Context, attrs *utils.AttrSetActi
*reply = utils.OK
return nil
}
-
-// Ping return pong if the service is active
-func (apiv2 *APIerSv2) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go
index de571bf22..119f69ddf 100644
--- a/cmd/cgr-engine/cgr-engine.go
+++ b/cmd/cgr-engine/cgr-engine.go
@@ -90,14 +90,12 @@ func initCacheS(internalCacheSChan chan birpc.ClientConnector,
}
}()
- srv, err := engine.NewService(chS)
+ srv, err := engine.NewService(v1.NewCacheSv1(chS))
if err != nil {
return nil, err
}
if !cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- server.RpcRegister(s)
- }
+ server.RpcRegister(srv)
}
internalCacheSChan <- anz.GetInternalCodec(srv, utils.CacheS)
return chS, nil
@@ -110,9 +108,7 @@ func initGuardianSv1(internalGuardianSChan chan birpc.ClientConnector, server *c
return err
}
if !cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- server.RpcRegister(s)
- }
+ server.RpcRegister(srv)
}
internalGuardianSChan <- anz.GetInternalCodec(srv, utils.GuardianS)
return nil
@@ -126,9 +122,7 @@ func initServiceManagerV1(internalServiceManagerChan chan birpc.ClientConnector,
return err
}
if !cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- server.RpcRegister(s)
- }
+ server.RpcRegister(srv)
}
internalServiceManagerChan <- anz.GetInternalCodec(srv, utils.ServiceManager)
return nil
@@ -141,9 +135,7 @@ func initConfigSv1(internalConfigChan chan birpc.ClientConnector,
return err
}
if !cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- server.RpcRegister(s)
- }
+ server.RpcRegister(srv)
}
internalConfigChan <- anz.GetInternalCodec(srv, utils.ConfigSv1)
return nil
diff --git a/config/config.go b/config/config.go
index 3a4ac6f61..95a35bd6a 100644
--- a/config/config.go
+++ b/config/config.go
@@ -1183,12 +1183,6 @@ func (cfg *CGRConfig) GetReloadChan(sectID string) chan struct{} {
return cfg.rldChans[sectID]
}
-// Call implements birpc.ClientConnector interface for internal RPC
-func (cfg *CGRConfig) Call(ctx *context.Context, serviceMethod string,
- args any, reply any) error {
- return utils.APIerRPCCall(cfg, serviceMethod, args, reply)
-}
-
func (cfg *CGRConfig) rLockSections() {
for _, lk := range cfg.lks {
lk.RLock()
diff --git a/config/config_test.go b/config/config_test.go
index 934299cbb..265a07fe4 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -5563,14 +5563,6 @@ func TestLoadConfigFromReaderLoadFunctionsError(t *testing.T) {
}
}
-func TestCallOnCGRConfig(t *testing.T) {
- expected := "UNSUPPORTED_SERVICE_METHOD"
- cgrcfg := NewDefaultCGRConfig()
- if err := cgrcfg.Call(context.Background(), "inexistentMethod", nil, nil); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-}
-
func TestLoadCfgFromJSONWithLocksInvalidSeciton(t *testing.T) {
expected := "Invalid section: "
cfg := NewDefaultCGRConfig()
diff --git a/console/ping_test.go b/console/ping_test.go
index 81dacf574..89cc29aff 100644
--- a/console/ping_test.go
+++ b/console/ping_test.go
@@ -20,10 +20,10 @@ package console
import (
"reflect"
- "strings"
"testing"
v1 "github.com/cgrates/cgrates/apier/v1"
+ "github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -39,10 +39,15 @@ func TestCmdPingRoutesLow(t *testing.T) {
if !reflect.DeepEqual(result2, utils.RouteSv1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.RouteSv1Ping, result2)
}
- m, ok := reflect.TypeOf(new(v1.RouteSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
+ srv, err := engine.NewService(&v1.RouteSv1{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
+ m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
@@ -73,10 +78,15 @@ func TestCmdPingAttributesLow(t *testing.T) {
if !reflect.DeepEqual(result2, utils.AttributeSv1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.AttributeSv1Ping, result2)
}
- m, ok := reflect.TypeOf(new(v1.AttributeSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
+ srv, err := engine.NewService(&v1.AttributeSv1{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
+ m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
@@ -108,10 +118,15 @@ func TestCmdPingChargerSLow(t *testing.T) {
if !reflect.DeepEqual(result2, utils.ChargerSv1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.ChargerSv1Ping, result2)
}
- m, ok := reflect.TypeOf(new(v1.ChargerSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
+ srv, err := engine.NewService(&v1.ChargerSv1{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
+ m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
@@ -143,10 +158,15 @@ func TestCmdPingResourcesLow(t *testing.T) {
if !reflect.DeepEqual(result2, utils.ResourceSv1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.ResourceSv1Ping, result2)
}
- m, ok := reflect.TypeOf(new(v1.ResourceSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
+ srv, err := engine.NewService(&v1.ResourceSv1{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
+ m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
@@ -178,10 +198,15 @@ func TestCmdPingStatServiceLow(t *testing.T) {
if !reflect.DeepEqual(result2, utils.StatSv1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.StatSv1Ping, result2)
}
- m, ok := reflect.TypeOf(new(v1.StatSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
+ srv, err := engine.NewService(&v1.StatSv1{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
+ m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
@@ -212,10 +237,15 @@ func TestCmdPingThresholdsLow(t *testing.T) {
if !reflect.DeepEqual(result2, utils.ThresholdSv1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.ThresholdSv1Ping, result2)
}
- m, ok := reflect.TypeOf(new(v1.ThresholdSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
+ srv, err := engine.NewService(&v1.ThresholdSv1{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
+ m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
@@ -246,10 +276,15 @@ func TestCmdPingSessionsLow(t *testing.T) {
if !reflect.DeepEqual(result2, utils.SessionSv1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.SessionSv1Ping, result2)
}
- m, ok := reflect.TypeOf(new(v1.SessionSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
+ srv, err := engine.NewService(&v1.SessionSv1{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
+ m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
@@ -280,10 +315,15 @@ func TestCmdPingLoaderSLow(t *testing.T) {
if !reflect.DeepEqual(result2, utils.LoaderSv1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.LoaderSv1Ping, result2)
}
- m, ok := reflect.TypeOf(new(v1.LoaderSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
+ srv, err := engine.NewService(&v1.LoaderSv1{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
+ m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
@@ -314,10 +354,15 @@ func TestCmdPingDispatcherSLow(t *testing.T) {
if !reflect.DeepEqual(result2, utils.DispatcherSv1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.DispatcherSv1Ping, result2)
}
- m, ok := reflect.TypeOf(new(v1.DispatcherSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
+ srv, err := engine.NewService(&v1.DispatcherSv1{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
+ m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
@@ -348,10 +393,15 @@ func TestCmdPingAnalyzerSLow(t *testing.T) {
if !reflect.DeepEqual(result2, utils.AnalyzerSv1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.AnalyzerSv1Ping, result2)
}
- m, ok := reflect.TypeOf(new(v1.AnalyzerSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
+ srv, err := engine.NewService(&v1.AnalyzerSv1{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
+ m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
@@ -382,10 +432,15 @@ func TestCmdPingSchedulerSLow(t *testing.T) {
if !reflect.DeepEqual(result2, utils.SchedulerSv1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.SchedulerSv1Ping, result2)
}
- m, ok := reflect.TypeOf(new(v1.SchedulerSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
+ srv, err := engine.NewService(&v1.SchedulerSv1{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
+ m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
@@ -416,10 +471,15 @@ func TestCmdPingRALsLow(t *testing.T) {
if !reflect.DeepEqual(result2, utils.RALsV1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.RALsV1Ping, result2)
}
- m, ok := reflect.TypeOf(new(v1.RALsV1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
+ srv, err := engine.NewService(&v1.RALsV1{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
+ m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
@@ -450,10 +510,15 @@ func TestCmdPingReplicatorLow(t *testing.T) {
if !reflect.DeepEqual(result2, utils.ReplicatorSv1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.RALsV1Ping, result2)
}
- m, ok := reflect.TypeOf(new(v1.ReplicatorSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
+ srv, err := engine.NewService(&v1.ReplicatorSv1{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
+ m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
@@ -484,10 +549,15 @@ func TestCmdPingApierSLow(t *testing.T) {
if !reflect.DeepEqual(result2, utils.APIerSv1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.APIerSv1Ping, result2)
}
- m, ok := reflect.TypeOf(new(v1.APIerSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
+ srv, err := engine.NewService(&v1.APIerSv1{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
+ m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
@@ -518,10 +588,15 @@ func TestCmdPingEEsLow(t *testing.T) {
if !reflect.DeepEqual(result2, utils.EeSv1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.EeSv1Ping, result2)
}
- m, ok := reflect.TypeOf(new(v1.EeSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
+ srv, err := engine.NewService(&v1.EeSv1{})
+ if err != nil {
+ t.Fatal(err)
+ }
+ mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
+ m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
diff --git a/ees/ees.go b/ees/ees.go
index 66baf5445..56d153507 100644
--- a/ees/ees.go
+++ b/ees/ees.go
@@ -62,11 +62,6 @@ type EventExporterS struct {
mu sync.RWMutex // protects exporterCache
}
-// Call implements birpc.ClientConnector interface for internal RPC
-func (eeS *EventExporterS) Call(ctx *context.Context, serviceMethod string, args any, reply any) error {
- return utils.RPCCall(eeS, serviceMethod, args, reply)
-}
-
// ClearExporterCache clears the cache of EventExporters.
func (eeS *EventExporterS) ClearExporterCache() {
eeS.mu.Lock()
diff --git a/ees/ees_test.go b/ees/ees_test.go
index 4ef91b27e..4480a8334 100644
--- a/ees/ees_test.go
+++ b/ees/ees_test.go
@@ -36,21 +36,6 @@ import (
"github.com/cgrates/rpcclient"
)
-func TestCall(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- newIDb := engine.NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items)
- newDM := engine.NewDataManager(newIDb, cfg.CacheCfg(), nil)
- filterS := engine.NewFilterS(cfg, nil, newDM)
- eeS, err := NewEventExporterS(cfg, filterS, nil)
- if err != nil {
- t.Fatal(err)
- }
- errExpect := "UNSUPPORTED_SERVICE_METHOD"
- if err := eeS.Call(context.Background(), "test", 24532, 43643); err == nil || err.Error() != errExpect {
- t.Errorf("Expected %q but received %q", errExpect, err)
- }
-}
-
type testMockEvent struct {
calls map[string]func(args any, reply any) error
}
diff --git a/engine/caches.go b/engine/caches.go
index a255f449c..62f319750 100644
--- a/engine/caches.go
+++ b/engine/caches.go
@@ -309,11 +309,6 @@ func (chS *CacheS) Precache() (err error) {
// APIs start here
-// Call gives the ability of CacheS to be passed as internal RPC
-func (chS *CacheS) Call(ctx *context.Context, serviceMethod string, args any, reply any) error {
- return utils.RPCCall(chS, serviceMethod, args, reply)
-}
-
func (chS *CacheS) V1GetItemIDs(ctx *context.Context, args *utils.ArgsGetCacheItemIDsWithAPIOpts,
reply *[]string) (err error) {
itmIDs := chS.tCache.GetItemIDs(args.CacheID, args.ItemIDPrefix)
diff --git a/engine/caches_test.go b/engine/caches_test.go
index 0ca753f54..b847a8a3a 100644
--- a/engine/caches_test.go
+++ b/engine/caches_test.go
@@ -1053,18 +1053,3 @@ func TestCachesV1ReLoadCache(t *testing.T) {
}
}
-
-func TestCachesCall(t *testing.T) {
- chS := CacheS{}
-
- ctx := context.Background()
- serviceMethod := "Method"
- args := "Args"
- reply := "Reply"
-
- err := chS.Call(ctx, serviceMethod, args, reply)
-
- if err == nil {
- t.Errorf("Call returned an unexpected error: %v", err)
- }
-}
diff --git a/engine/cdrs.go b/engine/cdrs.go
index 11072ee93..4cc909cca 100644
--- a/engine/cdrs.go
+++ b/engine/cdrs.go
@@ -21,16 +21,13 @@ package engine
import (
"fmt"
"net/http"
- "reflect"
"slices"
- "strings"
"time"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/guardian"
"github.com/cgrates/cgrates/utils"
- "github.com/cgrates/rpcclient"
)
func newMapEventFromReqForm(r *http.Request) (mp MapEvent, err error) {
@@ -746,33 +743,6 @@ func (cdrS *CDRServer) processEvents(evs []*utils.CGREvent, args cdrProcessingAr
return
}
-// Call implements the birpc.ClientConnector interface
-func (cdrS *CDRServer) Call(ctx *context.Context, serviceMethod string, args any, reply any) error {
- parts := strings.Split(serviceMethod, ".")
- if len(parts) != 2 {
- return rpcclient.ErrUnsupporteServiceMethod
- }
- // get method
- method := reflect.ValueOf(cdrS).MethodByName(parts[0][len(parts[0])-2:] + parts[1]) // Inherit the version in the method
- if !method.IsValid() {
- return rpcclient.ErrUnsupporteServiceMethod
- }
- // construct the params
- params := []reflect.Value{reflect.ValueOf(args), reflect.ValueOf(reply)}
- ret := method.Call(params)
- if len(ret) != 1 {
- return utils.ErrServerError
- }
- if ret[0].Interface() == nil {
- return nil
- }
- err, ok := ret[0].Interface().(error)
- if !ok {
- return utils.ErrServerError
- }
- return err
-}
-
// V1ProcessCDR processes a CDR
func (cdrS *CDRServer) V1ProcessCDR(ctx *context.Context, cdr *CDRWithAPIOpts, reply *string) (err error) {
if cdr.CGRID == utils.EmptyString { // Populate CGRID if not present
diff --git a/engine/cdrs_test.go b/engine/cdrs_test.go
index 3134d35c0..6352c0834 100644
--- a/engine/cdrs_test.go
+++ b/engine/cdrs_test.go
@@ -2591,32 +2591,6 @@ func TestCDRSV1ProcessEvents(t *testing.T) {
}
}
-func TestCDRSCallValidServiceMethod(t *testing.T) {
- cdrS := &CDRServer{}
-
- args := struct{}{}
- reply := new(struct{})
-
- err := cdrS.Call(nil, "CDRServer.testMethod", args, reply)
-
- if err == nil {
- t.Errorf("UNSUPPORTED_SERVICE_METHOD, got %v", err)
- }
-}
-
-func TestCDRSCallInvalidServiceMethod(t *testing.T) {
- cdrS := &CDRServer{}
-
- args := struct{}{}
- reply := new(struct{})
-
- err := cdrS.Call(nil, "CDRServer.InvalidMethod", args, reply)
-
- if err != rpcclient.ErrUnsupporteServiceMethod {
- t.Errorf("Expected error %v, got %v", rpcclient.ErrUnsupporteServiceMethod, err)
- }
-}
-
func TestNewMapEventFromReqForm_ParseForm(t *testing.T) {
formData := url.Values{}
formData.Add("key", "value")
diff --git a/engine/libengine.go b/engine/libengine.go
index 925b1af8c..f55df0c9e 100644
--- a/engine/libengine.go
+++ b/engine/libengine.go
@@ -24,7 +24,6 @@ import (
"reflect"
"strings"
"time"
- "unicode"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
@@ -165,41 +164,17 @@ func (s RPCClientSet) Call(ctx *context.Context, method string, args any, reply
// }
// }
-func NewService(val any) (_ IntService, err error) {
- return NewServiceWithName(val, utils.EmptyString, false)
+func NewService(rcvr any) (*birpc.Service, error) {
+ return NewServiceWithName(rcvr, utils.EmptyString, false)
}
-func NewServiceWithName(val any, name string, useName bool) (_ IntService, err error) {
- var srv *birpc.Service
- if srv, err = birpc.NewService(val, name, useName); err != nil {
- return
+func NewServiceWithName(rcvr any, name string, useName bool) (*birpc.Service, error) {
+ srv, err := birpc.NewService(rcvr, name, useName)
+ if err != nil {
+ return nil, err
}
srv.Methods["Ping"] = pingM
- s := IntService{srv.Name: srv}
- for m, v := range srv.Methods {
- m = strings.TrimPrefix(m, "BiRPC")
- if len(m) < 2 || unicode.ToLower(rune(m[0])) != 'v' {
- continue
- }
-
- key := srv.Name
- if unicode.IsLower(rune(key[len(key)-1])) {
- key += "V"
- } else {
- key += "v"
- }
- key += string(m[1])
- srv2, has := s[key]
- if !has {
- srv2 = new(birpc.Service)
- *srv2 = *srv
- srv2.Name = key
- RegisterPingMethod(srv2.Methods)
- s[key] = srv2
- }
- srv2.Methods[m[2:]] = v
- }
- return s, nil
+ return srv, nil
}
// func NewDispatcherService(val any) (_ IntService, err error) {
diff --git a/engine/libengine_test.go b/engine/libengine_test.go
index 94b789534..c401ae69a 100644
--- a/engine/libengine_test.go
+++ b/engine/libengine_test.go
@@ -320,45 +320,6 @@ func TestPing(t *testing.T) {
}
}
-func TestNewService(t *testing.T) {
- testCases := []struct {
- name string
- input any
- expectErr bool
- }{
- {"valid input", "valid", false},
- {"invalid input", "invalid", true},
- }
- for _, tc := range testCases {
- t.Run(tc.name, func(t *testing.T) {
- service, _ := NewService(tc.input)
- if !tc.expectErr && service != nil {
- t.Error("expected non-nil service, got nil")
- }
- })
- }
-}
-
-func TestIntServiceCall(t *testing.T) {
- tService := &birpc.Service{}
- intService := IntService{
- "testService": tService,
- }
- ctx := &context.Context{}
- serviceMethod := "testService.Method"
- args := "testArgs"
- var reply any
- err := intService.Call(ctx, serviceMethod, args, &reply)
- if err == nil {
- t.Errorf("Expected no error, got %v", err)
- }
- invalidServiceMethod := "nonexistentService.Method"
- err = intService.Call(ctx, invalidServiceMethod, args, &reply)
- if err == nil || err.Error() != "rpc: can't find service "+invalidServiceMethod {
- t.Errorf("Expected error 'rpc: can't find service %s', got %v", invalidServiceMethod, err)
- }
-}
-
func TestGetSessionsBackup(t *testing.T) {
_, err := dm.GetSessionsBackup("node1", "tenant1")
if err == utils.ErrNoDatabaseConn {
diff --git a/engine/responder.go b/engine/responder.go
index f174dce9d..d1fa01f71 100644
--- a/engine/responder.go
+++ b/engine/responder.go
@@ -20,8 +20,6 @@ package engine
import (
"fmt"
- "reflect"
- "strings"
"sync"
"time"
@@ -391,35 +389,3 @@ func (rs *Responder) Shutdown(ctx *context.Context, arg *utils.TenantWithAPIOpts
*reply = "Done!"
return
}
-
-// Ping used to detreminate if component is active
-func (chSv1 *Responder) Ping(ctx *context.Context, ign *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
-
-func (rs *Responder) Call(ctx *context.Context, serviceMethod string, args any, reply any) error {
- parts := strings.Split(serviceMethod, ".")
- if len(parts) != 2 {
- return utils.ErrNotImplemented
- }
- // get method
- method := reflect.ValueOf(rs).MethodByName(parts[1])
- if !method.IsValid() {
- return utils.ErrNotImplemented
- }
- // construct the params
- params := []reflect.Value{reflect.ValueOf(args), reflect.ValueOf(reply)}
- ret := method.Call(params)
- if len(ret) != 1 {
- return utils.ErrServerError
- }
- if ret[0].Interface() == nil {
- return nil
- }
- err, ok := ret[0].Interface().(error)
- if !ok {
- return utils.ErrServerError
- }
- return err
-}
diff --git a/engine/responder_test.go b/engine/responder_test.go
index a13d99d33..f6b5b4b7f 100644
--- a/engine/responder_test.go
+++ b/engine/responder_test.go
@@ -1430,17 +1430,3 @@ func TestResponderGetCostOnRatingPlans(t *testing.T) {
t.Errorf("expected %v, got %v", exp, reply)
}
}
-
-func TestResponderPingResponder(t *testing.T) {
- responder := &Responder{}
- ctx := context.Background()
- var event *utils.CGREvent = nil
- var reply string
- err := responder.Ping(ctx, event, &reply)
- if reply != utils.Pong {
- t.Errorf("Expected reply to be '%s', got '%s'", utils.Pong, reply)
- }
- if err != nil {
- t.Errorf("Expected error to be nil, got %v", err)
- }
-}
diff --git a/engine/stats.go b/engine/stats.go
index ee6977101..679d93158 100644
--- a/engine/stats.go
+++ b/engine/stats.go
@@ -244,12 +244,6 @@ func (sS *StatService) matchingStatQueuesForEvent(tnt string, statsIDs []string,
return
}
-// Call implements birpc.ClientConnector interface for internal RPC
-// here for cases when passing StatsService as rpccclient.RpcClientConnection
-func (sS *StatService) Call(ctx *context.Context, serviceMethod string, args any, reply any) error {
- return utils.RPCCall(sS, serviceMethod, args, reply)
-}
-
func (sS *StatService) getStatQueue(tnt, id string) (sq *StatQueue, err error) {
if sq, err = sS.dm.GetStatQueue(tnt, id, true, true, utils.EmptyString); err != nil {
return
diff --git a/engine/stats_test.go b/engine/stats_test.go
index 3da4f1e16..90e6839ac 100644
--- a/engine/stats_test.go
+++ b/engine/stats_test.go
@@ -3375,26 +3375,3 @@ func TestStatQueueProcessEventErr(t *testing.T) {
}
}
-
-func TestStatServiceCall(t *testing.T) {
-
- tDM := &DataManager{}
- tConnMgr := &ConnManager{}
- tFilterS := &FilterS{}
- tCGRConfig := &config.CGRConfig{}
- statService := &StatService{
- dm: tDM,
- connMgr: tConnMgr,
- filterS: tFilterS,
- cgrcfg: tCGRConfig,
- }
- ctx := context.Background()
- serviceMethod := ""
- args := ""
- reply := ""
- err := statService.Call(ctx, serviceMethod, args, &reply)
- if err == nil {
- t.Errorf("Call method returned error: %v", err)
- }
-
-}
diff --git a/engine/z_loader_it_test.go b/engine/z_loader_it_test.go
index 5e2c2483c..d049b094d 100644
--- a/engine/z_loader_it_test.go
+++ b/engine/z_loader_it_test.go
@@ -24,6 +24,7 @@ import (
"flag"
"path"
"reflect"
+ "strings"
"testing"
"github.com/cgrates/birpc"
@@ -100,7 +101,12 @@ func testLoaderITInitDataDB(t *testing.T) {
connMgr = NewConnManager(lCfg, map[string]chan birpc.ClientConnector{
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches): cacheChan,
})
- srv, err := NewService(NewCacheS(lCfg, NewDataManager(dataDbCsv, lCfg.CacheCfg(), connMgr), nil))
+
+ // Importing v1 package would create an import cycle; using the CacheS object instead.
+ chS := NewCacheS(lCfg, NewDataManager(dataDbCsv, lCfg.CacheCfg(), connMgr), nil)
+ srv, err := birpc.NewServiceWithMethodsRename(chS, utils.CacheSv1, true, func(oldFn string) (newFn string) {
+ return strings.TrimPrefix(oldFn, "V1")
+ })
if err != nil {
t.Fatal(err)
}
diff --git a/services/analyzers.go b/services/analyzers.go
index 897e4b34e..c2215df2a 100644
--- a/services/analyzers.go
+++ b/services/analyzers.go
@@ -24,6 +24,7 @@ import (
"github.com/cgrates/birpc"
"github.com/cgrates/cgrates/analyzers"
+ v1 "github.com/cgrates/cgrates/apier/v1"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/cores"
"github.com/cgrates/cgrates/engine"
@@ -97,16 +98,14 @@ func (anz *AnalyzerService) start() {
anz.filterSChan <- fS
anz.anz.SetFilterS(fS)
}
- srv, err := engine.NewServiceWithName(anz.anz, utils.AnalyzerS, true)
+ srv, err := engine.NewService(v1.NewAnalyzerSv1(anz.anz))
if err != nil {
utils.Logger.Err(fmt.Sprintf("<%s> failed to initialize service, error: <%s>",
utils.AnalyzerS, err.Error()))
return
}
if !anz.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- anz.server.RpcRegister(s)
- }
+ anz.server.RpcRegister(srv)
}
anz.connChan <- srv
}
diff --git a/services/apierv1.go b/services/apierv1.go
index 626628ae5..74e0960d0 100644
--- a/services/apierv1.go
+++ b/services/apierv1.go
@@ -122,26 +122,20 @@ func (apiService *APIerSv1Service) Start() error {
return err
}
if !apiService.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- apiService.server.RpcRegister(s)
- }
- var legacySrv engine.IntService
- legacySrv, err = engine.NewServiceWithName(apiService.api, utils.ApierV1, true)
- if err != nil {
- return err
- }
+ apiService.server.RpcRegister(srv)
+
//backwards compatible
- for _, s := range legacySrv {
- apiService.server.RpcRegister(s)
- }
- var rplSrv engine.IntService
- rplSrv, err = engine.NewService(v1.NewReplicatorSv1(datadb, apiService.api))
+ legacySrv, err := engine.NewServiceWithName(apiService.api, utils.ApierV1, true)
if err != nil {
return err
}
- for _, s := range rplSrv {
- apiService.server.RpcRegister(s)
+ apiService.server.RpcRegister(legacySrv)
+
+ rplSrv, err := engine.NewService(v1.NewReplicatorSv1(datadb, apiService.api))
+ if err != nil {
+ return err
}
+ apiService.server.RpcRegister(rplSrv)
}
apiService.connChan <- apiService.anz.GetInternalCodec(srv, utils.APIerSv1)
diff --git a/services/apierv2.go b/services/apierv2.go
index 4fe5969de..641524f2c 100644
--- a/services/apierv2.go
+++ b/services/apierv2.go
@@ -73,33 +73,33 @@ func (api *APIerSv2Service) Start() error {
api.api = &v2.APIerSv2{
APIerSv1: *apiV1,
}
- srv, err := engine.NewService(api.api)
+ apiV1Srv, err := engine.NewService(apiV1)
if err != nil {
return err
}
- var apierV1Srv *birpc.Service
- apierV1Srv, err = birpc.NewService(apiV1, "", false)
+ apiV2Srv, err := engine.NewService(api.api)
if err != nil {
return err
}
- engine.RegisterPingMethod(apierV1Srv.Methods)
- srv[utils.APIerSv1] = apierV1Srv
if !api.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- api.server.RpcRegister(s)
- }
- var legacySrv engine.IntService
- legacySrv, err = engine.NewServiceWithName(api.api, utils.ApierV2, true)
+ api.server.RpcRegister(apiV2Srv)
+
+ //backwards compatible
+ legacySrv, err := engine.NewServiceWithName(api.api, utils.ApierV2, true)
if err != nil {
return err
}
- //backwards compatible
- for _, s := range legacySrv {
- api.server.RpcRegister(s)
- }
+ api.server.RpcRegister(legacySrv)
}
- api.connChan <- api.anz.GetInternalCodec(srv, utils.APIerSv2)
+ // The services for both APIerSv1 and APIerSv2 must be grouped together because
+ // only APIerSv2's internal channel is considered for *internal connections.
+ intSrv := engine.IntService{
+ utils.APIerSv1: apiV1Srv,
+ utils.APIerSv2: apiV2Srv,
+ }
+
+ api.connChan <- api.anz.GetInternalCodec(intSrv, utils.APIerSv2)
return nil
}
diff --git a/services/attributes.go b/services/attributes.go
index a9b9f6c87..632eb6bad 100644
--- a/services/attributes.go
+++ b/services/attributes.go
@@ -59,7 +59,6 @@ type AttributeService struct {
server *cores.Server
attrS *engine.AttributeService
- rpc *v1.AttributeSv1 // useful on restart
connChan chan birpc.ClientConnector // publish the internal Subsystem when available
anz *AnalyzerService
srvDep map[string]*sync.WaitGroup
@@ -84,15 +83,12 @@ func (attrS *AttributeService) Start() error {
defer attrS.Unlock()
attrS.attrS = engine.NewAttributeService(datadb, filterS, attrS.cfg)
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.AttributeS))
- attrS.rpc = v1.NewAttributeSv1(attrS.attrS)
- srv, err := engine.NewService(attrS.rpc)
+ srv, err := engine.NewService(v1.NewAttributeSv1(attrS.attrS))
if err != nil {
return err
}
if !attrS.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- attrS.server.RpcRegister(s)
- }
+ attrS.server.RpcRegister(srv)
}
attrS.connChan <- attrS.anz.GetInternalCodec(srv, utils.AttributeS)
return nil
@@ -109,7 +105,6 @@ func (attrS *AttributeService) Shutdown() (err error) {
defer attrS.Unlock()
attrS.attrS.Shutdown()
attrS.attrS = nil
- attrS.rpc = nil
<-attrS.connChan
return
}
diff --git a/services/cdrs.go b/services/cdrs.go
index 7890c9c17..ce1d1219d 100644
--- a/services/cdrs.go
+++ b/services/cdrs.go
@@ -99,23 +99,23 @@ func (cdrService *CDRServer) Start() error {
utils.Logger.Info("Registering CDRS RPC service.")
cdrsV1 := v1.NewCDRsV1(cdrService.cdrS)
- cdrsV2 := &v2.CDRsV2{CDRsV1: *cdrsV1}
- srv, err := engine.NewService(cdrsV1)
+ srvV1, err := engine.NewService(cdrsV1)
if err != nil {
return err
}
- cdrsV2Srv, err := birpc.NewService(cdrsV2, "", false)
+ srvV2, err := engine.NewService(&v2.CDRsV2{CDRsV1: *cdrsV1})
if err != nil {
return err
}
- engine.RegisterPingMethod(cdrsV2Srv.Methods)
- srv[utils.CDRsV2] = cdrsV2Srv
if !cdrService.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- cdrService.server.RpcRegister(s)
- }
+ cdrService.server.RpcRegister(srvV1)
+ cdrService.server.RpcRegister(srvV2)
}
- cdrService.connChan <- cdrService.anz.GetInternalCodec(srv, utils.CDRServer) // Signal that cdrS is operational
+ intSrv := engine.IntService{
+ utils.CDRsV1: srvV1,
+ utils.CDRsV2: srvV2,
+ }
+ cdrService.connChan <- cdrService.anz.GetInternalCodec(intSrv, utils.CDRServer) // Signal that cdrS is operational
return nil
}
diff --git a/services/chargers.go b/services/chargers.go
index 88036c584..11c1a67c7 100644
--- a/services/chargers.go
+++ b/services/chargers.go
@@ -60,7 +60,6 @@ type ChargerService struct {
connMgr *engine.ConnManager
chrS *engine.ChargerService
- rpc *v1.ChargerSv1
connChan chan birpc.ClientConnector
anz *AnalyzerService
srvDep map[string]*sync.WaitGroup
@@ -85,14 +84,12 @@ func (chrS *ChargerService) Start() error {
defer chrS.Unlock()
chrS.chrS = engine.NewChargerService(datadb, filterS, chrS.cfg, chrS.connMgr)
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.ChargerS))
- srv, err := engine.NewServiceWithName(chrS.chrS, utils.ChargerS, true)
+ srv, err := engine.NewService(v1.NewChargerSv1(chrS.chrS))
if err != nil {
return err
}
if !chrS.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- chrS.server.RpcRegister(s)
- }
+ chrS.server.RpcRegister(srv)
}
chrS.connChan <- chrS.anz.GetInternalCodec(srv, utils.ChargerS)
return nil
@@ -109,7 +106,6 @@ func (chrS *ChargerService) Shutdown() (err error) {
defer chrS.Unlock()
chrS.chrS.Shutdown()
chrS.chrS = nil
- chrS.rpc = nil
<-chrS.connChan
return
}
diff --git a/services/cores.go b/services/cores.go
index 8dc88d527..1231c358b 100644
--- a/services/cores.go
+++ b/services/cores.go
@@ -24,6 +24,7 @@ import (
"sync"
"github.com/cgrates/birpc"
+ v1 "github.com/cgrates/cgrates/apier/v1"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/cores"
"github.com/cgrates/cgrates/engine"
@@ -75,14 +76,12 @@ func (cS *CoreService) Start() error {
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.CoreS))
cS.stopChan = make(chan struct{})
cS.cS = cores.NewCoreService(cS.cfg, cS.caps, cS.fileCPU, cS.stopChan, cS.shdWg, cS.shdChan)
- srv, err := engine.NewServiceWithName(cS.cS, utils.CoreS, true)
+ srv, err := engine.NewService(v1.NewCoreSv1(cS.cS))
if err != nil {
return err
}
if !cS.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- cS.server.RpcRegister(s)
- }
+ cS.server.RpcRegister(srv)
}
cS.connChan <- cS.anz.GetInternalCodec(srv, utils.CoreS)
return nil
diff --git a/services/ees.go b/services/ees.go
index 4b48c27d1..a9ead9277 100644
--- a/services/ees.go
+++ b/services/ees.go
@@ -23,6 +23,7 @@ import (
"sync"
"github.com/cgrates/birpc"
+ v1 "github.com/cgrates/cgrates/apier/v1"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/cores"
"github.com/cgrates/cgrates/ees"
@@ -117,14 +118,12 @@ func (es *EventExporterService) Start() error {
return err
}
- srv, err := engine.NewServiceWithName(es.eeS, utils.EeS, true)
+ srv, err := engine.NewService(v1.NewEeSv1(es.eeS))
if err != nil {
return err
}
if !es.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- es.server.RpcRegister(s)
- }
+ es.server.RpcRegister(srv)
}
es.intConnChan <- es.anz.GetInternalCodec(srv, utils.EEs)
return nil
diff --git a/services/loaders.go b/services/loaders.go
index 231bda277..892ba659e 100644
--- a/services/loaders.go
+++ b/services/loaders.go
@@ -22,6 +22,7 @@ import (
"sync"
"github.com/cgrates/birpc"
+ v1 "github.com/cgrates/cgrates/apier/v1"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/cores"
"github.com/cgrates/cgrates/engine"
@@ -88,14 +89,12 @@ func (ldrs *LoaderService) Start() error {
if err := ldrs.ldrs.ListenAndServe(ldrs.stopChan); err != nil {
return err
}
- srv, err := engine.NewServiceWithName(ldrs.ldrs, utils.LoaderS, true)
+ srv, err := engine.NewService(v1.NewLoaderSv1(ldrs.ldrs))
if err != nil {
return err
}
if !ldrs.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- ldrs.server.RpcRegister(s)
- }
+ ldrs.server.RpcRegister(srv)
}
ldrs.connChan <- ldrs.anz.GetInternalCodec(srv, utils.LoaderS)
return nil
diff --git a/services/rals.go b/services/rals.go
index f5c6cf1fa..ffe3d4ed1 100644
--- a/services/rals.go
+++ b/services/rals.go
@@ -92,9 +92,7 @@ func (rals *RalService) Start() error {
return err
}
if !rals.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- rals.server.RpcRegister(s)
- }
+ rals.server.RpcRegister(srv)
}
rals.connChan <- rals.anz.GetInternalCodec(srv, utils.RALService)
diff --git a/services/rankings.go b/services/rankings.go
index db81d57eb..07789c6f7 100644
--- a/services/rankings.go
+++ b/services/rankings.go
@@ -85,9 +85,7 @@ func (rg *RankingService) Start() error {
return err
}
if !rg.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- rg.server.RpcRegister(s)
- }
+ rg.server.RpcRegister(srv)
}
rg.connChan <- rg.anz.GetInternalCodec(srv, utils.StatS)
return nil
diff --git a/services/resources.go b/services/resources.go
index c4ecce863..4ddcde5b8 100644
--- a/services/resources.go
+++ b/services/resources.go
@@ -23,6 +23,7 @@ import (
"sync"
"github.com/cgrates/birpc"
+ v1 "github.com/cgrates/cgrates/apier/v1"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/cores"
"github.com/cgrates/cgrates/engine"
@@ -86,14 +87,12 @@ func (reS *ResourceService) Start() error {
reS.reS = engine.NewResourceService(datadb, reS.cfg, filterS, reS.connMgr)
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.ResourceS))
reS.reS.StartLoop()
- srv, err := engine.NewServiceWithName(reS.reS, utils.ResourceS, true)
+ srv, err := engine.NewService(v1.NewResourceSv1(reS.reS))
if err != nil {
return err
}
if !reS.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- reS.server.RpcRegister(s)
- }
+ reS.server.RpcRegister(srv)
}
reS.connChan <- reS.anz.GetInternalCodec(srv, utils.ResourceS)
return nil
diff --git a/services/responders.go b/services/responders.go
index 83672e01f..c7e43aa89 100644
--- a/services/responders.go
+++ b/services/responders.go
@@ -85,9 +85,7 @@ func (resp *ResponderService) Start() error {
return err
}
if !resp.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- resp.server.RpcRegister(s)
- }
+ resp.server.RpcRegister(srv)
}
resp.connChan <- resp.anz.GetInternalCodec(srv, utils.ResponderS) // Rater done
diff --git a/services/routes.go b/services/routes.go
index a54ca67eb..cf0fcbcf3 100644
--- a/services/routes.go
+++ b/services/routes.go
@@ -23,6 +23,7 @@ import (
"sync"
"github.com/cgrates/birpc"
+ v1 "github.com/cgrates/cgrates/apier/v1"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/cores"
"github.com/cgrates/cgrates/engine"
@@ -85,14 +86,12 @@ func (routeS *RouteService) Start() error {
routeS.routeS = engine.NewRouteService(datadb, filterS, routeS.cfg, routeS.connMgr)
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.RouteS))
- srv, err := engine.NewServiceWithName(routeS.routeS, utils.RouteS, true)
+ srv, err := engine.NewService(v1.NewRouteSv1(routeS.routeS))
if err != nil {
return err
}
if !routeS.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- routeS.server.RpcRegister(s)
- }
+ routeS.server.RpcRegister(srv)
}
routeS.connChan <- routeS.anz.GetInternalCodec(srv, utils.RouteS)
return nil
diff --git a/services/schedulers.go b/services/schedulers.go
index 0dc760ea8..a69fc1673 100644
--- a/services/schedulers.go
+++ b/services/schedulers.go
@@ -59,7 +59,6 @@ type SchedulerService struct {
server *cores.Server
schS *scheduler.Scheduler
- rpc *v1.SchedulerSv1
connChan chan birpc.ClientConnector
connMgr *engine.ConnManager
anz *AnalyzerService
@@ -86,15 +85,12 @@ func (schS *SchedulerService) Start() error {
schS.schS = scheduler.NewScheduler(datadb, schS.cfg, fltrS)
go schS.schS.Loop()
- schS.rpc = v1.NewSchedulerSv1(schS.cfg, datadb, fltrS)
- srv, err := engine.NewService(schS.rpc)
+ srv, err := engine.NewService(v1.NewSchedulerSv1(schS.cfg, datadb, fltrS))
if err != nil {
return err
}
if !schS.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- schS.server.RpcRegister(s)
- }
+ schS.server.RpcRegister(srv)
}
schS.connChan <- schS.anz.GetInternalCodec(srv, utils.SchedulerS)
return nil
@@ -113,7 +109,6 @@ func (schS *SchedulerService) Shutdown() (err error) {
schS.Lock()
schS.schS.Shutdown()
schS.schS = nil
- schS.rpc = nil
<-schS.connChan
schS.Unlock()
return
diff --git a/services/sessions.go b/services/sessions.go
index 449ca9ba7..9afa84777 100644
--- a/services/sessions.go
+++ b/services/sessions.go
@@ -60,7 +60,6 @@ type SessionService struct {
stopChan chan struct{}
sm *sessions.SessionS
- rpc *v1.SMGenericV1
connChan chan birpc.ClientConnector
// in order to stop the bircp server if necesary
@@ -98,34 +97,25 @@ func (smg *SessionService) Start() error {
//start sync session in a separate gorutine
go smg.sm.SyncSessions(smg.stopChan)
// Pass internal connection
- srv, err := engine.NewServiceWithName(v1.NewSessionSv1(smg.sm), "", false)
+ srv, err := engine.NewService(v1.NewSessionSv1(smg.sm))
if err != nil {
return err
}
smg.connChan <- smg.anz.GetInternalCodec(srv, utils.SessionS)
- // Register RPC handler
- smg.rpc = v1.NewSMGenericV1(smg.sm)
-
if !smg.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- smg.server.RpcRegister(s)
- }
+ smg.server.RpcRegister(srv)
- var legacySrv engine.IntService
- legacySrv, err := engine.NewService(smg.rpc)
+ // maintain backwards compatibility
+ legacySrv, err := engine.NewService(v1.NewSMGenericV1(smg.sm))
if err != nil {
return err
}
- for _, s := range legacySrv {
- smg.server.RpcRegister(s)
- }
+ smg.server.RpcRegister(legacySrv)
}
// Register BiRpc handlers
if smg.cfg.SessionSCfg().ListenBijson != "" {
smg.birpcEnabled = true
- for n, s := range srv {
- smg.server.BiRPCRegisterName(n, s)
- }
+ smg.server.BiRPCRegisterName(utils.SessionSv1, srv)
// run this in it's own goroutine
go smg.start()
}
@@ -163,7 +153,6 @@ func (smg *SessionService) Shutdown() (err error) {
smg.birpcEnabled = false
}
smg.sm = nil
- smg.rpc = nil
<-smg.connChan
return
}
diff --git a/services/stats.go b/services/stats.go
index 6caf2aad3..e466d77e3 100644
--- a/services/stats.go
+++ b/services/stats.go
@@ -95,9 +95,7 @@ func (sts *StatService) Start() error {
return err
}
if !sts.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- sts.server.RpcRegister(s)
- }
+ sts.server.RpcRegister(srv)
}
sts.connChan <- sts.anz.GetInternalCodec(srv, utils.StatS)
return nil
diff --git a/services/thresholds.go b/services/thresholds.go
index 909ae1d41..bc1c55dce 100644
--- a/services/thresholds.go
+++ b/services/thresholds.go
@@ -91,9 +91,7 @@ func (thrs *ThresholdService) Start() error {
return err
}
if !thrs.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- thrs.server.RpcRegister(s)
- }
+ thrs.server.RpcRegister(srv)
}
thrs.connChan <- thrs.anz.GetInternalCodec(srv, utils.ThresholdS)
return nil
diff --git a/services/trends.go b/services/trends.go
index 17a7506a1..097f2f2e3 100644
--- a/services/trends.go
+++ b/services/trends.go
@@ -89,9 +89,7 @@ func (trs *TrendService) Start() error {
return err
}
if !trs.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- trs.server.RpcRegister(s)
- }
+ trs.server.RpcRegister(srv)
}
trs.connChan <- trs.anz.GetInternalCodec(srv, utils.StatS)
return nil
diff --git a/servmanager/servmanager.go b/servmanager/servmanager.go
index 8c9040038..8a74b6c9b 100644
--- a/servmanager/servmanager.go
+++ b/servmanager/servmanager.go
@@ -21,15 +21,12 @@ package servmanager
import (
"errors"
"fmt"
- "reflect"
- "strings"
"sync"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
- "github.com/cgrates/rpcclient"
)
// NewServiceManager returns a service manager
@@ -55,33 +52,6 @@ type ServiceManager struct {
connMgr *engine.ConnManager
}
-// Call .
-func (srvMngr *ServiceManager) Call(ctx *context.Context, serviceMethod string, args any, reply any) error {
- parts := strings.Split(serviceMethod, ".")
- if len(parts) != 2 {
- return rpcclient.ErrUnsupporteServiceMethod
- }
- // get method
- method := reflect.ValueOf(srvMngr).MethodByName(parts[0][len(parts[0])-2:] + parts[1]) // Inherit the version in the method
- if !method.IsValid() {
- return rpcclient.ErrUnsupporteServiceMethod
- }
- // construct the params
- params := []reflect.Value{reflect.ValueOf(args), reflect.ValueOf(reply)}
- ret := method.Call(params)
- if len(ret) != 1 {
- return utils.ErrServerError
- }
- if ret[0].Interface() == nil {
- return nil
- }
- err, ok := ret[0].Interface().(error)
- if !ok {
- return utils.ErrServerError
- }
- return err
-}
-
// ArgStartService are passed to Start/StopService/Status RPC methods
type ArgStartService struct {
ServiceID string
diff --git a/utils/coreutils.go b/utils/coreutils.go
index c639da930..e2542f8b6 100644
--- a/utils/coreutils.go
+++ b/utils/coreutils.go
@@ -35,7 +35,6 @@ import (
math_rand "math/rand"
"os"
"path/filepath"
- "reflect"
"regexp"
"slices"
"strconv"
@@ -43,7 +42,6 @@ import (
"sync"
"time"
- "github.com/cgrates/rpcclient"
"golang.org/x/crypto/bcrypt"
)
@@ -835,59 +833,6 @@ func (tID *TenantIDWithAPIOpts) TenantIDConcatenated() string {
return ConcatenatedKey(tID.Tenant, tID.ID)
}
-// RPCCall is a generic method calling RPC on a struct instance
-// serviceMethod is assumed to be in the form InstanceV1.Method
-// where V1Method will become RPC method called on instance
-func RPCCall(inst any, serviceMethod string, args any, reply any) error {
- methodSplit := strings.Split(serviceMethod, ".")
- if len(methodSplit) != 2 {
- return rpcclient.ErrUnsupporteServiceMethod
- }
- method := reflect.ValueOf(inst).MethodByName(
- strings.ToUpper(methodSplit[0][len(methodSplit[0])-2:]) + methodSplit[1])
- if !method.IsValid() {
- return rpcclient.ErrUnsupporteServiceMethod
- }
- params := []reflect.Value{reflect.ValueOf(args), reflect.ValueOf(reply)}
- ret := method.Call(params)
- if len(ret) != 1 {
- return ErrServerError
- }
- if ret[0].Interface() == nil {
- return nil
- }
- err, ok := ret[0].Interface().(error)
- if !ok {
- return ErrServerError
- }
- return err
-}
-
-// ApierRPCCall implements generic RPCCall for APIer instances
-func APIerRPCCall(inst any, serviceMethod string, args any, reply any) error {
- methodSplit := strings.Split(serviceMethod, ".")
- if len(methodSplit) != 2 {
- return rpcclient.ErrUnsupporteServiceMethod
- }
- method := reflect.ValueOf(inst).MethodByName(methodSplit[1])
- if !method.IsValid() {
- return rpcclient.ErrUnsupporteServiceMethod
- }
- params := []reflect.Value{reflect.ValueOf(args), reflect.ValueOf(reply)}
- ret := method.Call(params)
- if len(ret) != 1 {
- return ErrServerError
- }
- if ret[0].Interface() == nil {
- return nil
- }
- err, ok := ret[0].Interface().(error)
- if !ok {
- return ErrServerError
- }
- return err
-}
-
// CachedRPCResponse is used to cache a RPC response
type CachedRPCResponse struct {
Result any
diff --git a/utils/coreutils_test.go b/utils/coreutils_test.go
index bd3f71917..6e857117d 100644
--- a/utils/coreutils_test.go
+++ b/utils/coreutils_test.go
@@ -28,7 +28,6 @@ import (
"golang.org/x/crypto/bcrypt"
- "github.com/cgrates/rpcclient"
"github.com/google/go-cmp/cmp"
)
@@ -1449,30 +1448,6 @@ func (tRPC *TestRPC) V1Error3(args any, reply any) int {
return 0
}
-func TestRPCCall(t *testing.T) {
- if err := RPCCall("wrong", "test", nil, nil); err == nil || err != rpcclient.ErrUnsupporteServiceMethod {
- t.Errorf("Expecting: %+v, received: %+v", rpcclient.ErrUnsupporteServiceMethod, err)
- }
- var reply string
- if err := RPCCall(&TestRPC{}, "TestRPCV1.Copy", StringPointer("test"), &reply); err != nil {
- t.Errorf("Expecting: , received: %+v", err)
- }
- if err := RPCCall(&TestRPC{}, "TestRPCV1.Error", StringPointer("test"), &reply); err == nil || err.Error() != "V1_err_test" {
- t.Errorf("Expecting: , received: <%+v>", err)
- }
- if err := RPCCall(&TestRPC{}, "TestRPCV1.Unexist", StringPointer("test"), &reply); err == nil || err != rpcclient.ErrUnsupporteServiceMethod {
- t.Errorf("Expecting: %+v, received: %+v", rpcclient.ErrUnsupporteServiceMethod, err)
- }
-
- if err := RPCCall(&TestRPC{}, "TestRPCV1.Error2", StringPointer("test"), &reply); err == nil || err != ErrServerError {
- t.Errorf("Expecting: %+v, received: %+v", ErrServerError, err)
- }
-
- if err := RPCCall(&TestRPC{}, "TestRPCV1.Error3", StringPointer("test"), &reply); err == nil || err != ErrServerError {
- t.Errorf("Expecting: %+v, received: %+v", ErrServerError, err)
- }
-}
-
type TestRPC2 struct {
}
@@ -1497,30 +1472,6 @@ func (tRPC *TestRPC2) Error3(args any, reply any) int {
return 0
}
-func TestRPCAPICall(t *testing.T) {
- if err := APIerRPCCall("wrong", "test", nil, nil); err == nil || err != rpcclient.ErrUnsupporteServiceMethod {
- t.Errorf("Expecting: %+v, received: %+v", rpcclient.ErrUnsupporteServiceMethod, err)
- }
- var reply string
- if err := APIerRPCCall(&TestRPC2{}, "TestRPC2.Copy", StringPointer("test"), &reply); err != nil {
- t.Errorf("Expecting: , received: %+v", err)
- }
- if err := APIerRPCCall(&TestRPC2{}, "TestRPC2.Error", StringPointer("test"), &reply); err == nil || err.Error() != "V1_err_test" {
- t.Errorf("Expecting: , received: <%+v>", err)
- }
- if err := APIerRPCCall(&TestRPC2{}, "TestRPC2.Unexist", StringPointer("test"), &reply); err == nil || err != rpcclient.ErrUnsupporteServiceMethod {
- t.Errorf("Expecting: %+v, received: %+v", rpcclient.ErrUnsupporteServiceMethod, err)
- }
-
- if err := APIerRPCCall(&TestRPC2{}, "TestRPC2.Error2", StringPointer("test"), &reply); err == nil || err != ErrServerError {
- t.Errorf("Expecting: %+v, received: %+v", ErrServerError, err)
- }
-
- if err := APIerRPCCall(&TestRPC2{}, "TestRPC2.Error3", StringPointer("test"), &reply); err == nil || err != ErrServerError {
- t.Errorf("Expecting: %+v, received: %+v", ErrServerError, err)
- }
-}
-
func TestCounter(t *testing.T) {
var cmax int64 = 10000
var i int64