From b4fe82c6d73bac267262d7b42a7ebe889157e6b1 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 9 Dec 2019 14:48:29 +0200 Subject: [PATCH] Updated rpcclient library --- agents/astagent.go | 8 +- agents/diamagent.go | 8 +- agents/dnsagent.go | 10 +- agents/fsagent.go | 12 +-- agents/httpagent.go | 4 +- agents/kamagent.go | 8 +- agents/radagent.go | 8 +- apier/v1/analyzer.go | 2 +- apier/v1/apier.go | 18 ++-- apier/v1/attributes.go | 2 +- apier/v1/caches.go | 2 +- apier/v1/chargers.go | 2 +- apier/v1/config.go | 2 +- apier/v1/core.go | 2 +- apier/v1/guardian.go | 2 +- apier/v1/loaders.go | 2 +- apier/v1/rals.go | 2 +- apier/v1/replicator.go | 2 +- apier/v1/resourcesv1.go | 2 +- apier/v1/schedulers.go | 2 +- apier/v1/servicemanager.go | 2 +- apier/v1/sessions.go | 2 +- apier/v1/stats.go | 2 +- apier/v1/suppliers.go | 2 +- apier/v1/thresholds.go | 2 +- apier/v1/tpaccountactions_it_test.go | 2 +- apier/v1/tpactionplans_it_test.go | 2 +- apier/v1/tpactions_it_test.go | 2 +- apier/v1/tpactiontriggers_it_test.go | 2 +- apier/v1/tpattributes_it_test.go | 2 +- apier/v1/tpchargers_it_test.go | 2 +- apier/v1/tpdestinationrates_it_test.go | 2 +- apier/v1/tpdestinations_it_test.go | 2 +- apier/v1/tpdispatchers_it_test.go | 2 +- apier/v1/tpfilters_it_test.go | 2 +- apier/v1/tprates_it_test.go | 2 +- apier/v1/tpratingplans_it_test.go | 2 +- apier/v1/tpratingprofiles_it_test.go | 2 +- apier/v1/tpresources_it_test.go | 2 +- apier/v1/tpsharedgroups_it_test.go | 2 +- apier/v1/tpstats_it_test.go | 2 +- apier/v1/tpsuppliers_it_test.go | 2 +- apier/v1/tpthresholds_it_test.go | 2 +- apier/v1/tptimings_it_test.go | 2 +- apier/v2/apier.go | 2 +- cdrc/cdrc.go | 4 +- cdrc/csv.go | 2 +- cdrc/partial_cdr.go | 4 +- cmd/cgr-console/cgr-console.go | 6 +- cmd/cgr-engine/cgr-engine.go | 42 ++++----- cmd/cgr-loader/cgr-loader.go | 18 ++-- cmd/cgr-tester/cdr_repl/process_cdr.go | 6 +- cmd/cgr-tester/cgr-tester.go | 4 +- cmd/cgr-tester/filereader.go | 4 +- config/config.go | 6 +- config/config_it_test.go | 4 +- config/config_json_test.go | 2 +- config/config_test.go | 6 +- dispatchers/dispatchers.go | 6 +- engine/action.go | 6 +- engine/calldesc.go | 12 +-- engine/cdre.go | 4 +- engine/cdrs.go | 24 ++--- engine/chargers.go | 6 +- engine/connmanager.go | 12 +-- engine/datamanager.go | 8 +- engine/dispatcherprfl.go | 2 +- engine/filters.go | 16 ++-- engine/libengine.go | 34 +++---- engine/libtest.go | 4 +- engine/resources.go | 8 +- engine/stats.go | 8 +- engine/suppliers.go | 14 +-- engine/tpreader.go | 12 +-- general_tests/cdrs_onlexp_it_test.go | 10 +- general_tests/dest_management_it_test.go | 2 +- general_tests/oldtutorial_it_test.go | 4 +- general_tests/rpcclient_it_test.go | 26 +++--- general_tests/tls_it_test.go | 18 ++-- general_tests/tutorial_calls_test.go | 2 +- go.mod | 2 +- go.sum | 2 + loaders/loader.go | 8 +- loaders/loaders.go | 4 +- services/analyzers.go | 6 +- services/apierv1.go | 20 ++-- services/apierv2.go | 6 +- services/asteriskagent.go | 12 +-- services/attributes.go | 6 +- services/attributes_it_test.go | 2 +- services/cdrs.go | 22 ++--- services/cdrs_it_test.go | 8 +- services/chargers.go | 16 ++-- services/chargers_it_test.go | 2 +- services/connmanager.go | 4 +- services/datadb.go | 8 +- services/datadb_it_test.go | 2 +- services/diameteragent.go | 12 +-- services/dispatchers.go | 12 +-- services/dispatchers_it_test.go | 4 +- services/dnsagent.go | 12 +-- services/dnsagent_it_test.go | 4 +- services/ers.go | 2 +- services/ers_it_test.go | 2 +- services/freeswitchagent.go | 12 +-- services/httpagent.go | 10 +- services/kamailioagent.go | 12 +-- services/loaders.go | 12 +-- services/radiusagent.go | 12 +-- services/rals.go | 8 +- services/rals_it_test.go | 6 +- services/resources.go | 16 ++-- services/responders.go | 18 ++-- services/schedulers.go | 12 +-- services/schedulers_it_test.go | 2 +- services/sessions.go | 28 +++--- services/sessions_it_test.go | 10 +- services/stats.go | 16 ++-- services/stordb.go | 2 +- services/suppliers.go | 20 ++-- services/thresholds.go | 6 +- services/utils.go | 6 +- servmanager/servmanager.go | 2 +- sessions/sessions.go | 114 +++++++++++------------ sessions/sessions_bench_test.go | 6 +- sessions/sessions_test.go | 4 +- utils/birpcint_client.go | 12 +-- utils/birpcint_client_test.go | 4 +- utils/consts.go | 1 - utils/server.go | 10 +- 130 files changed, 519 insertions(+), 516 deletions(-) diff --git a/agents/astagent.go b/agents/astagent.go index 0177f80d2..2903a963d 100644 --- a/agents/astagent.go +++ b/agents/astagent.go @@ -54,7 +54,7 @@ const ( ) func NewAsteriskAgent(cgrCfg *config.CGRConfig, astConnIdx int, - smgConn rpcclient.RpcClientConnection) (*AsteriskAgent, error) { + smgConn rpcclient.ClientConnector) (*AsteriskAgent, error) { sma := &AsteriskAgent{ cgrCfg: cgrCfg, astConnIdx: astConnIdx, @@ -67,7 +67,7 @@ func NewAsteriskAgent(cgrCfg *config.CGRConfig, astConnIdx int, type AsteriskAgent struct { cgrCfg *config.CGRConfig // Separate from smCfg since there can be multiple astConnIdx int - smg rpcclient.RpcClientConnection + smg rpcclient.ClientConnector astConn *aringo.ARInGO astEvChan chan map[string]interface{} astErrChan chan error @@ -329,7 +329,7 @@ func (sma *AsteriskAgent) V1DisconnectSession(args utils.AttrDisconnectSession, return nil } -// rpcclient.RpcClientConnection interface +// rpcclient.ClientConnector interface func (sma *AsteriskAgent) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.RPCCall(sma, serviceMethod, args, reply) } @@ -360,6 +360,6 @@ func (sma *AsteriskAgent) V1GetActiveSessionIDs(ignParam string, // SetSessionSConnection sets the new connection to the session service // only used on reload -func (sma *AsteriskAgent) SetSessionSConnection(sS rpcclient.RpcClientConnection) { +func (sma *AsteriskAgent) SetSessionSConnection(sS rpcclient.ClientConnector) { sma.smg = sS } diff --git a/agents/diamagent.go b/agents/diamagent.go index 6a88afd04..36dfef052 100644 --- a/agents/diamagent.go +++ b/agents/diamagent.go @@ -36,7 +36,7 @@ import ( ) func NewDiameterAgent(cgrCfg *config.CGRConfig, filterS *engine.FilterS, - sS rpcclient.RpcClientConnection) (*DiameterAgent, error) { + sS rpcclient.ClientConnector) (*DiameterAgent, error) { if sS != nil && reflect.ValueOf(sS).IsNil() { sS = nil } @@ -67,7 +67,7 @@ func NewDiameterAgent(cgrCfg *config.CGRConfig, filterS *engine.FilterS, type DiameterAgent struct { cgrCfg *config.CGRConfig filterS *engine.FilterS - sS rpcclient.RpcClientConnection // Connection towards CGR-SessionS component + sS rpcclient.ClientConnector // Connection towards CGR-SessionS component aReqs int aReqsLck sync.RWMutex } @@ -428,7 +428,7 @@ func (da *DiameterAgent) processRequest(reqProcessor *config.RequestProcessor, return true, nil } -// rpcclient.RpcClientConnection interface +// rpcclient.ClientConnector interface func (da *DiameterAgent) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.RPCCall(da, serviceMethod, args, reply) } @@ -487,6 +487,6 @@ func (da *DiameterAgent) V1GetActiveSessionIDs(ignParam string, // SetSessionSConnection sets the new connection to the session service // only used on reload -func (da *DiameterAgent) SetSessionSConnection(sS rpcclient.RpcClientConnection) { +func (da *DiameterAgent) SetSessionSConnection(sS rpcclient.ClientConnector) { da.sS = sS } diff --git a/agents/dnsagent.go b/agents/dnsagent.go index 0e13fb72e..5bd713dbd 100644 --- a/agents/dnsagent.go +++ b/agents/dnsagent.go @@ -33,7 +33,7 @@ import ( // NewDNSAgent is the constructor for DNSAgent func NewDNSAgent(cgrCfg *config.CGRConfig, fltrS *engine.FilterS, - sS rpcclient.RpcClientConnection) (da *DNSAgent, err error) { + sS rpcclient.ClientConnector) (da *DNSAgent, err error) { da = &DNSAgent{cgrCfg: cgrCfg, fltrS: fltrS, sS: sS} err = da.initDNSServer() return @@ -41,9 +41,9 @@ func NewDNSAgent(cgrCfg *config.CGRConfig, fltrS *engine.FilterS, // DNSAgent translates DNS requests towards CGRateS infrastructure type DNSAgent struct { - cgrCfg *config.CGRConfig // loaded CGRateS configuration - fltrS *engine.FilterS // connection towards FilterS - sS rpcclient.RpcClientConnection // connection towards CGR-SessionS component + cgrCfg *config.CGRConfig // loaded CGRateS configuration + fltrS *engine.FilterS // connection towards FilterS + sS rpcclient.ClientConnector // connection towards CGR-SessionS component server *dns.Server } @@ -90,7 +90,7 @@ func (da *DNSAgent) Reload() (err error) { // SetSessionSConnection sets the new connection to the threshold service // only used on reload -func (da *DNSAgent) SetSessionSConnection(sS rpcclient.RpcClientConnection) { +func (da *DNSAgent) SetSessionSConnection(sS rpcclient.ClientConnector) { da.sS = sS } diff --git a/agents/fsagent.go b/agents/fsagent.go index 1923704e4..1e6272f93 100644 --- a/agents/fsagent.go +++ b/agents/fsagent.go @@ -34,7 +34,7 @@ import ( ) func NewFSsessions(fsAgentConfig *config.FsAgentCfg, - sS rpcclient.RpcClientConnection, timezone string) (fsa *FSsessions) { + sS rpcclient.ClientConnector, timezone string) (fsa *FSsessions) { if sS != nil && reflect.ValueOf(sS).IsNil() { sS = nil } @@ -52,9 +52,9 @@ func NewFSsessions(fsAgentConfig *config.FsAgentCfg, // and the active sessions type FSsessions struct { cfg *config.FsAgentCfg - conns []*fsock.FSock // Keep the list here for connection management purposes - senderPools []*fsock.FSockPool // Keep sender pools here - sS rpcclient.RpcClientConnection // Connection towards CGR-SessionS component + conns []*fsock.FSock // Keep the list here for connection management purposes + senderPools []*fsock.FSockPool // Keep sender pools here + sS rpcclient.ClientConnector // Connection towards CGR-SessionS component timezone string } @@ -379,7 +379,7 @@ func (sm *FSsessions) Shutdown() (err error) { return } -// rpcclient.RpcClientConnection interface +// rpcclient.ClientConnector interface func (sm *FSsessions) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.RPCCall(sm, serviceMethod, args, reply) } @@ -440,7 +440,7 @@ func (fsa *FSsessions) V1GetActiveSessionIDs(ignParam string, // SetSessionSConnection sets the new connection to the session service // only used on reload -func (sm *FSsessions) SetSessionSConnection(sS rpcclient.RpcClientConnection) { +func (sm *FSsessions) SetSessionSConnection(sS rpcclient.ClientConnector) { sm.sS = sS } diff --git a/agents/httpagent.go b/agents/httpagent.go index 21be828b6..86f98eed9 100644 --- a/agents/httpagent.go +++ b/agents/httpagent.go @@ -30,7 +30,7 @@ import ( ) // NewHttpAgent will construct a HTTPAgent -func NewHTTPAgent(sessionS rpcclient.RpcClientConnection, +func NewHTTPAgent(sessionS rpcclient.ClientConnector, filterS *engine.FilterS, dfltTenant, reqPayload, rplyPayload string, reqProcessors []*config.RequestProcessor) *HTTPAgent { return &HTTPAgent{sessionS: sessionS, filterS: filterS, @@ -41,7 +41,7 @@ func NewHTTPAgent(sessionS rpcclient.RpcClientConnection, // HTTPAgent is a handler for HTTP requests type HTTPAgent struct { - sessionS rpcclient.RpcClientConnection + sessionS rpcclient.ClientConnector filterS *engine.FilterS dfltTenant, reqPayload, diff --git a/agents/kamagent.go b/agents/kamagent.go index a5c32703b..cba0d3a94 100644 --- a/agents/kamagent.go +++ b/agents/kamagent.go @@ -44,7 +44,7 @@ var ( ) func NewKamailioAgent(kaCfg *config.KamAgentCfg, - sessionS rpcclient.RpcClientConnection, timezone string) (ka *KamailioAgent) { + sessionS rpcclient.ClientConnector, timezone string) (ka *KamailioAgent) { ka = &KamailioAgent{ cfg: kaCfg, sessionS: sessionS, @@ -57,7 +57,7 @@ func NewKamailioAgent(kaCfg *config.KamAgentCfg, type KamailioAgent struct { cfg *config.KamAgentCfg - sessionS rpcclient.RpcClientConnection + sessionS rpcclient.ClientConnector timezone string conns []*kamevapi.KamEvapi activeSessionIDs chan []*sessions.SessionID @@ -99,7 +99,7 @@ func (self *KamailioAgent) Shutdown() (err error) { return } -// rpcclient.RpcClientConnection interface +// rpcclient.ClientConnector interface func (ka *KamailioAgent) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.RPCCall(ka, serviceMethod, args, reply) } @@ -419,7 +419,7 @@ func (ka *KamailioAgent) V1GetActiveSessionIDs(ignParam string, sessionIDs *[]*s // SetSessionSConnection sets the new connection to the session service // only used on reload -func (ka *KamailioAgent) SetSessionSConnection(sS rpcclient.RpcClientConnection) { +func (ka *KamailioAgent) SetSessionSConnection(sS rpcclient.ClientConnector) { ka.sessionS = sS } diff --git a/agents/radagent.go b/agents/radagent.go index 0fbd2c94c..04c408bbf 100644 --- a/agents/radagent.go +++ b/agents/radagent.go @@ -37,7 +37,7 @@ const ( ) func NewRadiusAgent(cgrCfg *config.CGRConfig, filterS *engine.FilterS, - sessionS rpcclient.RpcClientConnection) (ra *RadiusAgent, err error) { + sessionS rpcclient.ClientConnector) (ra *RadiusAgent, err error) { dts := make(map[string]*radigo.Dictionary, len(cgrCfg.RadiusAgentCfg().ClientDictionaries)) for clntID, dictPath := range cgrCfg.RadiusAgentCfg().ClientDictionaries { utils.Logger.Info( @@ -62,8 +62,8 @@ func NewRadiusAgent(cgrCfg *config.CGRConfig, filterS *engine.FilterS, } type RadiusAgent struct { - cgrCfg *config.CGRConfig // reference for future config reloads - sessionS rpcclient.RpcClientConnection // Connection towards CGR-SessionS component + cgrCfg *config.CGRConfig // reference for future config reloads + sessionS rpcclient.ClientConnector // Connection towards CGR-SessionS component filterS *engine.FilterS rsAuth *radigo.Server rsAcct *radigo.Server @@ -346,6 +346,6 @@ func (ra *RadiusAgent) ListenAndServe() (err error) { // SetSessionSConnection sets the new connection to the session service // only used on reload -func (ra *RadiusAgent) SetSessionSConnection(sS rpcclient.RpcClientConnection) { +func (ra *RadiusAgent) SetSessionSConnection(sS rpcclient.ClientConnector) { ra.sessionS = sS } diff --git a/apier/v1/analyzer.go b/apier/v1/analyzer.go index 29d8060b4..0d4fed736 100755 --- a/apier/v1/analyzer.go +++ b/apier/v1/analyzer.go @@ -33,7 +33,7 @@ type AnalyzerSv1 struct { aS *analyzers.AnalyzerService } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (aSv1 *AnalyzerSv1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(aSv1, serviceMethod, args, reply) diff --git a/apier/v1/apier.go b/apier/v1/apier.go index 58edc20a5..fd0c3ce4f 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -47,16 +47,16 @@ type ApierV1 struct { DataManager *engine.DataManager Config *config.CGRConfig Responder *engine.Responder - CDRs rpcclient.RpcClientConnection // FixMe: populate it from cgr-engine - SchedulerService SchedulerGeter // Need to have them capitalize so we can export in V2 + CDRs rpcclient.ClientConnector // FixMe: populate it from cgr-engine + SchedulerService SchedulerGeter // Need to have them capitalize so we can export in V2 HTTPPoster *engine.HTTPPoster FilterS *engine.FilterS //Used for CDR Exporter - CacheS rpcclient.RpcClientConnection - SchedulerS rpcclient.RpcClientConnection - AttributeS rpcclient.RpcClientConnection + CacheS rpcclient.ClientConnector + SchedulerS rpcclient.ClientConnector + AttributeS rpcclient.ClientConnector } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (apiv1 *ApierV1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(apiv1, serviceMethod, args, reply) @@ -1375,19 +1375,19 @@ func (apiv1 *ApierV1) GetRatingPlanIDs(args utils.TenantArgWithPaginator, attrPr // SetAttributeSConnection sets the new connection to the attribute service // only used on reload -func (apiv1 *ApierV1) SetAttributeSConnection(attrS rpcclient.RpcClientConnection) { +func (apiv1 *ApierV1) SetAttributeSConnection(attrS rpcclient.ClientConnector) { apiv1.AttributeS = attrS } // SetCacheSConnection sets the new connection to the cache service // only used on reload -func (apiv1 *ApierV1) SetCacheSConnection(chS rpcclient.RpcClientConnection) { +func (apiv1 *ApierV1) SetCacheSConnection(chS rpcclient.ClientConnector) { apiv1.CacheS = chS } // SetSchedulerSConnection sets the new connection to the scheduler service // only used on reload -func (apiv1 *ApierV1) SetSchedulerSConnection(schS rpcclient.RpcClientConnection) { +func (apiv1 *ApierV1) SetSchedulerSConnection(schS rpcclient.ClientConnector) { apiv1.SchedulerS = schS } diff --git a/apier/v1/attributes.go b/apier/v1/attributes.go index 00eb64405..cca6ce585 100644 --- a/apier/v1/attributes.go +++ b/apier/v1/attributes.go @@ -136,7 +136,7 @@ type AttributeSv1 struct { attrS *engine.AttributeService } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (alSv1 *AttributeSv1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(alSv1, serviceMethod, args, reply) diff --git a/apier/v1/caches.go b/apier/v1/caches.go index 4a6033094..48e74fa1f 100644 --- a/apier/v1/caches.go +++ b/apier/v1/caches.go @@ -115,7 +115,7 @@ func (chSv1 *CacheSv1) Ping(ign *utils.CGREventWithArgDispatcher, reply *string) return nil } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (chSv1 *CacheSv1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(chSv1, serviceMethod, args, reply) diff --git a/apier/v1/chargers.go b/apier/v1/chargers.go index 38a9c40d2..7a5d3d204 100644 --- a/apier/v1/chargers.go +++ b/apier/v1/chargers.go @@ -122,7 +122,7 @@ type ChargerSv1 struct { cS *engine.ChargerService } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (cSv1 *ChargerSv1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(cSv1, serviceMethod, args, reply) diff --git a/apier/v1/config.go b/apier/v1/config.go index 50ee41d33..f7b0c4421 100644 --- a/apier/v1/config.go +++ b/apier/v1/config.go @@ -40,7 +40,7 @@ func (cSv1 *ConfigSv1) ReloadConfig(args *config.ConfigReloadWithArgDispatcher, return cSv1.cfg.V1ReloadConfig(args, reply) } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (cSv1 *ConfigSv1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(cSv1, serviceMethod, args, reply) diff --git a/apier/v1/core.go b/apier/v1/core.go index fc788efe0..b9dba1b8e 100644 --- a/apier/v1/core.go +++ b/apier/v1/core.go @@ -32,7 +32,7 @@ type CoreSv1 struct { cS *engine.CoreService } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (cS *CoreSv1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(cS, serviceMethod, args, reply) diff --git a/apier/v1/guardian.go b/apier/v1/guardian.go index 4f7ffa29d..9404372f6 100644 --- a/apier/v1/guardian.go +++ b/apier/v1/guardian.go @@ -48,7 +48,7 @@ func (self *GuardianSv1) Ping(ign *utils.CGREventWithArgDispatcher, reply *strin return nil } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (self *GuardianSv1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(self, serviceMethod, args, reply) diff --git a/apier/v1/loaders.go b/apier/v1/loaders.go index 71b70140b..e3380d121 100644 --- a/apier/v1/loaders.go +++ b/apier/v1/loaders.go @@ -32,7 +32,7 @@ type LoaderSv1 struct { ldrS *loaders.LoaderService } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (ldrSv1 *LoaderSv1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(ldrSv1, serviceMethod, args, reply) diff --git a/apier/v1/rals.go b/apier/v1/rals.go index 79d13a00c..1dc334afe 100644 --- a/apier/v1/rals.go +++ b/apier/v1/rals.go @@ -33,7 +33,7 @@ func NewRALsV1() *RALsV1 { type RALsV1 struct { } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (rsv1 *RALsV1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(rsv1, serviceMethod, args, reply) } diff --git a/apier/v1/replicator.go b/apier/v1/replicator.go index e167d866e..c0ee40659 100644 --- a/apier/v1/replicator.go +++ b/apier/v1/replicator.go @@ -32,7 +32,7 @@ type ReplicatorSv1 struct { dm *engine.DataManager } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (rplSv1 *ReplicatorSv1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(rplSv1, serviceMethod, args, reply) } diff --git a/apier/v1/resourcesv1.go b/apier/v1/resourcesv1.go index 81843e9a1..6e2c3a01c 100644 --- a/apier/v1/resourcesv1.go +++ b/apier/v1/resourcesv1.go @@ -34,7 +34,7 @@ type ResourceSv1 struct { rls *engine.ResourceService } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (rsv1 *ResourceSv1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(rsv1, serviceMethod, args, reply) } diff --git a/apier/v1/schedulers.go b/apier/v1/schedulers.go index f31cf3b34..4a60e3e1e 100644 --- a/apier/v1/schedulers.go +++ b/apier/v1/schedulers.go @@ -46,7 +46,7 @@ func (schdSv1 *SchedulerSv1) Ping(ign *utils.CGREventWithArgDispatcher, reply *s return nil } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (schdSv1 *SchedulerSv1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(schdSv1, serviceMethod, args, reply) diff --git a/apier/v1/servicemanager.go b/apier/v1/servicemanager.go index 3bd3d7081..88fd3e3a6 100644 --- a/apier/v1/servicemanager.go +++ b/apier/v1/servicemanager.go @@ -50,7 +50,7 @@ func (servManager *ServiceManagerV1) Ping(ign *utils.CGREventWithArgDispatcher, return nil } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (servManager *ServiceManagerV1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(servManager, serviceMethod, args, reply) diff --git a/apier/v1/sessions.go b/apier/v1/sessions.go index db2ffb171..f5124f085 100644 --- a/apier/v1/sessions.go +++ b/apier/v1/sessions.go @@ -130,7 +130,7 @@ func (ssv1 *SessionSv1) DeactivateSessions(args []string, reply *string) error { return ssv1.Ss.BiRPCv1DeactivateSessions(nil, args, reply) } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (ssv1 *SessionSv1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(ssv1, serviceMethod, args, reply) diff --git a/apier/v1/stats.go b/apier/v1/stats.go index 430cf3327..b3da9707a 100644 --- a/apier/v1/stats.go +++ b/apier/v1/stats.go @@ -163,7 +163,7 @@ type StatSv1 struct { sS *engine.StatService } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (stsv1 *StatSv1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(stsv1, serviceMethod, args, reply) } diff --git a/apier/v1/suppliers.go b/apier/v1/suppliers.go index 9102e7127..6514e0a4b 100644 --- a/apier/v1/suppliers.go +++ b/apier/v1/suppliers.go @@ -121,7 +121,7 @@ type SupplierSv1 struct { splS *engine.SupplierService } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (splv1 *SupplierSv1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(splv1, serviceMethod, args, reply) diff --git a/apier/v1/thresholds.go b/apier/v1/thresholds.go index 896c6ee07..03bd7021d 100644 --- a/apier/v1/thresholds.go +++ b/apier/v1/thresholds.go @@ -35,7 +35,7 @@ type ThresholdSv1 struct { tS *engine.ThresholdService } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (tSv1 *ThresholdSv1) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(tSv1, serviceMethod, args, reply) } diff --git a/apier/v1/tpaccountactions_it_test.go b/apier/v1/tpaccountactions_it_test.go index 8d1715592..b31fca107 100644 --- a/apier/v1/tpaccountactions_it_test.go +++ b/apier/v1/tpaccountactions_it_test.go @@ -120,7 +120,7 @@ func testTPAccActionsStartEngine(t *testing.T) { // Connect rpc client to rater func testTPAccActionsRpcConn(t *testing.T) { var err error - tpAccActionsRPC, err = jsonrpc.Dial("tcp", tpAccActionsCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpAccActionsRPC, err = jsonrpc.Dial(utils.TCP, tpAccActionsCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpactionplans_it_test.go b/apier/v1/tpactionplans_it_test.go index b28089bf5..1660bfbb7 100644 --- a/apier/v1/tpactionplans_it_test.go +++ b/apier/v1/tpactionplans_it_test.go @@ -122,7 +122,7 @@ func testTPAccPlansStartEngine(t *testing.T) { // Connect rpc client to rater func testTPAccPlansRpcConn(t *testing.T) { var err error - tpAccPlansRPC, err = jsonrpc.Dial("tcp", tpAccPlansCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpAccPlansRPC, err = jsonrpc.Dial(utils.TCP, tpAccPlansCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpactions_it_test.go b/apier/v1/tpactions_it_test.go index 934f2cd00..dc8640480 100644 --- a/apier/v1/tpactions_it_test.go +++ b/apier/v1/tpactions_it_test.go @@ -122,7 +122,7 @@ func testTPActionsStartEngine(t *testing.T) { // Connect rpc client to rater func testTPActionsRpcConn(t *testing.T) { var err error - tpActionRPC, err = jsonrpc.Dial("tcp", tpActionCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpActionRPC, err = jsonrpc.Dial(utils.TCP, tpActionCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpactiontriggers_it_test.go b/apier/v1/tpactiontriggers_it_test.go index 24745f582..2a571b6d0 100644 --- a/apier/v1/tpactiontriggers_it_test.go +++ b/apier/v1/tpactiontriggers_it_test.go @@ -122,7 +122,7 @@ func testTPActionTriggersStartEngine(t *testing.T) { // Connect rpc client to rater func testTPActionTriggersRpcConn(t *testing.T) { var err error - tpActionTriggerRPC, err = jsonrpc.Dial("tcp", tpActionTriggerCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpActionTriggerRPC, err = jsonrpc.Dial(utils.TCP, tpActionTriggerCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpattributes_it_test.go b/apier/v1/tpattributes_it_test.go index a320a3191..8c42b1740 100644 --- a/apier/v1/tpattributes_it_test.go +++ b/apier/v1/tpattributes_it_test.go @@ -111,7 +111,7 @@ func testTPAlsPrfStartEngine(t *testing.T) { // Connect rpc client to rater func testTPAlsPrfRPCConn(t *testing.T) { var err error - tpAlsPrfRPC, err = jsonrpc.Dial("tcp", tpAlsPrfCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpAlsPrfRPC, err = jsonrpc.Dial(utils.TCP, tpAlsPrfCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpchargers_it_test.go b/apier/v1/tpchargers_it_test.go index 5d8a8cbf4..ad8c82abf 100644 --- a/apier/v1/tpchargers_it_test.go +++ b/apier/v1/tpchargers_it_test.go @@ -111,7 +111,7 @@ func testTPChrgsStartEngine(t *testing.T) { // Connect rpc client to rater func testTPChrgsRPCConn(t *testing.T) { var err error - tpChrgsRPC, err = jsonrpc.Dial("tcp", tpChrgsCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpChrgsRPC, err = jsonrpc.Dial(utils.TCP, tpChrgsCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpdestinationrates_it_test.go b/apier/v1/tpdestinationrates_it_test.go index b3afc73b1..727d23d17 100644 --- a/apier/v1/tpdestinationrates_it_test.go +++ b/apier/v1/tpdestinationrates_it_test.go @@ -116,7 +116,7 @@ func testTPDstRateStartEngine(t *testing.T) { // Connect rpc client to rater func testTPDstRateRpcConn(t *testing.T) { var err error - tpDstRateRPC, err = jsonrpc.Dial("tcp", tpDstRateCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpDstRateRPC, err = jsonrpc.Dial(utils.TCP, tpDstRateCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpdestinations_it_test.go b/apier/v1/tpdestinations_it_test.go index 21d20cdc5..1bd213698 100644 --- a/apier/v1/tpdestinations_it_test.go +++ b/apier/v1/tpdestinations_it_test.go @@ -121,7 +121,7 @@ func testTPDestinationsStartEngine(t *testing.T) { // Connect rpc client to rater func testTPDestinationsRpcConn(t *testing.T) { var err error - tpDestinationRPC, err = jsonrpc.Dial("tcp", tpDestinationCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpDestinationRPC, err = jsonrpc.Dial(utils.TCP, tpDestinationCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpdispatchers_it_test.go b/apier/v1/tpdispatchers_it_test.go index 0c0a5fbb7..c1fbe9cd0 100644 --- a/apier/v1/tpdispatchers_it_test.go +++ b/apier/v1/tpdispatchers_it_test.go @@ -110,7 +110,7 @@ func testTPDispatcherStartEngine(t *testing.T) { // Connect rpc client to rater func testTPDispatcherRpcConn(t *testing.T) { var err error - tpDispatcherRPC, err = jsonrpc.Dial("tcp", tpDispatcherCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpDispatcherRPC, err = jsonrpc.Dial(utils.TCP, tpDispatcherCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpfilters_it_test.go b/apier/v1/tpfilters_it_test.go index 42910c732..2bea05161 100644 --- a/apier/v1/tpfilters_it_test.go +++ b/apier/v1/tpfilters_it_test.go @@ -119,7 +119,7 @@ func testTPFilterStartEngine(t *testing.T) { // Connect rpc client to rater func testTPFilterRpcConn(t *testing.T) { var err error - tpFilterRPC, err = jsonrpc.Dial("tcp", tpFilterCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpFilterRPC, err = jsonrpc.Dial(utils.TCP, tpFilterCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tprates_it_test.go b/apier/v1/tprates_it_test.go index 127ce7986..ab158bf54 100644 --- a/apier/v1/tprates_it_test.go +++ b/apier/v1/tprates_it_test.go @@ -121,7 +121,7 @@ func testTPRatesStartEngine(t *testing.T) { // Connect rpc client to rater func testTPRatesRpcConn(t *testing.T) { var err error - tpRateRPC, err = jsonrpc.Dial("tcp", tpRateCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpRateRPC, err = jsonrpc.Dial(utils.TCP, tpRateCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpratingplans_it_test.go b/apier/v1/tpratingplans_it_test.go index 4dd692a68..42e79514e 100644 --- a/apier/v1/tpratingplans_it_test.go +++ b/apier/v1/tpratingplans_it_test.go @@ -121,7 +121,7 @@ func testTPRatingPlansStartEngine(t *testing.T) { // Connect rpc client to rater func testTPRatingPlansRpcConn(t *testing.T) { var err error - tpRatingPlanRPC, err = jsonrpc.Dial("tcp", tpRatingPlanCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpRatingPlanRPC, err = jsonrpc.Dial(utils.TCP, tpRatingPlanCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpratingprofiles_it_test.go b/apier/v1/tpratingprofiles_it_test.go index 8bfda30ed..15d310cef 100644 --- a/apier/v1/tpratingprofiles_it_test.go +++ b/apier/v1/tpratingprofiles_it_test.go @@ -125,7 +125,7 @@ func testTPRatingProfilesStartEngine(t *testing.T) { // Connect rpc client to rater func testTPRatingProfilesRpcConn(t *testing.T) { var err error - tpRatingProfileRPC, err = jsonrpc.Dial("tcp", tpRatingProfileCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpRatingProfileRPC, err = jsonrpc.Dial(utils.TCP, tpRatingProfileCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpresources_it_test.go b/apier/v1/tpresources_it_test.go index f7c50b151..b36a41065 100644 --- a/apier/v1/tpresources_it_test.go +++ b/apier/v1/tpresources_it_test.go @@ -116,7 +116,7 @@ func testTPResStartEngine(t *testing.T) { // Connect rpc client to rater func testTPResRpcConn(t *testing.T) { var err error - tpResRPC, err = jsonrpc.Dial("tcp", tpResCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpResRPC, err = jsonrpc.Dial(utils.TCP, tpResCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpsharedgroups_it_test.go b/apier/v1/tpsharedgroups_it_test.go index 72e95c4e2..9adaf1cb5 100644 --- a/apier/v1/tpsharedgroups_it_test.go +++ b/apier/v1/tpsharedgroups_it_test.go @@ -121,7 +121,7 @@ func testTPSharedGroupsStartEngine(t *testing.T) { // Connect rpc client to rater func testTPSharedGroupsRpcConn(t *testing.T) { var err error - tpSharedGroupRPC, err = jsonrpc.Dial("tcp", tpSharedGroupCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpSharedGroupRPC, err = jsonrpc.Dial(utils.TCP, tpSharedGroupCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpstats_it_test.go b/apier/v1/tpstats_it_test.go index 128f9b6d2..7e02cdc89 100644 --- a/apier/v1/tpstats_it_test.go +++ b/apier/v1/tpstats_it_test.go @@ -117,7 +117,7 @@ func testTPStatsStartEngine(t *testing.T) { // Connect rpc client to rater func testTPStatsRpcConn(t *testing.T) { var err error - tpStatRPC, err = jsonrpc.Dial("tcp", tpStatCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpStatRPC, err = jsonrpc.Dial(utils.TCP, tpStatCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpsuppliers_it_test.go b/apier/v1/tpsuppliers_it_test.go index 96390355a..50f69f8ee 100644 --- a/apier/v1/tpsuppliers_it_test.go +++ b/apier/v1/tpsuppliers_it_test.go @@ -112,7 +112,7 @@ func testTPSplPrfStartEngine(t *testing.T) { // Connect rpc client to rater func testTPSplPrfRPCConn(t *testing.T) { var err error - tpSplPrfRPC, err = jsonrpc.Dial("tcp", tpSplPrfCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpSplPrfRPC, err = jsonrpc.Dial(utils.TCP, tpSplPrfCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tpthresholds_it_test.go b/apier/v1/tpthresholds_it_test.go index 0242aff07..c3c08feab 100644 --- a/apier/v1/tpthresholds_it_test.go +++ b/apier/v1/tpthresholds_it_test.go @@ -118,7 +118,7 @@ func testTPThreholdStartEngine(t *testing.T) { // Connect rpc client to rater func testTPThreholdRpcConn(t *testing.T) { var err error - tpThresholdRPC, err = jsonrpc.Dial("tcp", tpThresholdCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpThresholdRPC, err = jsonrpc.Dial(utils.TCP, tpThresholdCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v1/tptimings_it_test.go b/apier/v1/tptimings_it_test.go index 64b636bdc..241ad0e16 100644 --- a/apier/v1/tptimings_it_test.go +++ b/apier/v1/tptimings_it_test.go @@ -121,7 +121,7 @@ func testTPTimingsStartEngine(t *testing.T) { // Connect rpc client to rater func testTPTimingsRpcConn(t *testing.T) { var err error - tpTimingRPC, err = jsonrpc.Dial("tcp", tpTimingCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpTimingRPC, err = jsonrpc.Dial(utils.TCP, tpTimingCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/apier/v2/apier.go b/apier/v2/apier.go index cd1366bea..94e7143c0 100644 --- a/apier/v2/apier.go +++ b/apier/v2/apier.go @@ -38,7 +38,7 @@ type ApierV2 struct { v1.ApierV1 } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (apiv2 *ApierV2) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(apiv2, serviceMethod, args, reply) diff --git a/cdrc/cdrc.go b/cdrc/cdrc.go index 663b25cf8..adc97c47f 100644 --- a/cdrc/cdrc.go +++ b/cdrc/cdrc.go @@ -52,7 +52,7 @@ Common parameters within configs processed: Parameters specific per config instance: * cdrSourceId, cdrFilter, cdrFields */ -func NewCdrc(cdrcCfgs []*config.CdrcCfg, httpSkipTlsCheck bool, cdrs rpcclient.RpcClientConnection, +func NewCdrc(cdrcCfgs []*config.CdrcCfg, httpSkipTlsCheck bool, cdrs rpcclient.ClientConnector, closeChan chan struct{}, dfltTimezone string, filterS *engine.FilterS) (cdrc *Cdrc, err error) { cdrcCfg := cdrcCfgs[0] cdrc = &Cdrc{ @@ -91,7 +91,7 @@ type Cdrc struct { cdrcCfgs []*config.CdrcCfg // All cdrc config profiles attached to this CDRC (key will be profile instance name) dfltCdrcCfg *config.CdrcCfg timezone string - cdrs rpcclient.RpcClientConnection + cdrs rpcclient.ClientConnector closeChan chan struct{} // Used to signal config reloads when we need to span different CDRC-Client maxOpenFiles chan struct{} // Maximum number of simultaneous files processed filterS *engine.FilterS diff --git a/cdrc/csv.go b/cdrc/csv.go index 468e8e865..3e3daac26 100644 --- a/cdrc/csv.go +++ b/cdrc/csv.go @@ -34,7 +34,7 @@ import ( func NewCsvRecordsProcessor(csvReader *csv.Reader, timezone, fileName string, dfltCdrcCfg *config.CdrcCfg, cdrcCfgs []*config.CdrcCfg, httpSkipTlsCheck bool, cacheDumpFields []*config.FCTemplate, - filterS *engine.FilterS, cdrs rpcclient.RpcClientConnection, + filterS *engine.FilterS, cdrs rpcclient.ClientConnector, unp *UnpairedRecordsCache, prt *PartialRecordsCache) *CsvRecordsProcessor { return &CsvRecordsProcessor{csvReader: csvReader, timezone: timezone, fileName: fileName, diff --git a/cdrc/partial_cdr.go b/cdrc/partial_cdr.go index fe3453998..7c59350a3 100644 --- a/cdrc/partial_cdr.go +++ b/cdrc/partial_cdr.go @@ -40,7 +40,7 @@ const ( func NewPartialRecordsCache(ttl time.Duration, expiryAction string, cdrOutDir string, csvSep rune, timezone string, httpSkipTlsCheck bool, - cdrs rpcclient.RpcClientConnection, filterS *engine.FilterS) *PartialRecordsCache { + cdrs rpcclient.ClientConnector, filterS *engine.FilterS) *PartialRecordsCache { return &PartialRecordsCache{ttl: ttl, expiryAction: expiryAction, cdrOutDir: cdrOutDir, csvSep: csvSep, timezone: timezone, httpSkipTlsCheck: httpSkipTlsCheck, cdrs: cdrs, @@ -56,7 +56,7 @@ type PartialRecordsCache struct { csvSep rune timezone string httpSkipTlsCheck bool - cdrs rpcclient.RpcClientConnection + cdrs rpcclient.ClientConnector partialRecords map[string]*PartialCDRRecord // [OriginID]*PartialRecord dumpTimers map[string]*time.Timer // [OriginID]*time.Timer which can be canceled or reset guard *guardian.GuardianLocker diff --git a/cmd/cgr-console/cgr-console.go b/cmd/cgr-console/cgr-console.go index 7b4a6ea18..c07dc4807 100644 --- a/cmd/cgr-console/cgr-console.go +++ b/cmd/cgr-console/cgr-console.go @@ -46,7 +46,7 @@ var ( caPath = cgrConsoleFlags.String("ca_path", "", "path to CA for tls connection(only for self sign certificate)") tls = cgrConsoleFlags.Bool("tls", false, "TLS connection") replyTimeOut = cgrConsoleFlags.Int("reply_timeout", 300, "Reply timeout in seconds ") - client *rpcclient.RpcClient + client *rpcclient.RPCClient ) func executeCommand(command string) { @@ -129,8 +129,8 @@ func main() { return } var err error - client, err = rpcclient.NewRpcClient("tcp", *server, *tls, *keyPath, *certificatePath, *caPath, 3, 3, - time.Duration(1*time.Second), time.Duration(*replyTimeOut)*time.Second, strings.TrimPrefix(*rpcEncoding, utils.Meta), nil, false) + client, err = rpcclient.NewRPCClient(utils.TCP, *server, *tls, *keyPath, *certificatePath, *caPath, 3, 3, + time.Duration(1*time.Second), time.Duration(*replyTimeOut)*time.Second, *rpcEncoding, nil, false) if err != nil { cgrConsoleFlags.PrintDefaults() log.Fatal("Could not connect to server " + *server) diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go index 2aec24038..f3853fe8c 100644 --- a/cmd/cgr-engine/cgr-engine.go +++ b/cmd/cgr-engine/cgr-engine.go @@ -60,7 +60,7 @@ var ( cfg *config.CGRConfig ) -func startCdrcs(internalCdrSChan, internalRaterChan, internalDispatcherSChan chan rpcclient.RpcClientConnection, +func startCdrcs(internalCdrSChan, internalRaterChan, internalDispatcherSChan chan rpcclient.ClientConnector, filterSChan chan *engine.FilterS, exitChan chan bool) { filterS := <-filterSChan filterSChan <- filterS @@ -102,14 +102,14 @@ func startCdrcs(internalCdrSChan, internalRaterChan, internalDispatcherSChan cha } // Fires up a cdrc instance -func startCdrc(internalCdrSChan, internalRaterChan chan rpcclient.RpcClientConnection, cdrcCfgs []*config.CdrcCfg, httpSkipTlsCheck bool, +func startCdrc(internalCdrSChan, internalRaterChan chan rpcclient.ClientConnector, cdrcCfgs []*config.CdrcCfg, httpSkipTlsCheck bool, filterSChan chan *engine.FilterS, closeChan chan struct{}, exitChan chan bool) { filterS := <-filterSChan filterSChan <- filterS var err error - var cdrsConn rpcclient.RpcClientConnection + var cdrsConn rpcclient.ClientConnector cdrcCfg := cdrcCfgs[0] - cdrsConn, err = engine.NewRPCPool(rpcclient.POOL_FIRST, cfg.TlsCfg().ClientKey, + cdrsConn, err = engine.NewRPCPool(rpcclient.PoolFirst, cfg.TlsCfg().ClientKey, cfg.TlsCfg().ClientCerificate, cfg.TlsCfg().CaCertificate, cfg.GeneralCfg().ConnectAttempts, cfg.GeneralCfg().Reconnects, cfg.GeneralCfg().ConnectTimeout, cfg.GeneralCfg().ReplyTimeout, @@ -136,14 +136,14 @@ func startCdrc(internalCdrSChan, internalRaterChan chan rpcclient.RpcClientConne // startFilterService fires up the FilterS func startFilterService(filterSChan chan *engine.FilterS, cacheS *engine.CacheS, - internalStatSChan, internalResourceSChan, internalRalSChan chan rpcclient.RpcClientConnection, cfg *config.CGRConfig, + internalStatSChan, internalResourceSChan, internalRalSChan chan rpcclient.ClientConnector, cfg *config.CGRConfig, dm *engine.DataManager, exitChan chan bool) { <-cacheS.GetPrecacheChannel(utils.CacheFilters) filterSChan <- engine.NewFilterS(cfg, internalStatSChan, internalResourceSChan, internalRalSChan, dm) } // initCacheS inits the CacheS and starts precaching as well as populating internal channel for RPC conns -func initCacheS(internalCacheSChan chan rpcclient.RpcClientConnection, +func initCacheS(internalCacheSChan chan rpcclient.ClientConnector, server *utils.Server, dm *engine.DataManager, exitChan chan bool) (chS *engine.CacheS) { chS = engine.NewCacheS(cfg, dm) go func() { @@ -161,7 +161,7 @@ func initCacheS(internalCacheSChan chan rpcclient.RpcClientConnection, return } -func initGuardianSv1(internalGuardianSChan chan rpcclient.RpcClientConnection, server *utils.Server) { +func initGuardianSv1(internalGuardianSChan chan rpcclient.ClientConnector, server *utils.Server) { grdSv1 := v1.NewGuardianSv1() if !cfg.DispatcherSCfg().Enabled { server.RpcRegister(grdSv1) @@ -169,7 +169,7 @@ func initGuardianSv1(internalGuardianSChan chan rpcclient.RpcClientConnection, s internalGuardianSChan <- grdSv1 } -func initCoreSv1(internalCoreSv1Chan chan rpcclient.RpcClientConnection, server *utils.Server) { +func initCoreSv1(internalCoreSv1Chan chan rpcclient.ClientConnector, server *utils.Server) { cSv1 := v1.NewCoreSv1(engine.NewCoreService()) if !cfg.DispatcherSCfg().Enabled { server.RpcRegister(cSv1) @@ -177,7 +177,7 @@ func initCoreSv1(internalCoreSv1Chan chan rpcclient.RpcClientConnection, server internalCoreSv1Chan <- cSv1 } -func initServiceManagerV1(internalServiceManagerChan chan rpcclient.RpcClientConnection, +func initServiceManagerV1(internalServiceManagerChan chan rpcclient.ClientConnector, srvMngr *servmanager.ServiceManager, server *utils.Server) { if !cfg.DispatcherSCfg().Enabled { server.RpcRegister(v1.NewServiceManagerV1(srvMngr)) @@ -189,7 +189,7 @@ func startRpc(server *utils.Server, internalRaterChan, internalCdrSChan, internalRsChan, internalStatSChan, internalAttrSChan, internalChargerSChan, internalThdSChan, internalSuplSChan, internalSMGChan, internalAnalyzerSChan, internalDispatcherSChan, - internalLoaderSChan, internalRALsv1Chan, internalCacheSChan chan rpcclient.RpcClientConnection, + internalLoaderSChan, internalRALsv1Chan, internalCacheSChan chan rpcclient.ClientConnector, exitChan chan bool) { if !cfg.DispatcherSCfg().Enabled { select { // Any of the rpc methods will unlock listening to rpc requests @@ -310,7 +310,7 @@ func initLogger(cfg *config.CGRConfig) error { return nil } -func initConfigSv1(internalConfigChan chan rpcclient.RpcClientConnection, +func initConfigSv1(internalConfigChan chan rpcclient.ClientConnector, server *utils.Server) { cfgSv1 := v1.NewConfigSv1(cfg) if !cfg.DispatcherSCfg().Enabled { @@ -483,16 +483,16 @@ func main() { // Define internal connections via channels filterSChan := make(chan *engine.FilterS, 1) - internalServeManagerChan := make(chan rpcclient.RpcClientConnection, 1) - internalConfigChan := make(chan rpcclient.RpcClientConnection, 1) - internalCoreSv1Chan := make(chan rpcclient.RpcClientConnection, 1) - internalCacheSChan := make(chan rpcclient.RpcClientConnection, 1) - internalGuardianSChan := make(chan rpcclient.RpcClientConnection, 1) + internalServeManagerChan := make(chan rpcclient.ClientConnector, 1) + internalConfigChan := make(chan rpcclient.ClientConnector, 1) + internalCoreSv1Chan := make(chan rpcclient.ClientConnector, 1) + internalCacheSChan := make(chan rpcclient.ClientConnector, 1) + internalGuardianSChan := make(chan rpcclient.ClientConnector, 1) - internalCDRServerChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency - internalAttributeSChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency - internalDispatcherSChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency - internalSessionSChan := make(chan rpcclient.RpcClientConnection, 1) // needed to avod cyclic dependency + internalCDRServerChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency + internalAttributeSChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency + internalDispatcherSChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency + internalSessionSChan := make(chan rpcclient.ClientConnector, 1) // needed to avod cyclic dependency // init CacheS cacheS := initCacheS(internalCacheSChan, server, dmService.GetDM(), exitChan) @@ -535,7 +535,7 @@ func main() { ldrs := services.NewLoaderService(cfg, dmService, filterSChan, server, internalCacheSChan, dspS.GetIntenternalChan(), exitChan) anz := services.NewAnalyzerService(cfg, server, exitChan) - connManager := services.NewConnManagerService(cfg, map[string]chan rpcclient.RpcClientConnection{ + connManager := services.NewConnManagerService(cfg, map[string]chan rpcclient.ClientConnector{ utils.AnalyzerSv1: anz.GetIntenternalChan(), utils.ApierV1: rals.GetAPIv1().GetIntenternalChan(), utils.ApierV2: rals.GetAPIv2().GetIntenternalChan(), diff --git a/cmd/cgr-loader/cgr-loader.go b/cmd/cgr-loader/cgr-loader.go index b1a1919f2..e81249167 100755 --- a/cmd/cgr-loader/cgr-loader.go +++ b/cmd/cgr-loader/cgr-loader.go @@ -102,8 +102,8 @@ var ( err error dm *engine.DataManager storDb engine.LoadStorage - cacheS rpcclient.RpcClientConnection - schedulerS rpcclient.RpcClientConnection + cacheS rpcclient.ClientConnector + schedulerS rpcclient.ClientConnector loader engine.LoadReader ) @@ -243,10 +243,10 @@ func main() { if err != nil { log.Fatalf("Coud not open dataDB connection: %s", err.Error()) } - var rmtConns, rplConns *rpcclient.RpcClientPool + var rmtConns, rplConns *rpcclient.RPCPool if len(ldrCfg.DataDbCfg().RmtConns) != 0 { var err error - rmtConns, err = engine.NewRPCPool(rpcclient.POOL_FIRST_POSITIVE, ldrCfg.TlsCfg().ClientKey, + rmtConns, err = engine.NewRPCPool(rpcclient.PoolFirstPositive, ldrCfg.TlsCfg().ClientKey, ldrCfg.TlsCfg().ClientCerificate, ldrCfg.TlsCfg().CaCertificate, ldrCfg.GeneralCfg().ConnectAttempts, ldrCfg.GeneralCfg().Reconnects, ldrCfg.GeneralCfg().ConnectTimeout, ldrCfg.GeneralCfg().ReplyTimeout, @@ -257,7 +257,7 @@ func main() { } if len(ldrCfg.DataDbCfg().RplConns) != 0 { var err error - rplConns, err = engine.NewRPCPool(rpcclient.POOL_BROADCAST, ldrCfg.TlsCfg().ClientKey, + rplConns, err = engine.NewRPCPool(rpcclient.PoolBroadcast, ldrCfg.TlsCfg().ClientKey, ldrCfg.TlsCfg().ClientCerificate, ldrCfg.TlsCfg().CaCertificate, ldrCfg.GeneralCfg().ConnectAttempts, ldrCfg.GeneralCfg().Reconnects, ldrCfg.GeneralCfg().ConnectTimeout, ldrCfg.GeneralCfg().ReplyTimeout, @@ -321,12 +321,12 @@ func main() { } if len(ldrCfg.LoaderCgrCfg().CachesConns) != 0 { // Init connection to CacheS so we can reload it's data - if cacheS, err = rpcclient.NewRpcClient("tcp", + if cacheS, err = rpcclient.NewRPCClient(utils.TCP, ldrCfg.LoaderCgrCfg().CachesConns[0].Address, ldrCfg.LoaderCgrCfg().CachesConns[0].TLS, ldrCfg.TlsCfg().ClientKey, ldrCfg.TlsCfg().ClientCerificate, ldrCfg.TlsCfg().CaCertificate, 3, 3, time.Duration(1*time.Second), time.Duration(5*time.Minute), - strings.TrimPrefix(ldrCfg.LoaderCgrCfg().CachesConns[0].Transport, utils.Meta), + ldrCfg.LoaderCgrCfg().CachesConns[0].Transport, nil, false); err != nil { log.Fatalf("Could not connect to CacheS: %s", err.Error()) return @@ -336,12 +336,12 @@ func main() { } if len(ldrCfg.LoaderCgrCfg().SchedulerConns) != 0 { // Init connection to Scheduler so we can reload it's data - if schedulerS, err = rpcclient.NewRpcClient("tcp", + if schedulerS, err = rpcclient.NewRPCClient(utils.TCP, ldrCfg.LoaderCgrCfg().SchedulerConns[0].Address, ldrCfg.LoaderCgrCfg().SchedulerConns[0].TLS, ldrCfg.TlsCfg().ClientKey, ldrCfg.TlsCfg().ClientCerificate, ldrCfg.TlsCfg().CaCertificate, 3, 3, time.Duration(1*time.Second), time.Duration(5*time.Minute), - strings.TrimPrefix(ldrCfg.LoaderCgrCfg().SchedulerConns[0].Transport, utils.Meta), + ldrCfg.LoaderCgrCfg().SchedulerConns[0].Transport, nil, false); err != nil { log.Fatalf("Could not connect to Scheduler: %s", err.Error()) return diff --git a/cmd/cgr-tester/cdr_repl/process_cdr.go b/cmd/cgr-tester/cdr_repl/process_cdr.go index d79f765fa..63cd47b26 100644 --- a/cmd/cgr-tester/cdr_repl/process_cdr.go +++ b/cmd/cgr-tester/cdr_repl/process_cdr.go @@ -36,15 +36,15 @@ var dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path h func main() { flag.Parse() var err error - var cdrsMasterRpc *rpcclient.RpcClient + var cdrsMasterRpc *rpcclient.RPCClient var cdrsMasterCfgPath string var cdrsMasterCfg *config.CGRConfig cdrsMasterCfgPath = path.Join(*dataDir, "conf", "samples", "cdrsreplicationmaster") if cdrsMasterCfg, err = config.NewCGRConfigFromPath(cdrsMasterCfgPath); err != nil { log.Fatal("Got config error: ", err.Error()) } - cdrsMasterRpc, err = rpcclient.NewRpcClient("tcp", cdrsMasterCfg.ListenCfg().RPCJSONListen, false, "", "", "", 1, 1, - time.Duration(1*time.Second), time.Duration(2*time.Second), "json", nil, false) + cdrsMasterRpc, err = rpcclient.NewRPCClient(utils.TCP, cdrsMasterCfg.ListenCfg().RPCJSONListen, false, "", "", "", 1, 1, + time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSONrpc, nil, false) if err != nil { log.Fatal("Could not connect to rater: ", err.Error()) } diff --git a/cmd/cgr-tester/cgr-tester.go b/cmd/cgr-tester/cgr-tester.go index 187afa5c5..f4509dacd 100644 --- a/cmd/cgr-tester/cgr-tester.go +++ b/cmd/cgr-tester/cgr-tester.go @@ -118,9 +118,9 @@ func durRemoteRater(cd *engine.CallDescriptorWithArgDispatcher) (time.Duration, var client *rpc.Client var err error if *json { - client, err = jsonrpc.Dial("tcp", *raterAddress) + client, err = jsonrpc.Dial(utils.TCP, *raterAddress) } else { - client, err = rpc.Dial("tcp", *raterAddress) + client, err = rpc.Dial(utils.TCP, *raterAddress) } if err != nil { diff --git a/cmd/cgr-tester/filereader.go b/cmd/cgr-tester/filereader.go index bf956f7ea..1e01a9c8c 100644 --- a/cmd/cgr-tester/filereader.go +++ b/cmd/cgr-tester/filereader.go @@ -29,6 +29,8 @@ import ( "os" "sync" "time" + + "github.com/cgrates/cgrates/utils" ) func NewFileReaderTester(fPath, cgrAddr string, parallel, runs int, reqSep []byte) (frt *FileReaderTester, err error) { @@ -39,7 +41,7 @@ func NewFileReaderTester(fPath, cgrAddr string, parallel, runs int, reqSep []byt if frt.rdr, err = os.Open(fPath); err != nil { return nil, err } - if frt.conn, err = net.Dial("tcp", cgrAddr); err != nil { + if frt.conn, err = net.Dial(utils.TCP, cgrAddr); err != nil { return nil, err } return diff --git a/config/config.go b/config/config.go index 1d868709e..519875be7 100755 --- a/config/config.go +++ b/config/config.go @@ -351,7 +351,7 @@ func (cfg *CGRConfig) loadRPCConns(jsnCfg *CgrJsonCfg) (err error) { } // hardoded the *internal and *localhost connections cfg.rpcConns[utils.MetaInternal] = &RPCConn{ - Strategy: rpcclient.POOL_FIRST, + Strategy: rpcclient.PoolFirst, PoolSize: 0, Conns: []*RemoteHost{ &RemoteHost{ @@ -360,7 +360,7 @@ func (cfg *CGRConfig) loadRPCConns(jsnCfg *CgrJsonCfg) (err error) { }, } cfg.rpcConns[utils.MetaLocalHost] = &RPCConn{ - Strategy: rpcclient.POOL_FIRST, + Strategy: rpcclient.PoolFirst, PoolSize: 0, Conns: []*RemoteHost{ &RemoteHost{ @@ -1066,7 +1066,7 @@ func (cfg *CGRConfig) GetReloadChan(sectID string) chan struct{} { return cfg.rldChans[sectID] } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (cfg *CGRConfig) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.APIerRPCCall(cfg, serviceMethod, args, reply) diff --git a/config/config_it_test.go b/config/config_it_test.go index c58fd205e..c9dc2e00e 100644 --- a/config/config_it_test.go +++ b/config/config_it_test.go @@ -42,7 +42,7 @@ func TestNewCgrJsonCfgFromHttp(t *testing.T) { t.Fatal(err) } - if _, err = net.DialTimeout("tcp", addr, time.Second); err != nil { // check if site is up + if _, err = net.DialTimeout(utils.TCP, addr, time.Second); err != nil { // check if site is up return } @@ -70,7 +70,7 @@ func TestNewCGRConfigFromPath(t *testing.T) { t.Fatal(err) } - if _, err = net.DialTimeout("tcp", addr, time.Second); err != nil { // check if site is up + if _, err = net.DialTimeout(utils.TCP, addr, time.Second); err != nil { // check if site is up return } diff --git a/config/config_json_test.go b/config/config_json_test.go index ae0479930..eb1fe830a 100755 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -662,7 +662,7 @@ func TestDiameterAgentJsonCfg(t *testing.T) { eCfg := &DiameterAgentJsonCfg{ Enabled: utils.BoolPointer(false), Listen: utils.StringPointer("127.0.0.1:3868"), - Listen_net: utils.StringPointer("tcp"), + Listen_net: utils.StringPointer(utils.TCP), Dictionaries_path: utils.StringPointer("/usr/share/cgrates/diameter/dict/"), Sessions_conns: &[]*RemoteHostJson{ { diff --git a/config/config_test.go b/config/config_test.go index b12b9b43d..94039d1a3 100755 --- a/config/config_test.go +++ b/config/config_test.go @@ -885,7 +885,7 @@ func TestCgrCfgJSONDefaultsDiameterAgentCfg(t *testing.T) { testDA := &DiameterAgentCfg{ Enabled: false, Listen: "127.0.0.1:3868", - ListenNet: "tcp", + ListenNet: utils.TCP, DictionariesPath: "/usr/share/cgrates/diameter/dict/", SessionSConns: []*RemoteHost{ {Address: "*internal"}}, @@ -1915,7 +1915,7 @@ func TestRpcConnsDefaults(t *testing.T) { eCfg := make(map[string]*RPCConn) // hardoded the *internal and *localhost connections eCfg[utils.MetaInternal] = &RPCConn{ - Strategy: rpcclient.POOL_FIRST, + Strategy: rpcclient.PoolFirst, PoolSize: 0, Conns: []*RemoteHost{ &RemoteHost{ @@ -1924,7 +1924,7 @@ func TestRpcConnsDefaults(t *testing.T) { }, } eCfg[utils.MetaLocalHost] = &RPCConn{ - Strategy: rpcclient.POOL_FIRST, + Strategy: rpcclient.PoolFirst, PoolSize: 0, Conns: []*RemoteHost{ &RemoteHost{ diff --git a/dispatchers/dispatchers.go b/dispatchers/dispatchers.go index eac545f17..0fdfe6b27 100755 --- a/dispatchers/dispatchers.go +++ b/dispatchers/dispatchers.go @@ -34,7 +34,7 @@ import ( // NewDispatcherService constructs a DispatcherService func NewDispatcherService(dm *engine.DataManager, cfg *config.CGRConfig, fltrS *engine.FilterS, - attrS *rpcclient.RpcClientPool) (*DispatcherService, error) { + attrS *rpcclient.RPCPool) (*DispatcherService, error) { if attrS != nil && reflect.ValueOf(attrS).IsNil() { attrS = nil } @@ -48,7 +48,7 @@ type DispatcherService struct { dm *engine.DataManager cfg *config.CGRConfig fltrS *engine.FilterS - attrS *rpcclient.RpcClientPool // used for API auth + attrS *rpcclient.RPCPool // used for API auth } // ListenAndServe will initialize the service @@ -289,7 +289,7 @@ func (dS *DispatcherService) V1Apier(apier interface{}, args *utils.MethodParame } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC func (dS *DispatcherService) Call(serviceMethod string, // all API fuction must be of type: SubsystemMethod args interface{}, reply interface{}) error { methodSplit := strings.Split(serviceMethod, ".") diff --git a/engine/action.go b/engine/action.go index c8a86f1f5..9ea1806d7 100644 --- a/engine/action.go +++ b/engine/action.go @@ -755,16 +755,16 @@ func cgrRPCAction(ub *Account, a *Action, acs Actions, extraData interface{}) er if err != nil { return err } - var client rpcclient.RpcClientConnection + var client rpcclient.ClientConnector if req.Address != utils.MetaInternal { - if client, err = rpcclient.NewRpcClient("tcp", req.Address, false, "", "", "", + if client, err = rpcclient.NewRPCClient(utils.TCP, req.Address, false, "", "", "", req.Attempts, 0, config.CgrConfig().GeneralCfg().ConnectTimeout, config.CgrConfig().GeneralCfg().ReplyTimeout, req.Transport, nil, false); err != nil { return err } } else { - client = params.Object.(rpcclient.RpcClientConnection) + client = params.Object.(rpcclient.ClientConnector) } in, out := params.InParam, params.OutParam //utils.Logger.Info("Params: " + utils.ToJSON(req.Params)) diff --git a/engine/calldesc.go b/engine/calldesc.go index 3ea08f79e..9ffc1c2d4 100644 --- a/engine/calldesc.go +++ b/engine/calldesc.go @@ -57,9 +57,9 @@ var ( cdrStorage CdrStorage debitPeriod = 10 * time.Second globalRoundingDecimals = 6 - thresholdS rpcclient.RpcClientConnection // used by RALs to communicate with ThresholdS - statS rpcclient.RpcClientConnection - schedCdrsConns rpcclient.RpcClientConnection + thresholdS rpcclient.ClientConnector // used by RALs to communicate with ThresholdS + statS rpcclient.ClientConnector + schedCdrsConns rpcclient.ClientConnector rpSubjectPrefixMatching bool ) @@ -68,11 +68,11 @@ func SetDataStorage(dm2 *DataManager) { dm = dm2 } -func SetThresholdS(thdS rpcclient.RpcClientConnection) { +func SetThresholdS(thdS rpcclient.ClientConnector) { thresholdS = thdS } -func SetStatS(stsS rpcclient.RpcClientConnection) { +func SetStatS(stsS rpcclient.ClientConnector) { statS = stsS } @@ -91,7 +91,7 @@ func SetCdrStorage(cStorage CdrStorage) { } // SetSchedCdrsConns sets the connection between action and CDRServer -func SetSchedCdrsConns(sc rpcclient.RpcClientConnection) { +func SetSchedCdrsConns(sc rpcclient.ClientConnector) { schedCdrsConns = sc if schedCdrsConns != nil && reflect.ValueOf(schedCdrsConns).IsNil() { schedCdrsConns = nil diff --git a/engine/cdre.go b/engine/cdre.go index bb874ad3b..99c259c64 100644 --- a/engine/cdre.go +++ b/engine/cdre.go @@ -54,7 +54,7 @@ const ( func NewCDRExporter(cdrs []*CDR, exportTemplate *config.CdreCfg, exportFormat, exportPath, fallbackPath, exportID string, synchronous bool, attempts int, fieldSeparator rune, - httpSkipTlsCheck bool, httpPoster *HTTPPoster, attrS rpcclient.RpcClientConnection, filterS *FilterS) (*CDRExporter, error) { + httpSkipTlsCheck bool, httpPoster *HTTPPoster, attrS rpcclient.ClientConnector, filterS *FilterS) (*CDRExporter, error) { if len(cdrs) == 0 { // Nothing to export return nil, nil } @@ -103,7 +103,7 @@ type CDRExporter struct { positiveExports []string // CGRIDs of successfully exported CDRs negativeExports map[string]string // CGRIDs of failed exports - attrS rpcclient.RpcClientConnection + attrS rpcclient.ClientConnector filterS *FilterS } diff --git a/engine/cdrs.go b/engine/cdrs.go index f7d41b517..f65314c43 100644 --- a/engine/cdrs.go +++ b/engine/cdrs.go @@ -69,7 +69,7 @@ func fsCdrHandler(w http.ResponseWriter, r *http.Request) { // NewCDRServer is a constructor for CDRServer func NewCDRServer(cgrCfg *config.CGRConfig, cdrDb CdrStorage, dm *DataManager, rater, - attrS, thdS, statS, chargerS rpcclient.RpcClientConnection, filterS *FilterS) *CDRServer { + attrS, thdS, statS, chargerS rpcclient.ClientConnector, filterS *FilterS) *CDRServer { if rater != nil && reflect.ValueOf(rater).IsNil() { rater = nil } @@ -104,11 +104,11 @@ type CDRServer struct { cgrCfg *config.CGRConfig cdrDb CdrStorage dm *DataManager - rals rpcclient.RpcClientConnection - attrS rpcclient.RpcClientConnection - thdS rpcclient.RpcClientConnection - statS rpcclient.RpcClientConnection - chargerS rpcclient.RpcClientConnection + rals rpcclient.ClientConnector + attrS rpcclient.ClientConnector + thdS rpcclient.ClientConnector + statS rpcclient.ClientConnector + chargerS rpcclient.ClientConnector guard *guardian.GuardianLocker httpPoster *HTTPPoster // used for replication filterS *FilterS @@ -581,7 +581,7 @@ func (cdrS *CDRServer) processEvent(ev *utils.CGREventWithArgDispatcher, return } -// Call implements the rpcclient.RpcClientConnection interface +// Call implements the rpcclient.ClientConnector interface func (cdrS *CDRServer) Call(serviceMethod string, args interface{}, reply interface{}) error { parts := strings.Split(serviceMethod, ".") if len(parts) != 2 { @@ -980,31 +980,31 @@ func (cdrS *CDRServer) V1CountCDRs(args *utils.RPCCDRsFilterWithArgDispatcher, c // SetAttributeSConnection sets the new connection to the attribute service // only used on reload -func (cdrS *CDRServer) SetAttributeSConnection(attrS rpcclient.RpcClientConnection) { +func (cdrS *CDRServer) SetAttributeSConnection(attrS rpcclient.ClientConnector) { cdrS.attrS = attrS } // SetThresholSConnection sets the new connection to the threshold service // only used on reload -func (cdrS *CDRServer) SetThresholSConnection(thdS rpcclient.RpcClientConnection) { +func (cdrS *CDRServer) SetThresholSConnection(thdS rpcclient.ClientConnector) { cdrS.thdS = thdS } // SetStatSConnection sets the new connection to the stat service // only used on reload -func (cdrS *CDRServer) SetStatSConnection(stS rpcclient.RpcClientConnection) { +func (cdrS *CDRServer) SetStatSConnection(stS rpcclient.ClientConnector) { cdrS.statS = stS } // SetChargerSConnection sets the new connection to the charger service // only used on reload -func (cdrS *CDRServer) SetChargerSConnection(chS rpcclient.RpcClientConnection) { +func (cdrS *CDRServer) SetChargerSConnection(chS rpcclient.ClientConnector) { cdrS.chargerS = chS } // SetRALsConnection sets the new connection to the RAL service // only used on reload -func (cdrS *CDRServer) SetRALsConnection(rls rpcclient.RpcClientConnection) { +func (cdrS *CDRServer) SetRALsConnection(rls rpcclient.ClientConnector) { cdrS.rals = rls } diff --git a/engine/chargers.go b/engine/chargers.go index 4188b055f..9e452cd7d 100644 --- a/engine/chargers.go +++ b/engine/chargers.go @@ -29,7 +29,7 @@ import ( ) func NewChargerService(dm *DataManager, filterS *FilterS, - attrS rpcclient.RpcClientConnection, + attrS rpcclient.ClientConnector, cfg *config.CGRConfig) (*ChargerService, error) { if attrS != nil && reflect.ValueOf(attrS).IsNil() { attrS = nil @@ -42,7 +42,7 @@ func NewChargerService(dm *DataManager, filterS *FilterS, type ChargerService struct { dm *DataManager filterS *FilterS - attrS rpcclient.RpcClientConnection + attrS rpcclient.ClientConnector cfg *config.CGRConfig } @@ -184,6 +184,6 @@ func (cS *ChargerService) V1GetChargersForEvent(args *utils.CGREventWithArgDispa // SetAttributeConnection sets the new connection to the attribute service // only used on reload -func (cS *ChargerService) SetAttributeConnection(attrS rpcclient.RpcClientConnection) { +func (cS *ChargerService) SetAttributeConnection(attrS rpcclient.ClientConnector) { cS.attrS = attrS } diff --git a/engine/connmanager.go b/engine/connmanager.go index 663fb311f..bf83651b7 100644 --- a/engine/connmanager.go +++ b/engine/connmanager.go @@ -25,28 +25,28 @@ import ( ) // NewConnManager returns the Connection Manager -func NewConnManager(cfg *config.CGRConfig, rpcInternal map[string]chan rpcclient.RpcClientConnection) (cM *ConnManager) { +func NewConnManager(cfg *config.CGRConfig, rpcInternal map[string]chan rpcclient.ClientConnector) (cM *ConnManager) { return &ConnManager{cfg: cfg, rpcInternal: rpcInternal} } //ConnManager handle the RPC connections type ConnManager struct { cfg *config.CGRConfig - rpcInternal map[string]chan rpcclient.RpcClientConnection + rpcInternal map[string]chan rpcclient.ClientConnector } //getConn is used to retrieves a connection from cache //in case this doesn't exist create it and cache it -func (cM *ConnManager) getConn(connID string) (connPool *rpcclient.RpcClientPool, err error) { +func (cM *ConnManager) getConn(connID string) (connPool *rpcclient.RPCPool, err error) { //try to get the connection from cache if x, ok := Cache.Get(utils.CacheRPCConnections, connID); ok { if x == nil { return nil, utils.ErrNotFound } - return x.(*rpcclient.RpcClientPool), nil + return x.(*rpcclient.RPCPool), nil } // in case we don't find in cache create the connection and add this in cache - var intChan chan rpcclient.RpcClientConnection + var intChan chan rpcclient.ClientConnector var connCfg *config.RPCConn if internalChan, has := cM.rpcInternal[connID]; has { connCfg = cM.cfg.RPCConns()[utils.MetaInternal] @@ -68,7 +68,7 @@ func (cM *ConnManager) getConn(connID string) (connPool *rpcclient.RpcClientPool } func (cM *ConnManager) Call(connIDs []string, method string, arg, reply interface{}) (err error) { - var conn *rpcclient.RpcClientPool + var conn *rpcclient.RPCPool for _, connID := range connIDs { if conn, err = cM.getConn(connID); err != nil { continue diff --git a/engine/datamanager.go b/engine/datamanager.go index ef4e13efe..0395bf2f1 100644 --- a/engine/datamanager.go +++ b/engine/datamanager.go @@ -90,7 +90,7 @@ var ( // NewDataManager returns a new DataManager func NewDataManager(dataDB DataDB, cacheCfg config.CacheCfg, rmtConns, - rplConns *rpcclient.RpcClientPool) *DataManager { + rplConns *rpcclient.RPCPool) *DataManager { return &DataManager{ dataDB: dataDB, cacheCfg: cacheCfg, @@ -104,7 +104,7 @@ func NewDataManager(dataDB DataDB, cacheCfg config.CacheCfg, rmtConns, type DataManager struct { dataDB DataDB cacheCfg config.CacheCfg - rmtConns, rplConns *rpcclient.RpcClientPool + rmtConns, rplConns *rpcclient.RPCPool } // DataDB exports access to dataDB @@ -520,7 +520,7 @@ func GetFilter(dm *DataManager, tenant, id string, cacheRead, cacheWrite bool, } if strings.HasPrefix(id, utils.Meta) { fltr, err = NewFilterFromInline(tenant, id) - } else if dm == nil { // in case we want the filter from dataDB but the connection to dataDB a optional (e.g. SessionS) + } else if dm == nil { // in case we want the filter from dataDB but the connection to dataDB a optional (e.g. SessionS) err = utils.ErrNoDatabaseConn return } else { @@ -2101,7 +2101,7 @@ func (dm *DataManager) GetDispatcherHost(tenant, id string, cacheRead, cacheWrit if cacheWrite { cfg := config.CgrConfig() if dH.rpcConn, err = NewRPCPool( - rpcclient.POOL_FIRST, + rpcclient.PoolFirst, cfg.TlsCfg().ClientKey, cfg.TlsCfg().ClientCerificate, cfg.TlsCfg().CaCertificate, cfg.GeneralCfg().ConnectAttempts, cfg.GeneralCfg().Reconnects, diff --git a/engine/dispatcherprfl.go b/engine/dispatcherprfl.go index d5bc33bdf..68c32765c 100644 --- a/engine/dispatcherprfl.go +++ b/engine/dispatcherprfl.go @@ -130,7 +130,7 @@ type DispatcherHost struct { Tenant string ID string Conns []*config.RemoteHost - rpcConn rpcclient.RpcClientConnection + rpcConn rpcclient.ClientConnector } func (dH *DispatcherHost) TenantID() string { diff --git a/engine/filters.go b/engine/filters.go index 8cf40880a..ab2d7b671 100644 --- a/engine/filters.go +++ b/engine/filters.go @@ -28,7 +28,7 @@ import ( ) func NewFilterS(cfg *config.CGRConfig, - statSChan, resSChan, ralSChan chan rpcclient.RpcClientConnection, dm *DataManager) (fS *FilterS) { + statSChan, resSChan, ralSChan chan rpcclient.ClientConnector, dm *DataManager) (fS *FilterS) { fS = &FilterS{ dm: dm, cfg: cfg, @@ -49,19 +49,19 @@ func NewFilterS(cfg *config.CGRConfig, // uses lazy connections where necessary to avoid deadlocks on service startup type FilterS struct { cfg *config.CGRConfig - statSConns, resSConns, ralSConns rpcclient.RpcClientConnection + statSConns, resSConns, ralSConns rpcclient.ClientConnector sSConnMux, rSConnMux, ralSConnMux sync.RWMutex // make sure only one goroutine attempts connecting dm *DataManager } // connStatS returns will connect towards StatS -func (fS *FilterS) connStatS(statSChan chan rpcclient.RpcClientConnection) (err error) { +func (fS *FilterS) connStatS(statSChan chan rpcclient.ClientConnector) (err error) { fS.sSConnMux.Lock() defer fS.sSConnMux.Unlock() if fS.statSConns != nil { // connection was populated between locks return } - fS.statSConns, err = NewRPCPool(rpcclient.POOL_FIRST, + fS.statSConns, err = NewRPCPool(rpcclient.PoolFirst, fS.cfg.TlsCfg().ClientKey, fS.cfg.TlsCfg().ClientCerificate, fS.cfg.TlsCfg().CaCertificate, fS.cfg.GeneralCfg().ConnectAttempts, fS.cfg.GeneralCfg().Reconnects, fS.cfg.GeneralCfg().ConnectTimeout, @@ -71,13 +71,13 @@ func (fS *FilterS) connStatS(statSChan chan rpcclient.RpcClientConnection) (err } // connResourceS returns will connect towards ResourceS -func (fS *FilterS) connResourceS(resSChan chan rpcclient.RpcClientConnection) (err error) { +func (fS *FilterS) connResourceS(resSChan chan rpcclient.ClientConnector) (err error) { fS.rSConnMux.Lock() defer fS.rSConnMux.Unlock() if fS.resSConns != nil { // connection was populated between locks return } - fS.resSConns, err = NewRPCPool(rpcclient.POOL_FIRST, + fS.resSConns, err = NewRPCPool(rpcclient.PoolFirst, fS.cfg.TlsCfg().ClientKey, fS.cfg.TlsCfg().ClientCerificate, fS.cfg.TlsCfg().CaCertificate, fS.cfg.GeneralCfg().ConnectAttempts, fS.cfg.GeneralCfg().Reconnects, fS.cfg.GeneralCfg().ConnectTimeout, @@ -87,13 +87,13 @@ func (fS *FilterS) connResourceS(resSChan chan rpcclient.RpcClientConnection) (e } // connRALs returns will connect towards RALs -func (fS *FilterS) connRALs(ralSChan chan rpcclient.RpcClientConnection) (err error) { +func (fS *FilterS) connRALs(ralSChan chan rpcclient.ClientConnector) (err error) { fS.ralSConnMux.Lock() defer fS.ralSConnMux.Unlock() if fS.ralSConns != nil { // connection was populated between locks return } - fS.ralSConns, err = NewRPCPool(rpcclient.POOL_FIRST, + fS.ralSConns, err = NewRPCPool(rpcclient.PoolFirst, fS.cfg.TlsCfg().ClientKey, fS.cfg.TlsCfg().ClientCerificate, fS.cfg.TlsCfg().CaCertificate, fS.cfg.GeneralCfg().ConnectAttempts, fS.cfg.GeneralCfg().Reconnects, fS.cfg.GeneralCfg().ConnectTimeout, diff --git a/engine/libengine.go b/engine/libengine.go index cdeb6d43c..f87b532ef 100644 --- a/engine/libengine.go +++ b/engine/libengine.go @@ -30,21 +30,21 @@ import ( func NewRPCPool(dispatchStrategy string, keyPath, certPath, caPath string, connAttempts, reconnects int, connectTimeout, replyTimeout time.Duration, rpcConnCfgs []*config.RemoteHost, - internalConnChan chan rpcclient.RpcClientConnection, lazyConnect bool) (*rpcclient.RpcClientPool, error) { - var rpcClient *rpcclient.RpcClient + internalConnChan chan rpcclient.ClientConnector, lazyConnect bool) (*rpcclient.RPCPool, error) { + var rpcClient *rpcclient.RPCClient var err error - rpcPool := rpcclient.NewRpcClientPool(dispatchStrategy, replyTimeout) + rpcPool := rpcclient.NewRPCPool(dispatchStrategy, replyTimeout) atLestOneConnected := false // If one connected we don't longer return errors for _, rpcConnCfg := range rpcConnCfgs { if rpcConnCfg.Address == utils.MetaInternal { - rpcClient, err = rpcclient.NewRpcClient("", "", rpcConnCfg.TLS, keyPath, certPath, caPath, connAttempts, - reconnects, connectTimeout, replyTimeout, rpcclient.INTERNAL_RPC, internalConnChan, lazyConnect) + rpcClient, err = rpcclient.NewRPCClient("", "", rpcConnCfg.TLS, keyPath, certPath, caPath, connAttempts, + reconnects, connectTimeout, replyTimeout, rpcclient.InternalRPC, internalConnChan, lazyConnect) } else if utils.SliceHasMember([]string{utils.EmptyString, utils.MetaGOB, utils.MetaJSON}, rpcConnCfg.Transport) { - codec := utils.GOB + codec := rpcclient.GOBrpc if rpcConnCfg.Transport != "" { - codec = rpcConnCfg.Transport[1:] // Transport contains always * before codec understood by rpcclient + codec = rpcConnCfg.Transport } - rpcClient, err = rpcclient.NewRpcClient("tcp", rpcConnCfg.Address, rpcConnCfg.TLS, keyPath, certPath, caPath, + rpcClient, err = rpcclient.NewRPCClient(utils.TCP, rpcConnCfg.Address, rpcConnCfg.TLS, keyPath, certPath, caPath, connAttempts, reconnects, connectTimeout, replyTimeout, codec, nil, lazyConnect) } else { return nil, fmt.Errorf("Unsupported transport: <%s>", rpcConnCfg.Transport) @@ -63,22 +63,22 @@ func NewRPCPool(dispatchStrategy string, keyPath, certPath, caPath string, connA var IntRPC *RPCClientSet func NewRPCClientSet() (s *RPCClientSet) { - return &RPCClientSet{set: make(map[string]*rpcclient.RpcClient)} + return &RPCClientSet{set: make(map[string]*rpcclient.RPCClient)} } type RPCClientSet struct { - set map[string]*rpcclient.RpcClient + set map[string]*rpcclient.RPCClient } -func (s *RPCClientSet) AddRPCClient(name string, rpc *rpcclient.RpcClient) { +func (s *RPCClientSet) AddRPCClient(name string, rpc *rpcclient.RPCClient) { s.set[name] = rpc } func (s *RPCClientSet) AddRPCConnection(name, transport, addr string, tls bool, key_path, cert_path, ca_path string, connectAttempts, reconnects int, connTimeout, replyTimeout time.Duration, codec string, - internalChan chan rpcclient.RpcClientConnection, lazyConnect bool) error { - rpc, err := rpcclient.NewRpcClient(transport, addr, tls, key_path, cert_path, + internalChan chan rpcclient.ClientConnector, lazyConnect bool) error { + rpc, err := rpcclient.NewRPCClient(transport, addr, tls, key_path, cert_path, ca_path, connectAttempts, reconnects, connTimeout, replyTimeout, codec, internalChan, lazyConnect) if err != nil { @@ -88,19 +88,19 @@ func (s *RPCClientSet) AddRPCConnection(name, transport, addr string, tls bool, return nil } -func (s *RPCClientSet) AddInternalRPCClient(name string, connChan chan rpcclient.RpcClientConnection) { +func (s *RPCClientSet) AddInternalRPCClient(name string, connChan chan rpcclient.ClientConnector) { err := s.AddRPCConnection(name, utils.EmptyString, utils.EmptyString, false, utils.EmptyString, utils.EmptyString, utils.EmptyString, config.CgrConfig().GeneralCfg().ConnectAttempts, config.CgrConfig().GeneralCfg().Reconnects, config.CgrConfig().GeneralCfg().ConnectTimeout, config.CgrConfig().GeneralCfg().ReplyTimeout, - rpcclient.INTERNAL_RPC, connChan, true) + rpcclient.InternalRPC, connChan, true) if err != nil { utils.Logger.Err(fmt.Sprintf(" Error adding %s to the set: %v", name, err.Error())) } } -func (s *RPCClientSet) GetInternalChanel() chan rpcclient.RpcClientConnection { - connChan := make(chan rpcclient.RpcClientConnection, 1) +func (s *RPCClientSet) GetInternalChanel() chan rpcclient.ClientConnector { + connChan := make(chan rpcclient.ClientConnector, 1) connChan <- s return connChan } diff --git a/engine/libtest.go b/engine/libtest.go index 5bec65b40..c500e5c11 100644 --- a/engine/libtest.go +++ b/engine/libtest.go @@ -347,7 +347,7 @@ func StartEngine(cfgPath string, waitEngine int) (*exec.Cmd, error) { var connected bool for i := 0; i < 200; i++ { time.Sleep(time.Duration(fib()) * time.Millisecond) - if _, err := jsonrpc.Dial("tcp", cfg.ListenCfg().RPCJSONListen); err != nil { + if _, err := jsonrpc.Dial(utils.TCP, cfg.ListenCfg().RPCJSONListen); err != nil { utils.Logger.Warning(fmt.Sprintf("Error <%s> when opening test connection to: <%s>", err.Error(), cfg.ListenCfg().RPCJSONListen)) } else { @@ -376,7 +376,7 @@ func StopStartEngine(cfgPath string, waitEngine int) (*exec.Cmd, error) { } func LoadTariffPlanFromFolder(tpPath, timezone string, dm *DataManager, disable_reverse bool, - cacheS rpcclient.RpcClientConnection, schedulerS rpcclient.RpcClientConnection) error { + cacheS rpcclient.ClientConnector, schedulerS rpcclient.ClientConnector) error { loader, err := NewTpReader(dm.dataDB, NewFileCSVStorage(utils.CSV_SEP, tpPath, false), "", timezone, cacheS, schedulerS) if err != nil { return utils.NewErrServerError(err) diff --git a/engine/resources.go b/engine/resources.go index 5b2e7a9cf..80b85d74a 100644 --- a/engine/resources.go +++ b/engine/resources.go @@ -298,7 +298,7 @@ func (rs Resources) allocateResource(ru *ResourceUsage, dryRun bool) (alcMessage // NewResourceService returns a new ResourceService func NewResourceService(dm *DataManager, cgrcfg *config.CGRConfig, - thdS rpcclient.RpcClientConnection, filterS *FilterS) (*ResourceService, error) { + thdS rpcclient.ClientConnector, filterS *FilterS) (*ResourceService, error) { if thdS != nil && reflect.ValueOf(thdS).IsNil() { thdS = nil } @@ -312,8 +312,8 @@ func NewResourceService(dm *DataManager, cgrcfg *config.CGRConfig, // ResourceService is the service handling resources type ResourceService struct { - dm *DataManager // So we can load the data in cache and index it - thdS rpcclient.RpcClientConnection // allows applying filters based on stats + dm *DataManager // So we can load the data in cache and index it + thdS rpcclient.ClientConnector // allows applying filters based on stats filterS *FilterS storedResources utils.StringMap // keep a record of resources which need saving, map[resID]bool srMux sync.RWMutex // protects storedResources @@ -771,6 +771,6 @@ func (rS *ResourceService) StartLoop() { // SetThresholdConnection sets the new connection to the threshold service // only used on reload -func (rS *ResourceService) SetThresholdConnection(thdS rpcclient.RpcClientConnection) { +func (rS *ResourceService) SetThresholdConnection(thdS rpcclient.ClientConnector) { rS.thdS = thdS } diff --git a/engine/stats.go b/engine/stats.go index 9bc08a4c2..0189bb2bc 100644 --- a/engine/stats.go +++ b/engine/stats.go @@ -33,7 +33,7 @@ import ( // NewStatService initializes a StatService func NewStatService(dm *DataManager, cgrcfg *config.CGRConfig, - thdS rpcclient.RpcClientConnection, filterS *FilterS) (ss *StatService, err error) { + thdS rpcclient.ClientConnector, filterS *FilterS) (ss *StatService, err error) { if thdS != nil && reflect.ValueOf(thdS).IsNil() { // fix nil value in interface thdS = nil } @@ -50,7 +50,7 @@ func NewStatService(dm *DataManager, cgrcfg *config.CGRConfig, // StatService builds stats for events type StatService struct { dm *DataManager - thdS rpcclient.RpcClientConnection // rpc connection towards ThresholdS + thdS rpcclient.ClientConnector // rpc connection towards ThresholdS filterS *FilterS cgrcfg *config.CGRConfig loopStoped chan struct{} @@ -222,7 +222,7 @@ func (sS *StatService) matchingStatQueuesForEvent(args *StatsArgsProcessEvent) ( return } -// Call implements rpcclient.RpcClientConnection interface for internal RPC +// Call implements rpcclient.ClientConnector interface for internal RPC // here for cases when passing StatsService as rpccclient.RpcClientConnection func (ss *StatService) Call(serviceMethod string, args interface{}, reply interface{}) error { return utils.RPCCall(ss, serviceMethod, args, reply) @@ -428,6 +428,6 @@ func (sS *StatService) StartLoop() { // SetThresholdConnection sets the new connection to the threshold service // only used on reload -func (sS *StatService) SetThresholdConnection(thdS rpcclient.RpcClientConnection) { +func (sS *StatService) SetThresholdConnection(thdS rpcclient.ClientConnector) { sS.thdS = thdS } diff --git a/engine/suppliers.go b/engine/suppliers.go index 51650afff..b3ff13b13 100644 --- a/engine/suppliers.go +++ b/engine/suppliers.go @@ -111,7 +111,7 @@ func (lps SupplierProfiles) Sort() { // NewSupplierService initializes the Supplier Service func NewSupplierService(dm *DataManager, filterS *FilterS, cgrcfg *config.CGRConfig, resourceS, - statS, attributeS rpcclient.RpcClientConnection) (spS *SupplierService, err error) { + statS, attributeS rpcclient.ClientConnector) (spS *SupplierService, err error) { if attributeS != nil && reflect.ValueOf(attributeS).IsNil() { // fix nil value in interface attributeS = nil } @@ -140,9 +140,9 @@ type SupplierService struct { dm *DataManager filterS *FilterS cgrcfg *config.CGRConfig - attributeS rpcclient.RpcClientConnection - resourceS rpcclient.RpcClientConnection - statS rpcclient.RpcClientConnection + attributeS rpcclient.ClientConnector + resourceS rpcclient.ClientConnector + statS rpcclient.ClientConnector sorter SupplierSortDispatcher } @@ -638,18 +638,18 @@ func (spS *SupplierService) V1GetSupplierProfilesForEvent(args *utils.CGREventWi // SetAttributeSConnection sets the new connection to the attribute service // only used on reload -func (spS *SupplierService) SetAttributeSConnection(attrS rpcclient.RpcClientConnection) { +func (spS *SupplierService) SetAttributeSConnection(attrS rpcclient.ClientConnector) { spS.attributeS = attrS } // SetStatSConnection sets the new connection to the stat service // only used on reload -func (spS *SupplierService) SetStatSConnection(stS rpcclient.RpcClientConnection) { +func (spS *SupplierService) SetStatSConnection(stS rpcclient.ClientConnector) { spS.statS = stS } // SetResourceSConnection sets the new connection to the resource service // only used on reload -func (spS *SupplierService) SetResourceSConnection(rS rpcclient.RpcClientConnection) { +func (spS *SupplierService) SetResourceSConnection(rS rpcclient.ClientConnector) { spS.resourceS = rS } diff --git a/engine/tpreader.go b/engine/tpreader.go index 46a6c7626..b3063e6cf 100644 --- a/engine/tpreader.go +++ b/engine/tpreader.go @@ -62,16 +62,16 @@ type TpReader struct { thresholds []*utils.TenantID // IDs of thresholds which need creation based on thresholdProfiles revDests, acntActionPlans map[string][]string - cacheS rpcclient.RpcClientConnection - schedulerS rpcclient.RpcClientConnection + cacheS rpcclient.ClientConnector + schedulerS rpcclient.ClientConnector } func NewTpReader(db DataDB, lr LoadReader, tpid, timezone string, - cacheS rpcclient.RpcClientConnection, schedulerS rpcclient.RpcClientConnection) (*TpReader, error) { - var rmtConns, rplConns *rpcclient.RpcClientPool + cacheS rpcclient.ClientConnector, schedulerS rpcclient.ClientConnector) (*TpReader, error) { + var rmtConns, rplConns *rpcclient.RPCPool if len(config.CgrConfig().DataDbCfg().RmtConns) != 0 { var err error - rmtConns, err = NewRPCPool(rpcclient.POOL_FIRST_POSITIVE, config.CgrConfig().TlsCfg().ClientKey, + rmtConns, err = NewRPCPool(rpcclient.PoolFirstPositive, config.CgrConfig().TlsCfg().ClientKey, config.CgrConfig().TlsCfg().ClientCerificate, config.CgrConfig().TlsCfg().CaCertificate, config.CgrConfig().GeneralCfg().ConnectAttempts, config.CgrConfig().GeneralCfg().Reconnects, config.CgrConfig().GeneralCfg().ConnectTimeout, config.CgrConfig().GeneralCfg().ReplyTimeout, @@ -82,7 +82,7 @@ func NewTpReader(db DataDB, lr LoadReader, tpid, timezone string, } if len(config.CgrConfig().DataDbCfg().RplConns) != 0 { var err error - rplConns, err = NewRPCPool(rpcclient.POOL_BROADCAST, config.CgrConfig().TlsCfg().ClientKey, + rplConns, err = NewRPCPool(rpcclient.PoolBroadcast, config.CgrConfig().TlsCfg().ClientKey, config.CgrConfig().TlsCfg().ClientCerificate, config.CgrConfig().TlsCfg().CaCertificate, config.CgrConfig().GeneralCfg().ConnectAttempts, config.CgrConfig().GeneralCfg().Reconnects, config.CgrConfig().GeneralCfg().ConnectTimeout, config.CgrConfig().GeneralCfg().ReplyTimeout, diff --git a/general_tests/cdrs_onlexp_it_test.go b/general_tests/cdrs_onlexp_it_test.go index cc9cfcde5..f9b71cb7d 100644 --- a/general_tests/cdrs_onlexp_it_test.go +++ b/general_tests/cdrs_onlexp_it_test.go @@ -43,7 +43,7 @@ import ( var ( cdrsMasterCfgPath, cdrsSlaveCfgPath string cdrsMasterCfg, cdrsSlaveCfg *config.CGRConfig - cdrsMasterRpc *rpcclient.RpcClient + cdrsMasterRpc *rpcclient.RPCClient sTestsCDRsOnExp = []func(t *testing.T){ testCDRsOnExpInitConfig, @@ -142,8 +142,8 @@ func testCDRsOnExpAMQPQueuesCreation(t *testing.T) { // Connect rpc client to rater func testCDRsOnExpInitMasterRPC(t *testing.T) { var err error - cdrsMasterRpc, err = rpcclient.NewRpcClient("tcp", cdrsMasterCfg.ListenCfg().RPCJSONListen, false, "", "", "", 1, 1, - time.Duration(1*time.Second), time.Duration(2*time.Second), "json", nil, false) + cdrsMasterRpc, err = rpcclient.NewRPCClient(utils.TCP, cdrsMasterCfg.ListenCfg().RPCJSONListen, false, "", "", "", 1, 1, + time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSONrpc, nil, false) if err != nil { t.Fatal("Could not connect to rater: ", err.Error()) } @@ -240,8 +240,8 @@ func testCDRsOnExpHttpCdrReplication(t *testing.T) { t.Error("Unexpected reply received: ", reply) } time.Sleep(time.Duration(*waitRater) * time.Millisecond) - cdrsSlaveRpc, err := rpcclient.NewRpcClient("tcp", "127.0.0.1:12012", false, "", "", "", 1, 1, - time.Duration(1*time.Second), time.Duration(2*time.Second), "json", nil, false) + cdrsSlaveRpc, err := rpcclient.NewRPCClient(utils.TCP, "127.0.0.1:12012", false, "", "", "", 1, 1, + time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSONrpc, nil, false) if err != nil { t.Fatal("Could not connect to rater: ", err.Error()) } diff --git a/general_tests/dest_management_it_test.go b/general_tests/dest_management_it_test.go index abd3a1eb8..e8ae994b7 100644 --- a/general_tests/dest_management_it_test.go +++ b/general_tests/dest_management_it_test.go @@ -101,7 +101,7 @@ func testDestManagStartEngine(t *testing.T) { // Connect rpc client to rater func testDestManagRpcConn(t *testing.T) { var err error - destRPC, err = jsonrpc.Dial("tcp", destCfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + destRPC, err = jsonrpc.Dial(utils.TCP, destCfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/general_tests/oldtutorial_it_test.go b/general_tests/oldtutorial_it_test.go index 3aa19f7e0..b8de93987 100644 --- a/general_tests/oldtutorial_it_test.go +++ b/general_tests/oldtutorial_it_test.go @@ -78,7 +78,7 @@ package general_tests // // Connect rpc client to rater // func TestTutITRpcConn(t *testing.T) { // var err error -// tutLocalRpc, err = jsonrpc.Dial("tcp", tutFsLocalCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed +// tutLocalRpc, err = jsonrpc.Dial(utils.TCP, tutFsLocalCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed // if err != nil { // t.Fatal(err) // } @@ -141,7 +141,7 @@ package general_tests // t.Fatal(err) // } // var err error -// tutLocalRpc, err = jsonrpc.Dial("tcp", tutFsLocalCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed +// tutLocalRpc, err = jsonrpc.Dial(utils.TCP, tutFsLocalCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed // if err != nil { // t.Fatal(err) // } diff --git a/general_tests/rpcclient_it_test.go b/general_tests/rpcclient_it_test.go index 0db1ff53d..679d68f78 100644 --- a/general_tests/rpcclient_it_test.go +++ b/general_tests/rpcclient_it_test.go @@ -40,8 +40,8 @@ var testRemoteRALs = flag.Bool("remote_rals", false, "Perform the tests in integ var ( // shared vars rpcITCfgPath1, rpcITCfgPath2 string rpcITCfg1, rpcITCfg2 *config.CGRConfig - rpcRAL1, rpcRAL2 *rpcclient.RpcClient - rpcPoolFirst, rpcPoolBroadcast *rpcclient.RpcClientPool + rpcRAL1, rpcRAL2 *rpcclient.RPCClient + rpcPoolFirst, rpcPoolBroadcast *rpcclient.RPCPool ral1, ral2 *exec.Cmd err error node1 = "node1" @@ -102,15 +102,15 @@ func testRPCITLclStartSecondEngine(t *testing.T) { // Connect rpc client to rater func testRPCITLclRpcConnPoolFirst(t *testing.T) { - rpcPoolFirst = rpcclient.NewRpcClientPool(rpcclient.POOL_FIRST, 0) - rpcRAL1, err = rpcclient.NewRpcClient("tcp", rpcITCfg1.ListenCfg().RPCJSONListen, false, "", "", "", 3, 1, - time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSON_RPC, nil, false) + rpcPoolFirst = rpcclient.NewRPCPool(rpcclient.PoolFirst, 0) + rpcRAL1, err = rpcclient.NewRPCClient(utils.TCP, rpcITCfg1.ListenCfg().RPCJSONListen, false, "", "", "", 3, 1, + time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSONrpc, nil, false) if err == nil { t.Fatal("Should receive cannot connect error here") } rpcPoolFirst.AddClient(rpcRAL1) - rpcRAL2, err = rpcclient.NewRpcClient("tcp", rpcITCfg2.ListenCfg().RPCJSONListen, false, "", "", "", 3, 1, - time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSON_RPC, nil, false) + rpcRAL2, err = rpcclient.NewRPCClient(utils.TCP, rpcITCfg2.ListenCfg().RPCJSONListen, false, "", "", "", 3, 1, + time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSONrpc, nil, false) if err != nil { t.Fatal(err) } @@ -213,7 +213,7 @@ func testRPCITLclTDirectedRPC(t *testing.T) { // Connect rpc client to rater func testRPCITLclRpcConnPoolBcast(t *testing.T) { - rpcPoolBroadcast = rpcclient.NewRpcClientPool(rpcclient.POOL_BROADCAST, time.Duration(2*time.Second)) + rpcPoolBroadcast = rpcclient.NewRPCPool(rpcclient.PoolBroadcast, time.Duration(2*time.Second)) rpcPoolBroadcast.AddClient(rpcRAL1) rpcPoolBroadcast.AddClient(rpcRAL2) } @@ -336,15 +336,15 @@ func TestRPCITRmtRpcConnPool(t *testing.T) { if !*testRemoteRALs { return } - rpcPoolFirst = rpcclient.NewRpcClientPool(rpcclient.POOL_FIRST, 0) - rpcRALRmt, err := rpcclient.NewRpcClient("tcp", RemoteRALsAddr1, false, "", "", "", 1, 1, - time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSON_RPC, nil, false) + rpcPoolFirst = rpcclient.NewRPCPool(rpcclient.PoolFirst, 0) + rpcRALRmt, err := rpcclient.NewRPCClient(utils.TCP, RemoteRALsAddr1, false, "", "", "", 1, 1, + time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSONrpc, nil, false) if err != nil { t.Fatal(err) } rpcPoolFirst.AddClient(rpcRALRmt) - rpcRAL1, err = rpcclient.NewRpcClient("tcp", RemoteRALsAddr2, false, "", "", "", 1, 1, - time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSON_RPC, nil, false) + rpcRAL1, err = rpcclient.NewRPCClient(utils.TCP, RemoteRALsAddr2, false, "", "", "", 1, 1, + time.Duration(1*time.Second), time.Duration(2*time.Second), rpcclient.JSONrpc, nil, false) if err != nil { t.Fatal(err) } diff --git a/general_tests/tls_it_test.go b/general_tests/tls_it_test.go index 9a1dbb678..2a4d0bd20 100755 --- a/general_tests/tls_it_test.go +++ b/general_tests/tls_it_test.go @@ -34,9 +34,9 @@ import ( var ( tlsCfgPath string tlsCfg *config.CGRConfig - tlsRpcClientJson *rpcclient.RpcClient - tlsRpcClientGob *rpcclient.RpcClient - tlsHTTPJson *rpcclient.RpcClient + tlsRpcClientJson *rpcclient.RPCClient + tlsRpcClientGob *rpcclient.RPCClient + tlsHTTPJson *rpcclient.RPCClient tlsConfDIR string //run tests for specific configuration tlsDelay int @@ -84,23 +84,23 @@ func testTLSStartEngine(t *testing.T) { func testTLSRpcConn(t *testing.T) { var err error - tlsRpcClientJson, err = rpcclient.NewRpcClient("tcp", "localhost:2022", true, tlsCfg.TlsCfg().ClientKey, + tlsRpcClientJson, err = rpcclient.NewRPCClient(utils.TCP, "localhost:2022", true, tlsCfg.TlsCfg().ClientKey, tlsCfg.TlsCfg().ClientCerificate, tlsCfg.TlsCfg().CaCertificate, 3, 3, - time.Duration(1*time.Second), time.Duration(5*time.Minute), utils.JSON, nil, false) + time.Duration(1*time.Second), time.Duration(5*time.Minute), rpcclient.JSONrpc, nil, false) if err != nil { t.Errorf("Error: %s when dialing", err) } - tlsRpcClientGob, err = rpcclient.NewRpcClient("tcp", "localhost:2023", true, tlsCfg.TlsCfg().ClientKey, + tlsRpcClientGob, err = rpcclient.NewRPCClient(utils.TCP, "localhost:2023", true, tlsCfg.TlsCfg().ClientKey, tlsCfg.TlsCfg().ClientCerificate, tlsCfg.TlsCfg().CaCertificate, 3, 3, - time.Duration(1*time.Second), time.Duration(5*time.Minute), utils.GOB, nil, false) + time.Duration(1*time.Second), time.Duration(5*time.Minute), rpcclient.GOBrpc, nil, false) if err != nil { t.Errorf("Error: %s when dialing", err) } - tlsHTTPJson, err = rpcclient.NewRpcClient("tcp", "https://localhost:2280/jsonrpc", true, tlsCfg.TlsCfg().ClientKey, + tlsHTTPJson, err = rpcclient.NewRPCClient(utils.TCP, "https://localhost:2280/jsonrpc", true, tlsCfg.TlsCfg().ClientKey, tlsCfg.TlsCfg().ClientCerificate, tlsCfg.TlsCfg().CaCertificate, 3, 3, - time.Duration(1*time.Second), time.Duration(5*time.Minute), rpcclient.JSON_HTTP, nil, false) + time.Duration(1*time.Second), time.Duration(5*time.Minute), rpcclient.HTTPjson, nil, false) if err != nil { t.Errorf("Error: %s when dialing", err) } diff --git a/general_tests/tutorial_calls_test.go b/general_tests/tutorial_calls_test.go index 215c710a9..de474d3b8 100755 --- a/general_tests/tutorial_calls_test.go +++ b/general_tests/tutorial_calls_test.go @@ -243,7 +243,7 @@ func testCallRestartFS(t *testing.T) { // Connect rpc client to rater func testCallRpcConn(t *testing.T) { var err error - tutorialCallsRpc, err = jsonrpc.Dial("tcp", tutorialCallsCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tutorialCallsRpc, err = jsonrpc.Dial(utils.TCP, tutorialCallsCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/go.mod b/go.mod index 17213b96c..b781a9eae 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/cgrates/kamevapi v0.0.0-20191001125829-7dbc3ad58817 github.com/cgrates/ltcache v0.0.0-20181016092649-92fb7fa77cca github.com/cgrates/radigo v0.0.0-20181207143118-e5c8f3272ccc - github.com/cgrates/rpcclient v0.0.0-20191115092211-732f09b356e3 + github.com/cgrates/rpcclient v0.0.0-20191209100218-70f91dc30ac6 github.com/creack/pty v1.1.7 github.com/fiorix/go-diameter v3.0.3-0.20190716165154-f4823472d0e0+incompatible github.com/fortytw2/leaktest v1.3.0 // indirect diff --git a/go.sum b/go.sum index 17a56f6c4..5a9ffc607 100644 --- a/go.sum +++ b/go.sum @@ -69,6 +69,8 @@ github.com/cgrates/rpcclient v0.0.0-20190505150825-8fcc68b2c38b h1:GC+/hEDN/2Frh github.com/cgrates/rpcclient v0.0.0-20190505150825-8fcc68b2c38b/go.mod h1:Jy5Lv0y57OlxlNATKrkyAxgftYLHqXuxONgd4qsAC1U= github.com/cgrates/rpcclient v0.0.0-20191115092211-732f09b356e3 h1:Hr038ZfPZz87OKLV4pRSzf3U06lZ8zjl/cXpwrv7hCM= github.com/cgrates/rpcclient v0.0.0-20191115092211-732f09b356e3/go.mod h1:Jy5Lv0y57OlxlNATKrkyAxgftYLHqXuxONgd4qsAC1U= +github.com/cgrates/rpcclient v0.0.0-20191209100218-70f91dc30ac6 h1:g1LZmbYvqYkGAxM4/bNfTcBooCFf0lK2mgrp3yZERL0= +github.com/cgrates/rpcclient v0.0.0-20191209100218-70f91dc30ac6/go.mod h1:xXLqAKVvcdWeDYwHJYwDgAI3ZOg5LZYxzb72kLjsLZU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/creack/pty v1.1.7 h1:6pwm8kMQKCmgUg0ZHTm5+/YvRK0s3THD/28+T6/kk4A= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= diff --git a/loaders/loader.go b/loaders/loader.go index ac43501ef..aa44025a9 100644 --- a/loaders/loader.go +++ b/loaders/loader.go @@ -42,7 +42,7 @@ type openedCSVFile struct { func NewLoader(dm *engine.DataManager, cfg *config.LoaderSCfg, timezone string, exitChan chan bool, filterS *engine.FilterS, - internalCacheSChan chan rpcclient.RpcClientConnection) (ldr *Loader) { + internalCacheSChan chan rpcclient.ClientConnector) (ldr *Loader) { ldr = &Loader{ enabled: cfg.Enabled, tenant: cfg.Tenant, @@ -75,9 +75,9 @@ func NewLoader(dm *engine.DataManager, cfg *config.LoaderSCfg, } var err error //create cache connection - var caches *rpcclient.RpcClientPool + var caches *rpcclient.RPCPool if len(cfg.CacheSConns) != 0 { - caches, err = engine.NewRPCPool(rpcclient.POOL_FIRST, + caches, err = engine.NewRPCPool(rpcclient.PoolFirst, config.CgrConfig().TlsCfg().ClientKey, config.CgrConfig().TlsCfg().ClientCerificate, config.CgrConfig().TlsCfg().CaCertificate, config.CgrConfig().GeneralCfg().ConnectAttempts, config.CgrConfig().GeneralCfg().Reconnects, @@ -115,7 +115,7 @@ type Loader struct { dm *engine.DataManager timezone string filterS *engine.FilterS - cacheS rpcclient.RpcClientConnection + cacheS rpcclient.ClientConnector } func (ldr *Loader) ListenAndServe(exitChan chan struct{}) (err error) { diff --git a/loaders/loaders.go b/loaders/loaders.go index d98cec9ac..e70ba144b 100644 --- a/loaders/loaders.go +++ b/loaders/loaders.go @@ -31,7 +31,7 @@ import ( func NewLoaderService(dm *engine.DataManager, ldrsCfg []*config.LoaderSCfg, timezone string, exitChan chan bool, filterS *engine.FilterS, - internalCacheSChan chan rpcclient.RpcClientConnection) (ldrS *LoaderService) { + internalCacheSChan chan rpcclient.ClientConnector) (ldrS *LoaderService) { ldrS = &LoaderService{ldrs: make(map[string]*Loader)} for _, ldrCfg := range ldrsCfg { if !ldrCfg.Enabled { @@ -148,7 +148,7 @@ func (ldrS *LoaderService) V1Remove(args *ArgsProcessFolder, // Reload recreates the loaders map thread safe func (ldrS *LoaderService) Reload(dm *engine.DataManager, ldrsCfg []*config.LoaderSCfg, timezone string, exitChan chan bool, filterS *engine.FilterS, - internalCacheSChan chan rpcclient.RpcClientConnection) { + internalCacheSChan chan rpcclient.ClientConnector) { ldrS.Lock() ldrS.ldrs = make(map[string]*Loader) for _, ldrCfg := range ldrsCfg { diff --git a/services/analyzers.go b/services/analyzers.go index 6c0858f10..2e3b1effe 100644 --- a/services/analyzers.go +++ b/services/analyzers.go @@ -33,7 +33,7 @@ import ( // NewAnalyzerService returns the Analyzer Service func NewAnalyzerService(cfg *config.CGRConfig, server *utils.Server, exitChan chan bool) servmanager.Service { return &AnalyzerService{ - connChan: make(chan rpcclient.RpcClientConnection, 1), + connChan: make(chan rpcclient.ClientConnector, 1), cfg: cfg, server: server, exitChan: exitChan, @@ -49,7 +49,7 @@ type AnalyzerService struct { anz *analyzers.AnalyzerService rpc *v1.AnalyzerSv1 - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector } // Start should handle the sercive start @@ -78,7 +78,7 @@ func (anz *AnalyzerService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (anz *AnalyzerService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (anz *AnalyzerService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return anz.connChan } diff --git a/services/apierv1.go b/services/apierv1.go index 90e93ce10..b1157d0ea 100644 --- a/services/apierv1.go +++ b/services/apierv1.go @@ -33,11 +33,11 @@ import ( func NewApierV1Service(cfg *config.CGRConfig, dm *DataDBService, storDB *StorDBService, filterSChan chan *engine.FilterS, server *utils.Server, cacheSChan, schedChan, attrsChan, - dispatcherChan chan rpcclient.RpcClientConnection, + dispatcherChan chan rpcclient.ClientConnector, schedService *SchedulerService, responderService *ResponderService) *ApierV1Service { return &ApierV1Service{ - connChan: make(chan rpcclient.RpcClientConnection, 1), + connChan: make(chan rpcclient.ClientConnector, 1), cfg: cfg, dm: dm, storDB: storDB, @@ -60,15 +60,15 @@ type ApierV1Service struct { storDB *StorDBService filterSChan chan *engine.FilterS server *utils.Server - cacheSChan chan rpcclient.RpcClientConnection - schedChan chan rpcclient.RpcClientConnection - attrsChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + cacheSChan chan rpcclient.ClientConnector + schedChan chan rpcclient.ClientConnector + attrsChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector schedService *SchedulerService responderService *ResponderService api *v1.ApierV1 - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector } // Start should handle the sercive start @@ -85,7 +85,7 @@ func (api *ApierV1Service) Start() (err error) { defer api.Unlock() // create cache connection - var cacheSrpc, schedulerSrpc, attributeSrpc rpcclient.RpcClientConnection + var cacheSrpc, schedulerSrpc, attributeSrpc rpcclient.ClientConnector if cacheSrpc, err = NewConnection(api.cfg, api.cacheSChan, api.dispatcherChan, api.cfg.ApierCfg().CachesConns); err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to %s, error: %s", utils.ApierV1, utils.CacheS, err.Error())) @@ -135,13 +135,13 @@ func (api *ApierV1Service) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (api *ApierV1Service) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (api *ApierV1Service) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return api.connChan } // Reload handles the change of config func (api *ApierV1Service) Reload() (err error) { - var cacheSrpc, schedulerSrpc, attributeSrpc rpcclient.RpcClientConnection + var cacheSrpc, schedulerSrpc, attributeSrpc rpcclient.ClientConnector if cacheSrpc, err = NewConnection(api.cfg, api.cacheSChan, api.dispatcherChan, api.cfg.ApierCfg().CachesConns); err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to %s, error: %s", utils.ApierV1, utils.CacheS, err.Error())) diff --git a/services/apierv2.go b/services/apierv2.go index c7997c147..256791f11 100644 --- a/services/apierv2.go +++ b/services/apierv2.go @@ -33,7 +33,7 @@ func NewApierV2Service(apiv1 *ApierV1Service, cfg *config.CGRConfig, server *utils.Server) *ApierV2Service { return &ApierV2Service{ apiv1: apiv1, - connChan: make(chan rpcclient.RpcClientConnection, 1), + connChan: make(chan rpcclient.ClientConnector, 1), cfg: cfg, server: server, } @@ -47,7 +47,7 @@ type ApierV2Service struct { apiv1 *ApierV1Service api *v2.ApierV2 - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector } // Start should handle the sercive start @@ -76,7 +76,7 @@ func (api *ApierV2Service) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (api *ApierV2Service) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (api *ApierV2Service) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return api.connChan } diff --git a/services/asteriskagent.go b/services/asteriskagent.go index 54c0f23d8..1d5d0fa83 100644 --- a/services/asteriskagent.go +++ b/services/asteriskagent.go @@ -32,7 +32,7 @@ import ( // NewAsteriskAgent returns the Asterisk Agent func NewAsteriskAgent(cfg *config.CGRConfig, sSChan, - dispatcherChan chan rpcclient.RpcClientConnection, + dispatcherChan chan rpcclient.ClientConnector, exitChan chan bool) servmanager.Service { return &AsteriskAgent{ cfg: cfg, @@ -46,8 +46,8 @@ func NewAsteriskAgent(cfg *config.CGRConfig, sSChan, type AsteriskAgent struct { sync.RWMutex cfg *config.CGRConfig - sSChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + sSChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector exitChan chan bool smas []*agents.AsteriskAgent @@ -61,7 +61,7 @@ func (ast *AsteriskAgent) Start() (err error) { ast.Lock() defer ast.Unlock() - var sS rpcclient.RpcClientConnection + var sS rpcclient.ClientConnector var sSInternal bool utils.Logger.Info("Starting Asterisk agent") if !ast.cfg.DispatcherSCfg().Enabled && ast.cfg.AsteriskAgentCfg().SessionSConns[0].Address == utils.MetaInternal { @@ -105,13 +105,13 @@ func (ast *AsteriskAgent) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (ast *AsteriskAgent) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (ast *AsteriskAgent) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return nil } // Reload handles the change of config func (ast *AsteriskAgent) Reload() (err error) { - var sS rpcclient.RpcClientConnection + var sS rpcclient.ClientConnector var sSInternal bool if !ast.cfg.DispatcherSCfg().Enabled && ast.cfg.AsteriskAgentCfg().SessionSConns[0].Address == utils.MetaInternal { sSInternal = true diff --git a/services/attributes.go b/services/attributes.go index 420320cf3..1fa3a8a53 100644 --- a/services/attributes.go +++ b/services/attributes.go @@ -33,7 +33,7 @@ import ( // NewAttributeService returns the Attribute Service func NewAttributeService(cfg *config.CGRConfig, dm *DataDBService, cacheS *engine.CacheS, filterSChan chan *engine.FilterS, - server *utils.Server, internalChan chan rpcclient.RpcClientConnection) servmanager.Service { + server *utils.Server, internalChan chan rpcclient.ClientConnector) servmanager.Service { return &AttributeService{ connChan: internalChan, cfg: cfg, @@ -55,7 +55,7 @@ type AttributeService struct { attrS *engine.AttributeService rpc *v1.AttributeSv1 - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector } // Start should handle the sercive start @@ -89,7 +89,7 @@ func (attrS *AttributeService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (attrS *AttributeService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (attrS *AttributeService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return attrS.connChan } diff --git a/services/attributes_it_test.go b/services/attributes_it_test.go index e8e4bdd0b..e7bb0150d 100644 --- a/services/attributes_it_test.go +++ b/services/attributes_it_test.go @@ -50,7 +50,7 @@ func TestAttributeSReload(t *testing.T) { srvMngr := servmanager.NewServiceManager(cfg, engineShutdown) db := NewDataDBService(cfg) attrS := NewAttributeService(cfg, db, - chS, filterSChan, server, make(chan rpcclient.RpcClientConnection, 1), + chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1), ) srvMngr.AddServices(NewConnManagerService(cfg, nil), attrS, NewLoaderService(cfg, db, filterSChan, server, nil, nil, engineShutdown), db) diff --git a/services/cdrs.go b/services/cdrs.go index 9c1f5548e..e29a83dbe 100644 --- a/services/cdrs.go +++ b/services/cdrs.go @@ -35,7 +35,7 @@ import ( func NewCDRServer(cfg *config.CGRConfig, dm *DataDBService, storDB *StorDBService, filterSChan chan *engine.FilterS, server *utils.Server, internalCDRServerChan, chrsChan, respChan, attrsChan, thsChan, stsChan, - dispatcherChan chan rpcclient.RpcClientConnection) servmanager.Service { + dispatcherChan chan rpcclient.ClientConnector) servmanager.Service { return &CDRServer{ connChan: internalCDRServerChan, cfg: cfg, @@ -60,17 +60,17 @@ type CDRServer struct { storDB *StorDBService filterSChan chan *engine.FilterS server *utils.Server - chrsChan chan rpcclient.RpcClientConnection - respChan chan rpcclient.RpcClientConnection - attrsChan chan rpcclient.RpcClientConnection - thsChan chan rpcclient.RpcClientConnection - stsChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + chrsChan chan rpcclient.ClientConnector + respChan chan rpcclient.ClientConnector + attrsChan chan rpcclient.ClientConnector + thsChan chan rpcclient.ClientConnector + stsChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector cdrS *engine.CDRServer rpcv1 *v1.CDRsV1 rpcv2 *v2.CDRsV2 - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector } // Start should handle the sercive start @@ -84,7 +84,7 @@ func (cdrS *CDRServer) Start() (err error) { filterS := <-cdrS.filterSChan cdrS.filterSChan <- filterS - var ralConn, attrSConn, thresholdSConn, statsConn, chargerSConn rpcclient.RpcClientConnection + var ralConn, attrSConn, thresholdSConn, statsConn, chargerSConn rpcclient.ClientConnector chargerSConn, err = NewConnection(cdrS.cfg, cdrS.chrsChan, cdrS.dispatcherChan, cdrS.cfg.CdrsCfg().ChargerSConns) if err != nil { @@ -134,13 +134,13 @@ func (cdrS *CDRServer) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (cdrS *CDRServer) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (cdrS *CDRServer) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return cdrS.connChan } // Reload handles the change of config func (cdrS *CDRServer) Reload() (err error) { - var ralConn, attrSConn, thresholdSConn, statsConn, chargerSConn rpcclient.RpcClientConnection + var ralConn, attrSConn, thresholdSConn, statsConn, chargerSConn rpcclient.ClientConnector chargerSConn, err = NewConnection(cdrS.cfg, cdrS.chrsChan, cdrS.dispatcherChan, cdrS.cfg.CdrsCfg().ChargerSConns) if err != nil { diff --git a/services/cdrs_it_test.go b/services/cdrs_it_test.go index b56118475..2dd3418a3 100644 --- a/services/cdrs_it_test.go +++ b/services/cdrs_it_test.go @@ -59,9 +59,9 @@ func TestCdrsReload(t *testing.T) { cfg.ChargerSCfg().Enabled = true cfg.RalsCfg().Enabled = true - internalChan := make(chan rpcclient.RpcClientConnection, 1) + internalChan := make(chan rpcclient.ClientConnector, 1) internalChan <- nil - cacheSChan := make(chan rpcclient.RpcClientConnection, 1) + cacheSChan := make(chan rpcclient.ClientConnector, 1) cacheSChan <- chS server := utils.NewServer() srvMngr := servmanager.NewServiceManager(cfg, engineShutdown) @@ -69,13 +69,13 @@ func TestCdrsReload(t *testing.T) { cfg.StorDbCfg().Type = utils.INTERNAL stordb := NewStorDBService(cfg) chrS := NewChargerService(cfg, db, chS, filterSChan, server, nil, nil) - schS := NewSchedulerService(cfg, db, chS, filterSChan, server, make(chan rpcclient.RpcClientConnection, 1), nil) + schS := NewSchedulerService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1), nil) tS := NewThresholdService(cfg, db, chS, filterSChan, server) ralS := NewRalService(cfg, db, stordb, chS, filterSChan, server, tS.GetIntenternalChan(), internalChan, cacheSChan, internalChan, internalChan, internalChan, schS, engineShutdown) cdrS := NewCDRServer(cfg, db, stordb, filterSChan, server, - make(chan rpcclient.RpcClientConnection, 1), + make(chan rpcclient.ClientConnector, 1), chrS.GetIntenternalChan(), ralS.GetResponder().GetIntenternalChan(), nil, nil, nil, nil) srvMngr.AddServices(NewConnManagerService(cfg, nil), cdrS, ralS, schS, chrS, NewLoaderService(cfg, db, filterSChan, server, cacheSChan, nil, engineShutdown), db, stordb) diff --git a/services/chargers.go b/services/chargers.go index 362a3141e..b70eb9ef9 100644 --- a/services/chargers.go +++ b/services/chargers.go @@ -33,9 +33,9 @@ import ( // NewChargerService returns the Charger Service func NewChargerService(cfg *config.CGRConfig, dm *DataDBService, cacheS *engine.CacheS, filterSChan chan *engine.FilterS, server *utils.Server, - attrsChan, dispatcherChan chan rpcclient.RpcClientConnection) servmanager.Service { + attrsChan, dispatcherChan chan rpcclient.ClientConnector) servmanager.Service { return &ChargerService{ - connChan: make(chan rpcclient.RpcClientConnection, 1), + connChan: make(chan rpcclient.ClientConnector, 1), cfg: cfg, dm: dm, cacheS: cacheS, @@ -54,12 +54,12 @@ type ChargerService struct { cacheS *engine.CacheS filterSChan chan *engine.FilterS server *utils.Server - attrsChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + attrsChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector chrS *engine.ChargerService rpc *v1.ChargerSv1 - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector } // Start should handle the sercive start @@ -74,7 +74,7 @@ func (chrS *ChargerService) Start() (err error) { filterS := <-chrS.filterSChan chrS.filterSChan <- filterS - var attrSConn rpcclient.RpcClientConnection + var attrSConn rpcclient.ClientConnector if attrSConn, err = NewConnection(chrS.cfg, chrS.attrsChan, chrS.dispatcherChan, chrS.cfg.ChargerSCfg().AttributeSConns); err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to %s: %s", utils.ChargerS, utils.AttributeS, err.Error())) @@ -98,13 +98,13 @@ func (chrS *ChargerService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (chrS *ChargerService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (chrS *ChargerService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return chrS.connChan } // Reload handles the change of config func (chrS *ChargerService) Reload() (err error) { - var attrSConn rpcclient.RpcClientConnection + var attrSConn rpcclient.ClientConnector if attrSConn, err = NewConnection(chrS.cfg, chrS.attrsChan, chrS.dispatcherChan, chrS.cfg.ChargerSCfg().AttributeSConns); err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to %s: %s", utils.ChargerS, utils.AttributeS, err.Error())) diff --git a/services/chargers_it_test.go b/services/chargers_it_test.go index 9dc9c0e88..75d6f3010 100644 --- a/services/chargers_it_test.go +++ b/services/chargers_it_test.go @@ -51,7 +51,7 @@ func TestChargerSReload(t *testing.T) { server := utils.NewServer() srvMngr := servmanager.NewServiceManager(cfg, engineShutdown) db := NewDataDBService(cfg) - attrS := NewAttributeService(cfg, db, chS, filterSChan, server, make(chan rpcclient.RpcClientConnection, 1)) + attrS := NewAttributeService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1)) chrS := NewChargerService(cfg, db, chS, filterSChan, server, attrS.GetIntenternalChan(), nil) srvMngr.AddServices(NewConnManagerService(cfg, nil), attrS, chrS, NewLoaderService(cfg, db, filterSChan, server, nil, nil, engineShutdown), db) if err = srvMngr.StartServices(); err != nil { diff --git a/services/connmanager.go b/services/connmanager.go index 5c6e36152..1bfa9ea10 100644 --- a/services/connmanager.go +++ b/services/connmanager.go @@ -27,7 +27,7 @@ import ( "github.com/cgrates/rpcclient" ) -func NewConnManagerService(cfg *config.CGRConfig, intConns map[string]chan rpcclient.RpcClientConnection) *ConnManagerService { +func NewConnManagerService(cfg *config.CGRConfig, intConns map[string]chan rpcclient.ClientConnector) *ConnManagerService { return &ConnManagerService{ cfg: cfg, connMgr: engine.NewConnManager(cfg, intConns), @@ -46,7 +46,7 @@ func (cM *ConnManagerService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (cM *ConnManagerService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (cM *ConnManagerService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return nil } diff --git a/services/datadb.go b/services/datadb.go index f5eec787e..c9492405f 100644 --- a/services/datadb.go +++ b/services/datadb.go @@ -69,10 +69,10 @@ func (db *DataDBService) Start() (err error) { err = nil // reset the error in case of only SessionS active return } - var rmtConns, rplConns *rpcclient.RpcClientPool + var rmtConns, rplConns *rpcclient.RPCPool if len(db.cfg.DataDbCfg().RmtConns) != 0 { var err error - rmtConns, err = engine.NewRPCPool(rpcclient.POOL_FIRST_POSITIVE, db.cfg.TlsCfg().ClientKey, + rmtConns, err = engine.NewRPCPool(rpcclient.PoolFirstPositive, db.cfg.TlsCfg().ClientKey, db.cfg.TlsCfg().ClientCerificate, db.cfg.TlsCfg().CaCertificate, db.cfg.GeneralCfg().ConnectAttempts, db.cfg.GeneralCfg().Reconnects, db.cfg.GeneralCfg().ConnectTimeout, db.cfg.GeneralCfg().ReplyTimeout, @@ -83,7 +83,7 @@ func (db *DataDBService) Start() (err error) { } if len(config.CgrConfig().DataDbCfg().RplConns) != 0 { var err error - rplConns, err = engine.NewRPCPool(rpcclient.POOL_BROADCAST, db.cfg.TlsCfg().ClientKey, + rplConns, err = engine.NewRPCPool(rpcclient.PoolBroadcast, db.cfg.TlsCfg().ClientKey, db.cfg.TlsCfg().ClientCerificate, db.cfg.TlsCfg().CaCertificate, db.cfg.GeneralCfg().ConnectAttempts, db.cfg.GeneralCfg().Reconnects, db.cfg.GeneralCfg().ConnectTimeout, db.cfg.GeneralCfg().ReplyTimeout, @@ -103,7 +103,7 @@ func (db *DataDBService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (db *DataDBService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (db *DataDBService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return nil } diff --git a/services/datadb_it_test.go b/services/datadb_it_test.go index 839004497..528fee366 100644 --- a/services/datadb_it_test.go +++ b/services/datadb_it_test.go @@ -51,7 +51,7 @@ func TestDataDBReload(t *testing.T) { srvMngr := servmanager.NewServiceManager(cfg, engineShutdown) db := NewDataDBService(cfg) srvMngr.AddServices(NewConnManagerService(cfg, nil), NewAttributeService(cfg, db, - chS, filterSChan, server, make(chan rpcclient.RpcClientConnection, 1)), + chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1)), NewLoaderService(cfg, db, filterSChan, server, nil, nil, engineShutdown), db) if err = srvMngr.StartServices(); err != nil { t.Error(err) diff --git a/services/diameteragent.go b/services/diameteragent.go index 7f66bd22b..b4fe771c5 100644 --- a/services/diameteragent.go +++ b/services/diameteragent.go @@ -33,7 +33,7 @@ import ( // NewDiameterAgent returns the Diameter Agent func NewDiameterAgent(cfg *config.CGRConfig, filterSChan chan *engine.FilterS, - sSChan, dispatcherChan chan rpcclient.RpcClientConnection, + sSChan, dispatcherChan chan rpcclient.ClientConnector, exitChan chan bool) servmanager.Service { return &DiameterAgent{ cfg: cfg, @@ -49,8 +49,8 @@ type DiameterAgent struct { sync.RWMutex cfg *config.CGRConfig filterSChan chan *engine.FilterS - sSChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + sSChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector exitChan chan bool da *agents.DiameterAgent @@ -67,7 +67,7 @@ func (da *DiameterAgent) Start() (err error) { da.Lock() defer da.Unlock() - var sS rpcclient.RpcClientConnection + var sS rpcclient.ClientConnector var sSInternal bool utils.Logger.Info("Starting Diameter agent") if !da.cfg.DispatcherSCfg().Enabled && da.cfg.DiameterAgentCfg().SessionSConns[0].Address == utils.MetaInternal { @@ -112,13 +112,13 @@ func (da *DiameterAgent) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (da *DiameterAgent) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (da *DiameterAgent) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return nil } // Reload handles the change of config func (da *DiameterAgent) Reload() (err error) { - var sS rpcclient.RpcClientConnection + var sS rpcclient.ClientConnector var sSInternal bool if !da.cfg.DispatcherSCfg().Enabled && da.cfg.DiameterAgentCfg().SessionSConns[0].Address == utils.MetaInternal { sSInternal = true diff --git a/services/dispatchers.go b/services/dispatchers.go index 0f76990d2..4a364a541 100644 --- a/services/dispatchers.go +++ b/services/dispatchers.go @@ -34,7 +34,7 @@ import ( // NewDispatcherService returns the Dispatcher Service func NewDispatcherService(cfg *config.CGRConfig, dm *DataDBService, cacheS *engine.CacheS, filterSChan chan *engine.FilterS, - server *utils.Server, attrsChan, internalChan chan rpcclient.RpcClientConnection) servmanager.Service { + server *utils.Server, attrsChan, internalChan chan rpcclient.ClientConnector) servmanager.Service { return &DispatcherService{ connChan: internalChan, cfg: cfg, @@ -54,11 +54,11 @@ type DispatcherService struct { cacheS *engine.CacheS filterSChan chan *engine.FilterS server *utils.Server - attrsChan chan rpcclient.RpcClientConnection + attrsChan chan rpcclient.ClientConnector dspS *dispatchers.DispatcherService rpc *v1.DispatcherSv1 - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector } // Start should handle the sercive start @@ -76,9 +76,9 @@ func (dspS *DispatcherService) Start() (err error) { dspS.Lock() defer dspS.Unlock() - var attrSConn *rpcclient.RpcClientPool + var attrSConn *rpcclient.RPCPool if len(dspS.cfg.DispatcherSCfg().AttributeSConns) != 0 { // AttributeS connection init - if attrSConn, err = engine.NewRPCPool(rpcclient.POOL_FIRST, + if attrSConn, err = engine.NewRPCPool(rpcclient.PoolFirst, dspS.cfg.TlsCfg().ClientKey, dspS.cfg.TlsCfg().ClientCerificate, dspS.cfg.TlsCfg().CaCertificate, dspS.cfg.GeneralCfg().ConnectAttempts, dspS.cfg.GeneralCfg().Reconnects, @@ -151,7 +151,7 @@ func (dspS *DispatcherService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (dspS *DispatcherService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (dspS *DispatcherService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return dspS.connChan } diff --git a/services/dispatchers_it_test.go b/services/dispatchers_it_test.go index 9d6ae8f84..4c168ec3a 100644 --- a/services/dispatchers_it_test.go +++ b/services/dispatchers_it_test.go @@ -52,8 +52,8 @@ func TestDispatcherSReload(t *testing.T) { server := utils.NewServer() srvMngr := servmanager.NewServiceManager(cfg, engineShutdown) db := NewDataDBService(cfg) - attrS := NewAttributeService(cfg, db, chS, filterSChan, server, make(chan rpcclient.RpcClientConnection, 1)) - srv := NewDispatcherService(cfg, db, chS, filterSChan, server, attrS.GetIntenternalChan(), make(chan rpcclient.RpcClientConnection, 1)) + attrS := NewAttributeService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1)) + srv := NewDispatcherService(cfg, db, chS, filterSChan, server, attrS.GetIntenternalChan(), make(chan rpcclient.ClientConnector, 1)) srvMngr.AddServices(NewConnManagerService(cfg, nil), attrS, srv, NewLoaderService(cfg, db, filterSChan, server, nil, nil, engineShutdown), db) if err = srvMngr.StartServices(); err != nil { t.Error(err) diff --git a/services/dnsagent.go b/services/dnsagent.go index 2d8f55913..374df92bc 100644 --- a/services/dnsagent.go +++ b/services/dnsagent.go @@ -33,7 +33,7 @@ import ( // NewDNSAgent returns the DNS Agent func NewDNSAgent(cfg *config.CGRConfig, filterSChan chan *engine.FilterS, - sSChan, dispatcherChan chan rpcclient.RpcClientConnection, + sSChan, dispatcherChan chan rpcclient.ClientConnector, exitChan chan bool) servmanager.Service { return &DNSAgent{ cfg: cfg, @@ -49,8 +49,8 @@ type DNSAgent struct { sync.RWMutex cfg *config.CGRConfig filterSChan chan *engine.FilterS - sSChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + sSChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector exitChan chan bool dns *agents.DNSAgent @@ -68,7 +68,7 @@ func (dns *DNSAgent) Start() (err error) { dns.Lock() defer dns.Unlock() // var sSInternal bool - var sS rpcclient.RpcClientConnection + var sS rpcclient.ClientConnector utils.Logger.Info(fmt.Sprintf("starting %s service", utils.DNSAgent)) if !dns.cfg.DispatcherSCfg().Enabled && dns.cfg.DNSAgentCfg().SessionSConns[0].Address == utils.MetaInternal { // sSInternal = true @@ -109,13 +109,13 @@ func (dns *DNSAgent) Start() (err error) { // GetIntenternalChan returns the internal connection chanel // no chanel for DNSAgent -func (dns *DNSAgent) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (dns *DNSAgent) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return nil } // Reload handles the change of config func (dns *DNSAgent) Reload() (err error) { - var sS rpcclient.RpcClientConnection + var sS rpcclient.ClientConnector if !dns.cfg.DispatcherSCfg().Enabled && dns.cfg.DNSAgentCfg().SessionSConns[0].Address == utils.MetaInternal { // sSInternal = true sSIntConn := <-dns.sSChan diff --git a/services/dnsagent_it_test.go b/services/dnsagent_it_test.go index 30d91323d..aafc89b1e 100644 --- a/services/dnsagent_it_test.go +++ b/services/dnsagent_it_test.go @@ -44,7 +44,7 @@ func TestDNSAgentReload(t *testing.T) { engineShutdown := make(chan bool, 1) chS := engine.NewCacheS(cfg, nil) - cacheSChan := make(chan rpcclient.RpcClientConnection, 1) + cacheSChan := make(chan rpcclient.ClientConnector, 1) cacheSChan <- chS server := utils.NewServer() @@ -52,7 +52,7 @@ func TestDNSAgentReload(t *testing.T) { db := NewDataDBService(cfg) sS := NewSessionService(cfg, db, server, nil, nil, nil, nil, nil, - nil, nil, nil, nil, make(chan rpcclient.RpcClientConnection, 1), engineShutdown) + nil, nil, nil, nil, make(chan rpcclient.ClientConnector, 1), engineShutdown) srv := NewDNSAgent(cfg, filterSChan, sS.GetIntenternalChan(), nil, engineShutdown) srvMngr.AddServices(NewConnManagerService(cfg, nil), srv, sS, NewLoaderService(cfg, db, filterSChan, server, cacheSChan, nil, engineShutdown), db) if err = srvMngr.StartServices(); err != nil { diff --git a/services/ers.go b/services/ers.go index 58ac12d98..14b041d31 100644 --- a/services/ers.go +++ b/services/ers.go @@ -84,7 +84,7 @@ func (erS *EventReaderService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (erS *EventReaderService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (erS *EventReaderService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return nil } diff --git a/services/ers_it_test.go b/services/ers_it_test.go index 0b0736951..575bd13f0 100644 --- a/services/ers_it_test.go +++ b/services/ers_it_test.go @@ -57,7 +57,7 @@ func TestEventReaderSReload(t *testing.T) { db := NewDataDBService(cfg) sS := NewSessionService(cfg, db, server, nil, nil, nil, nil, nil, - nil, nil, nil, nil, make(chan rpcclient.RpcClientConnection, 1), engineShutdown) + nil, nil, nil, nil, make(chan rpcclient.ClientConnector, 1), engineShutdown) attrS := NewEventReaderService(cfg, filterSChan, engineShutdown, nil) srvMngr.AddServices(NewConnManagerService(cfg, nil), attrS, sS, NewLoaderService(cfg, db, filterSChan, server, nil, nil, engineShutdown), db) if err = srvMngr.StartServices(); err != nil { diff --git a/services/freeswitchagent.go b/services/freeswitchagent.go index 868918f22..a1fc321bd 100644 --- a/services/freeswitchagent.go +++ b/services/freeswitchagent.go @@ -32,7 +32,7 @@ import ( // NewFreeswitchAgent returns the Freeswitch Agent func NewFreeswitchAgent(cfg *config.CGRConfig, - sSChan, dispatcherChan chan rpcclient.RpcClientConnection, + sSChan, dispatcherChan chan rpcclient.ClientConnector, exitChan chan bool) servmanager.Service { return &FreeswitchAgent{ cfg: cfg, @@ -46,8 +46,8 @@ func NewFreeswitchAgent(cfg *config.CGRConfig, type FreeswitchAgent struct { sync.RWMutex cfg *config.CGRConfig - sSChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + sSChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector exitChan chan bool fS *agents.FSsessions @@ -61,7 +61,7 @@ func (fS *FreeswitchAgent) Start() (err error) { fS.Lock() defer fS.Unlock() - var sS rpcclient.RpcClientConnection + var sS rpcclient.ClientConnector var sSInternal bool utils.Logger.Info("Starting FreeSWITCH agent") if !fS.cfg.DispatcherSCfg().Enabled && fS.cfg.FsAgentCfg().SessionSConns[0].Address == utils.MetaInternal { @@ -99,13 +99,13 @@ func (fS *FreeswitchAgent) Start() (err error) { // GetIntenternalChan returns the internal connection chanel // no chanel for FreeswitchAgent -func (fS *FreeswitchAgent) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (fS *FreeswitchAgent) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return nil } // Reload handles the change of config func (fS *FreeswitchAgent) Reload() (err error) { - var sS rpcclient.RpcClientConnection + var sS rpcclient.ClientConnector var sSInternal bool if !fS.cfg.DispatcherSCfg().Enabled && fS.cfg.FsAgentCfg().SessionSConns[0].Address == utils.MetaInternal { sSInternal = true diff --git a/services/httpagent.go b/services/httpagent.go index e288ac8a9..301027132 100644 --- a/services/httpagent.go +++ b/services/httpagent.go @@ -32,7 +32,7 @@ import ( // NewHTTPAgent returns the HTTP Agent func NewHTTPAgent(cfg *config.CGRConfig, filterSChan chan *engine.FilterS, - sSChan, dispatcherChan chan rpcclient.RpcClientConnection, + sSChan, dispatcherChan chan rpcclient.ClientConnector, server *utils.Server) servmanager.Service { return &HTTPAgent{ cfg: cfg, @@ -48,8 +48,8 @@ type HTTPAgent struct { sync.RWMutex cfg *config.CGRConfig filterSChan chan *engine.FilterS - sSChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + sSChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector server *utils.Server ha *agents.HTTPAgent @@ -68,7 +68,7 @@ func (ha *HTTPAgent) Start() (err error) { defer ha.Unlock() utils.Logger.Info("Starting HTTP agent") for _, agntCfg := range ha.cfg.HttpAgentCfg() { - var sS rpcclient.RpcClientConnection + var sS rpcclient.ClientConnector if sS, err = NewConnection(ha.cfg, ha.sSChan, ha.dispatcherChan, agntCfg.SessionSConns); err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> could not connect to %s, error: %s", utils.HTTPAgent, utils.SessionS, err.Error())) @@ -82,7 +82,7 @@ func (ha *HTTPAgent) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (ha *HTTPAgent) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (ha *HTTPAgent) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return nil } diff --git a/services/kamailioagent.go b/services/kamailioagent.go index df0770d01..a100e1704 100644 --- a/services/kamailioagent.go +++ b/services/kamailioagent.go @@ -33,7 +33,7 @@ import ( // NewKamailioAgent returns the Kamailio Agent func NewKamailioAgent(cfg *config.CGRConfig, sSChan, - dispatcherChan chan rpcclient.RpcClientConnection, + dispatcherChan chan rpcclient.ClientConnector, exitChan chan bool) servmanager.Service { return &KamailioAgent{ cfg: cfg, @@ -47,8 +47,8 @@ func NewKamailioAgent(cfg *config.CGRConfig, sSChan, type KamailioAgent struct { sync.RWMutex cfg *config.CGRConfig - sSChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + sSChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector exitChan chan bool kam *agents.KamailioAgent @@ -62,7 +62,7 @@ func (kam *KamailioAgent) Start() (err error) { kam.Lock() defer kam.Unlock() - var sS rpcclient.RpcClientConnection + var sS rpcclient.ClientConnector var sSInternal bool utils.Logger.Info("Starting Kamailio agent") if !kam.cfg.DispatcherSCfg().Enabled && kam.cfg.KamAgentCfg().SessionSConns[0].Address == utils.MetaInternal { @@ -102,13 +102,13 @@ func (kam *KamailioAgent) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (kam *KamailioAgent) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (kam *KamailioAgent) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return nil } // Reload handles the change of config func (kam *KamailioAgent) Reload() (err error) { - var sS rpcclient.RpcClientConnection + var sS rpcclient.ClientConnector var sSInternal bool if !kam.cfg.DispatcherSCfg().Enabled && kam.cfg.KamAgentCfg().SessionSConns[0].Address == utils.MetaInternal { sSInternal = true diff --git a/services/loaders.go b/services/loaders.go index f73912be9..51612ba26 100644 --- a/services/loaders.go +++ b/services/loaders.go @@ -34,10 +34,10 @@ import ( // NewLoaderService returns the Loader Service func NewLoaderService(cfg *config.CGRConfig, dm *DataDBService, filterSChan chan *engine.FilterS, server *utils.Server, - cacheSChan, dispatcherChan chan rpcclient.RpcClientConnection, + cacheSChan, dispatcherChan chan rpcclient.ClientConnector, exitChan chan bool) servmanager.Service { return &LoaderService{ - connChan: make(chan rpcclient.RpcClientConnection, 1), + connChan: make(chan rpcclient.ClientConnector, 1), cfg: cfg, dm: dm, cacheSChan: cacheSChan, @@ -55,13 +55,13 @@ type LoaderService struct { dm *DataDBService filterSChan chan *engine.FilterS server *utils.Server - cacheSChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + cacheSChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector exitChan chan bool ldrs *loaders.LoaderService rpc *v1.LoaderSv1 - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector } // Start should handle the sercive start @@ -92,7 +92,7 @@ func (ldrs *LoaderService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (ldrs *LoaderService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (ldrs *LoaderService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return ldrs.connChan } diff --git a/services/radiusagent.go b/services/radiusagent.go index 04e5c409b..19fa54e32 100644 --- a/services/radiusagent.go +++ b/services/radiusagent.go @@ -32,7 +32,7 @@ import ( // NewRadiusAgent returns the Radius Agent func NewRadiusAgent(cfg *config.CGRConfig, filterSChan chan *engine.FilterS, - sSChan, dispatcherChan chan rpcclient.RpcClientConnection, + sSChan, dispatcherChan chan rpcclient.ClientConnector, exitChan chan bool) servmanager.Service { return &RadiusAgent{ cfg: cfg, @@ -48,8 +48,8 @@ type RadiusAgent struct { sync.RWMutex cfg *config.CGRConfig filterSChan chan *engine.FilterS - sSChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + sSChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector exitChan chan bool rad *agents.RadiusAgent @@ -66,7 +66,7 @@ func (rad *RadiusAgent) Start() (err error) { rad.Lock() defer rad.Unlock() - var smgConn rpcclient.RpcClientConnection + var smgConn rpcclient.ClientConnector utils.Logger.Info("Starting Radius agent") if smgConn, err = NewConnection(rad.cfg, rad.sSChan, rad.dispatcherChan, rad.cfg.RadiusAgentCfg().SessionSConns); err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to %s: %s", @@ -89,13 +89,13 @@ func (rad *RadiusAgent) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (rad *RadiusAgent) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (rad *RadiusAgent) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return nil } // Reload handles the change of config func (rad *RadiusAgent) Reload() (err error) { - var smgConn rpcclient.RpcClientConnection + var smgConn rpcclient.ClientConnector if smgConn, err = NewConnection(rad.cfg, rad.sSChan, rad.dispatcherChan, rad.cfg.RadiusAgentCfg().SessionSConns); err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to %s: %s", utils.RadiusAgent, utils.SessionS, err.Error())) diff --git a/services/rals.go b/services/rals.go index 49838110f..54d2a615a 100644 --- a/services/rals.go +++ b/services/rals.go @@ -33,13 +33,13 @@ import ( // NewRalService returns the Ral Service func NewRalService(cfg *config.CGRConfig, dm *DataDBService, storDB *StorDBService, cacheS *engine.CacheS, filterSChan chan *engine.FilterS, server *utils.Server, - thsChan, stsChan, cacheSChan, schedChan, attrsChan, dispatcherChan chan rpcclient.RpcClientConnection, + thsChan, stsChan, cacheSChan, schedChan, attrsChan, dispatcherChan chan rpcclient.ClientConnector, schedulerService *SchedulerService, exitChan chan bool) *RalService { resp := NewResponderService(cfg, server, thsChan, stsChan, dispatcherChan, exitChan) apiv1 := NewApierV1Service(cfg, dm, storDB, filterSChan, server, cacheSChan, schedChan, attrsChan, dispatcherChan, schedulerService, resp) apiv2 := NewApierV2Service(apiv1, cfg, server) return &RalService{ - connChan: make(chan rpcclient.RpcClientConnection, 1), + connChan: make(chan rpcclient.ClientConnector, 1), cfg: cfg, cacheS: cacheS, server: server, @@ -59,7 +59,7 @@ type RalService struct { apiv1 *ApierV1Service apiv2 *ApierV2Service responder *ResponderService - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector } // Start should handle the sercive start @@ -109,7 +109,7 @@ func (rals *RalService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (rals *RalService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (rals *RalService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return rals.connChan } diff --git a/services/rals_it_test.go b/services/rals_it_test.go index f900b5c14..ce3104ae4 100644 --- a/services/rals_it_test.go +++ b/services/rals_it_test.go @@ -58,16 +58,16 @@ func TestRalsReload(t *testing.T) { close(chS.GetPrecacheChannel(utils.CacheTimings)) cfg.ThresholdSCfg().Enabled = true - internalChan := make(chan rpcclient.RpcClientConnection, 1) + internalChan := make(chan rpcclient.ClientConnector, 1) internalChan <- nil - cacheSChan := make(chan rpcclient.RpcClientConnection, 1) + cacheSChan := make(chan rpcclient.ClientConnector, 1) cacheSChan <- chS server := utils.NewServer() srvMngr := servmanager.NewServiceManager(cfg, engineShutdown) db := NewDataDBService(cfg) cfg.StorDbCfg().Type = utils.INTERNAL stordb := NewStorDBService(cfg) - schS := NewSchedulerService(cfg, db, chS, filterSChan, server, make(chan rpcclient.RpcClientConnection, 1), nil) + schS := NewSchedulerService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1), nil) tS := NewThresholdService(cfg, db, chS, filterSChan, server) ralS := NewRalService(cfg, db, stordb, chS, filterSChan, server, tS.GetIntenternalChan(), internalChan, cacheSChan, internalChan, internalChan, diff --git a/services/resources.go b/services/resources.go index d6b00fbea..e8fc19f91 100644 --- a/services/resources.go +++ b/services/resources.go @@ -34,9 +34,9 @@ import ( func NewResourceService(cfg *config.CGRConfig, dm *DataDBService, cacheS *engine.CacheS, filterSChan chan *engine.FilterS, server *utils.Server, thrsChan, - dispatcherChan chan rpcclient.RpcClientConnection) servmanager.Service { + dispatcherChan chan rpcclient.ClientConnector) servmanager.Service { return &ResourceService{ - connChan: make(chan rpcclient.RpcClientConnection, 1), + connChan: make(chan rpcclient.ClientConnector, 1), cfg: cfg, dm: dm, cacheS: cacheS, @@ -55,12 +55,12 @@ type ResourceService struct { cacheS *engine.CacheS filterSChan chan *engine.FilterS server *utils.Server - thrsChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + thrsChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector reS *engine.ResourceService rpc *v1.ResourceSv1 - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector } // Start should handle the sercive start @@ -76,7 +76,7 @@ func (reS *ResourceService) Start() (err error) { filterS := <-reS.filterSChan reS.filterSChan <- filterS - var thdSConn rpcclient.RpcClientConnection + var thdSConn rpcclient.ClientConnector if thdSConn, err = NewConnection(reS.cfg, reS.thrsChan, reS.dispatcherChan, reS.cfg.ResourceSCfg().ThresholdSConns); err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to ThresholdS: %s", utils.ResourceS, err.Error())) return @@ -100,13 +100,13 @@ func (reS *ResourceService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (reS *ResourceService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (reS *ResourceService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return reS.connChan } // Reload handles the change of config func (reS *ResourceService) Reload() (err error) { - var thdSConn rpcclient.RpcClientConnection + var thdSConn rpcclient.ClientConnector if thdSConn, err = NewConnection(reS.cfg, reS.thrsChan, reS.dispatcherChan, reS.cfg.ResourceSCfg().ThresholdSConns); err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to ThresholdS: %s", utils.ResourceS, err.Error())) return diff --git a/services/responders.go b/services/responders.go index 06bfb79d3..841832065 100644 --- a/services/responders.go +++ b/services/responders.go @@ -30,10 +30,10 @@ import ( // NewResponderService returns the Resonder Service func NewResponderService(cfg *config.CGRConfig, server *utils.Server, - thsChan, stsChan, dispatcherChan chan rpcclient.RpcClientConnection, + thsChan, stsChan, dispatcherChan chan rpcclient.ClientConnector, exitChan chan bool) *ResponderService { return &ResponderService{ - connChan: make(chan rpcclient.RpcClientConnection, 1), + connChan: make(chan rpcclient.ClientConnector, 1), cfg: cfg, server: server, thsChan: thsChan, @@ -48,13 +48,13 @@ type ResponderService struct { sync.RWMutex cfg *config.CGRConfig server *utils.Server - thsChan chan rpcclient.RpcClientConnection - stsChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + thsChan chan rpcclient.ClientConnector + stsChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector exitChan chan bool resp *engine.Responder - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector } // Start should handle the sercive start @@ -64,7 +64,7 @@ func (resp *ResponderService) Start() (err error) { return fmt.Errorf("service aleady running") } - var thdS, stats rpcclient.RpcClientConnection + var thdS, stats rpcclient.ClientConnector if thdS, err = NewConnection(resp.cfg, resp.thsChan, resp.dispatcherChan, resp.cfg.RalsCfg().ThresholdSConns); err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to %s, error: %s", utils.RALService, utils.ThresholdS, err.Error())) @@ -99,13 +99,13 @@ func (resp *ResponderService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (resp *ResponderService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (resp *ResponderService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return resp.connChan } // Reload handles the change of config func (resp *ResponderService) Reload() (err error) { - var thdS, stats rpcclient.RpcClientConnection + var thdS, stats rpcclient.ClientConnector if thdS, err = NewConnection(resp.cfg, resp.thsChan, resp.dispatcherChan, resp.cfg.RalsCfg().ThresholdSConns); err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to %s, error: %s", utils.RALService, utils.ThresholdS, err.Error())) diff --git a/services/schedulers.go b/services/schedulers.go index 923ea5ee0..f42a2216d 100644 --- a/services/schedulers.go +++ b/services/schedulers.go @@ -34,9 +34,9 @@ import ( func NewSchedulerService(cfg *config.CGRConfig, dm *DataDBService, cacheS *engine.CacheS, fltrSChan chan *engine.FilterS, server *utils.Server, internalCDRServerChan, - dispatcherChan chan rpcclient.RpcClientConnection) *SchedulerService { + dispatcherChan chan rpcclient.ClientConnector) *SchedulerService { return &SchedulerService{ - connChan: make(chan rpcclient.RpcClientConnection, 1), + connChan: make(chan rpcclient.ClientConnector, 1), cfg: cfg, dm: dm, cacheS: cacheS, @@ -55,12 +55,12 @@ type SchedulerService struct { cacheS *engine.CacheS fltrSChan chan *engine.FilterS server *utils.Server - cdrSChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + cdrSChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector schS *scheduler.Scheduler rpc *v1.SchedulerSv1 - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector } // Start should handle the sercive start @@ -100,7 +100,7 @@ func (schS *SchedulerService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (schS *SchedulerService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (schS *SchedulerService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return schS.connChan } diff --git a/services/schedulers_it_test.go b/services/schedulers_it_test.go index ef101bb17..501d07ed5 100644 --- a/services/schedulers_it_test.go +++ b/services/schedulers_it_test.go @@ -45,7 +45,7 @@ func TestSchedulerSReload(t *testing.T) { close(chS.GetPrecacheChannel(utils.CacheActionPlans)) server := utils.NewServer() srvMngr := servmanager.NewServiceManager(cfg, engineShutdown) - internalCdrSChan := make(chan rpcclient.RpcClientConnection, 1) + internalCdrSChan := make(chan rpcclient.ClientConnector, 1) internalCdrSChan <- nil db := NewDataDBService(cfg) schS := NewSchedulerService(cfg, db, chS, filterSChan, server, internalCdrSChan, nil) diff --git a/services/sessions.go b/services/sessions.go index a69f2336c..5a788b774 100644 --- a/services/sessions.go +++ b/services/sessions.go @@ -33,7 +33,7 @@ import ( // NewSessionService returns the Session Service func NewSessionService(cfg *config.CGRConfig, dm *DataDBService, server *utils.Server, chrsChan, respChan, resChan, thsChan, stsChan, - supChan, attrsChan, cdrsChan, dispatcherChan, internalChan chan rpcclient.RpcClientConnection, + supChan, attrsChan, cdrsChan, dispatcherChan, internalChan chan rpcclient.ClientConnector, exitChan chan bool) servmanager.Service { return &SessionService{ connChan: internalChan, @@ -59,21 +59,21 @@ type SessionService struct { cfg *config.CGRConfig dm *DataDBService server *utils.Server - chrsChan chan rpcclient.RpcClientConnection - respChan chan rpcclient.RpcClientConnection - resChan chan rpcclient.RpcClientConnection - thsChan chan rpcclient.RpcClientConnection - stsChan chan rpcclient.RpcClientConnection - supChan chan rpcclient.RpcClientConnection - attrsChan chan rpcclient.RpcClientConnection - cdrsChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + chrsChan chan rpcclient.ClientConnector + respChan chan rpcclient.ClientConnector + resChan chan rpcclient.ClientConnector + thsChan chan rpcclient.ClientConnector + stsChan chan rpcclient.ClientConnector + supChan chan rpcclient.ClientConnector + attrsChan chan rpcclient.ClientConnector + cdrsChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector exitChan chan bool sm *sessions.SessionS rpc *v1.SMGenericV1 rpcv1 *v1.SessionSv1 - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector // in order to stop the bircp server if necesary bircpEnabled bool @@ -87,7 +87,7 @@ func (smg *SessionService) Start() (err error) { smg.Lock() defer smg.Unlock() - var ralsConns, resSConns, threshSConns, statSConns, suplSConns, attrConns, cdrsConn, chargerSConn rpcclient.RpcClientConnection + var ralsConns, resSConns, threshSConns, statSConns, suplSConns, attrConns, cdrsConn, chargerSConn rpcclient.ClientConnector if chargerSConn, err = NewConnection(smg.cfg, smg.chrsChan, smg.dispatcherChan, smg.cfg.SessionSCfg().ChargerSConns); err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to %s: %s", @@ -188,13 +188,13 @@ func (smg *SessionService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (smg *SessionService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (smg *SessionService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return smg.connChan } // Reload handles the change of config func (smg *SessionService) Reload() (err error) { - var ralsConns, resSConns, threshSConns, statSConns, suplSConns, attrConns, cdrsConn, chargerSConn rpcclient.RpcClientConnection + var ralsConns, resSConns, threshSConns, statSConns, suplSConns, attrConns, cdrsConn, chargerSConn rpcclient.ClientConnector if chargerSConn, err = NewConnection(smg.cfg, smg.chrsChan, smg.dispatcherChan, smg.cfg.SessionSCfg().ChargerSConns); err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to %s: %s", diff --git a/services/sessions_it_test.go b/services/sessions_it_test.go index 0b91020dc..92c6e175b 100644 --- a/services/sessions_it_test.go +++ b/services/sessions_it_test.go @@ -60,9 +60,9 @@ func TestSessionSReload(t *testing.T) { close(chS.GetPrecacheChannel(utils.CacheSharedGroups)) close(chS.GetPrecacheChannel(utils.CacheTimings)) - internalChan := make(chan rpcclient.RpcClientConnection, 1) + internalChan := make(chan rpcclient.ClientConnector, 1) internalChan <- nil - cacheSChan := make(chan rpcclient.RpcClientConnection, 1) + cacheSChan := make(chan rpcclient.ClientConnector, 1) cacheSChan <- chS server := utils.NewServer() @@ -71,17 +71,17 @@ func TestSessionSReload(t *testing.T) { cfg.StorDbCfg().Type = utils.INTERNAL stordb := NewStorDBService(cfg) chrS := NewChargerService(cfg, db, chS, filterSChan, server, nil, nil) - schS := NewSchedulerService(cfg, db, chS, filterSChan, server, make(chan rpcclient.RpcClientConnection, 1), nil) + schS := NewSchedulerService(cfg, db, chS, filterSChan, server, make(chan rpcclient.ClientConnector, 1), nil) ralS := NewRalService(cfg, db, stordb, chS, filterSChan, server, /*tS*/ internalChan, internalChan, cacheSChan, internalChan, internalChan, internalChan, schS, engineShutdown) cdrS := NewCDRServer(cfg, db, stordb, filterSChan, server, - make(chan rpcclient.RpcClientConnection, 1), + make(chan rpcclient.ClientConnector, 1), chrS.GetIntenternalChan(), ralS.GetResponder().GetIntenternalChan(), nil, nil, nil, nil) srv := NewSessionService(cfg, db, server, chrS.GetIntenternalChan(), ralS.GetResponder().GetIntenternalChan(), nil, nil, nil, - nil, nil, cdrS.GetIntenternalChan(), nil, make(chan rpcclient.RpcClientConnection, 1), engineShutdown) + nil, nil, cdrS.GetIntenternalChan(), nil, make(chan rpcclient.ClientConnector, 1), engineShutdown) srvMngr.AddServices(NewConnManagerService(cfg, nil), srv, chrS, schS, ralS, cdrS, NewLoaderService(cfg, db, filterSChan, server, cacheSChan, nil, engineShutdown), db, stordb) if err = srvMngr.StartServices(); err != nil { t.Error(err) diff --git a/services/stats.go b/services/stats.go index 661e75a5e..8e3eb39ed 100644 --- a/services/stats.go +++ b/services/stats.go @@ -34,9 +34,9 @@ import ( func NewStatService(cfg *config.CGRConfig, dm *DataDBService, cacheS *engine.CacheS, filterSChan chan *engine.FilterS, server *utils.Server, thrsChan, - dispatcherChan chan rpcclient.RpcClientConnection) servmanager.Service { + dispatcherChan chan rpcclient.ClientConnector) servmanager.Service { return &StatService{ - connChan: make(chan rpcclient.RpcClientConnection, 1), + connChan: make(chan rpcclient.ClientConnector, 1), cfg: cfg, dm: dm, cacheS: cacheS, @@ -55,12 +55,12 @@ type StatService struct { cacheS *engine.CacheS filterSChan chan *engine.FilterS server *utils.Server - thrsChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + thrsChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector sts *engine.StatService rpc *v1.StatSv1 - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector } // Start should handle the sercive start @@ -76,7 +76,7 @@ func (sts *StatService) Start() (err error) { filterS := <-sts.filterSChan sts.filterSChan <- filterS - var thdSConn rpcclient.RpcClientConnection + var thdSConn rpcclient.ClientConnector if thdSConn, err = NewConnection(sts.cfg, sts.thrsChan, sts.dispatcherChan, sts.cfg.StatSCfg().ThresholdSConns); err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to ThresholdS: %s", utils.StatS, err.Error())) return @@ -99,13 +99,13 @@ func (sts *StatService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (sts *StatService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (sts *StatService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return sts.connChan } // Reload handles the change of config func (sts *StatService) Reload() (err error) { - var thdSConn rpcclient.RpcClientConnection + var thdSConn rpcclient.ClientConnector if thdSConn, err = NewConnection(sts.cfg, sts.thrsChan, sts.dispatcherChan, sts.cfg.StatSCfg().ThresholdSConns); err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to ThresholdS: %s", utils.StatS, err.Error())) return diff --git a/services/stordb.go b/services/stordb.go index 43640917b..044c2f589 100644 --- a/services/stordb.go +++ b/services/stordb.go @@ -78,7 +78,7 @@ func (db *StorDBService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (db *StorDBService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (db *StorDBService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return nil } diff --git a/services/suppliers.go b/services/suppliers.go index e91edd58b..9e2a42e47 100644 --- a/services/suppliers.go +++ b/services/suppliers.go @@ -34,9 +34,9 @@ import ( func NewSupplierService(cfg *config.CGRConfig, dm *DataDBService, cacheS *engine.CacheS, filterSChan chan *engine.FilterS, server *utils.Server, attrsChan, stsChan, resChan, - dispatcherChan chan rpcclient.RpcClientConnection) servmanager.Service { + dispatcherChan chan rpcclient.ClientConnector) servmanager.Service { return &SupplierService{ - connChan: make(chan rpcclient.RpcClientConnection, 1), + connChan: make(chan rpcclient.ClientConnector, 1), cfg: cfg, dm: dm, cacheS: cacheS, @@ -57,14 +57,14 @@ type SupplierService struct { cacheS *engine.CacheS filterSChan chan *engine.FilterS server *utils.Server - attrsChan chan rpcclient.RpcClientConnection - stsChan chan rpcclient.RpcClientConnection - resChan chan rpcclient.RpcClientConnection - dispatcherChan chan rpcclient.RpcClientConnection + attrsChan chan rpcclient.ClientConnector + stsChan chan rpcclient.ClientConnector + resChan chan rpcclient.ClientConnector + dispatcherChan chan rpcclient.ClientConnector splS *engine.SupplierService rpc *v1.SupplierSv1 - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector } // Start should handle the sercive start @@ -79,7 +79,7 @@ func (splS *SupplierService) Start() (err error) { filterS := <-splS.filterSChan splS.filterSChan <- filterS - var attrSConn, resourceSConn, statSConn rpcclient.RpcClientConnection + var attrSConn, resourceSConn, statSConn rpcclient.ClientConnector attrSConn, err = NewConnection(splS.cfg, splS.attrsChan, splS.dispatcherChan, splS.cfg.SupplierSCfg().AttributeSConns) if err != nil { @@ -119,13 +119,13 @@ func (splS *SupplierService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (splS *SupplierService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (splS *SupplierService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return splS.connChan } // Reload handles the change of config func (splS *SupplierService) Reload() (err error) { - var attrSConn, resourceSConn, statSConn rpcclient.RpcClientConnection + var attrSConn, resourceSConn, statSConn rpcclient.ClientConnector attrSConn, err = NewConnection(splS.cfg, splS.attrsChan, splS.dispatcherChan, splS.cfg.SupplierSCfg().AttributeSConns) if err != nil { utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to %s: %s", diff --git a/services/thresholds.go b/services/thresholds.go index a483404a1..532da3854 100644 --- a/services/thresholds.go +++ b/services/thresholds.go @@ -35,7 +35,7 @@ func NewThresholdService(cfg *config.CGRConfig, dm *DataDBService, cacheS *engine.CacheS, filterSChan chan *engine.FilterS, server *utils.Server) servmanager.Service { return &ThresholdService{ - connChan: make(chan rpcclient.RpcClientConnection, 1), + connChan: make(chan rpcclient.ClientConnector, 1), cfg: cfg, dm: dm, cacheS: cacheS, @@ -55,7 +55,7 @@ type ThresholdService struct { thrs *engine.ThresholdService rpc *v1.ThresholdSv1 - connChan chan rpcclient.RpcClientConnection + connChan chan rpcclient.ClientConnector } // Start should handle the sercive start @@ -89,7 +89,7 @@ func (thrs *ThresholdService) Start() (err error) { } // GetIntenternalChan returns the internal connection chanel -func (thrs *ThresholdService) GetIntenternalChan() (conn chan rpcclient.RpcClientConnection) { +func (thrs *ThresholdService) GetIntenternalChan() (conn chan rpcclient.ClientConnector) { return thrs.connChan } diff --git a/services/utils.go b/services/utils.go index 0bbf4cb93..5deaacb12 100644 --- a/services/utils.go +++ b/services/utils.go @@ -25,8 +25,8 @@ import ( ) // NewConnection returns a new connection -func NewConnection(cfg *config.CGRConfig, serviceConnChan, dispatcherSChan chan rpcclient.RpcClientConnection, - conns []*config.RemoteHost) (rpcclient.RpcClientConnection, error) { +func NewConnection(cfg *config.CGRConfig, serviceConnChan, dispatcherSChan chan rpcclient.ClientConnector, + conns []*config.RemoteHost) (rpcclient.ClientConnector, error) { if len(conns) == 0 { return nil, nil } @@ -34,7 +34,7 @@ func NewConnection(cfg *config.CGRConfig, serviceConnChan, dispatcherSChan chan if cfg.DispatcherSCfg().Enabled { internalChan = dispatcherSChan } - return engine.NewRPCPool(rpcclient.POOL_FIRST, + return engine.NewRPCPool(rpcclient.PoolFirst, cfg.TlsCfg().ClientKey, cfg.TlsCfg().ClientCerificate, cfg.TlsCfg().CaCertificate, cfg.GeneralCfg().ConnectAttempts, cfg.GeneralCfg().Reconnects, diff --git a/servmanager/servmanager.go b/servmanager/servmanager.go index 803d50fa8..08ea81577 100644 --- a/servmanager/servmanager.go +++ b/servmanager/servmanager.go @@ -370,7 +370,7 @@ type Service interface { // Shutdown stops the service Shutdown() error // GetIntenternalChan returns the internal connection chanel - GetIntenternalChan() chan rpcclient.RpcClientConnection + GetIntenternalChan() chan rpcclient.ClientConnector // IsRunning returns if the service is running IsRunning() bool // ShouldRun returns if the service should be running diff --git a/sessions/sessions.go b/sessions/sessions.go index 0183473e8..094d6a9b6 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -46,10 +46,10 @@ func NewSReplConns(conns []*config.RemoteHost, reconnects int, connTimeout, replyTimeout time.Duration) (sReplConns []*SReplConn, err error) { sReplConns = make([]*SReplConn, len(conns)) for i, replConnCfg := range conns { - var replCon *rpcclient.RpcClient - if replCon, err = rpcclient.NewRpcClient(utils.TCP, replConnCfg.Address, + var replCon *rpcclient.RPCClient + if replCon, err = rpcclient.NewRPCClient(utils.TCP, replConnCfg.Address, replConnCfg.TLS, "", "", "", 0, reconnects, connTimeout, - replyTimeout, replConnCfg.Transport[1:], nil, true); err != nil { + replyTimeout, replConnCfg.Transport, nil, true); err != nil { return nil, err } sReplConns[i] = &SReplConn{Connection: replCon, Synchronous: replConnCfg.Synchronous} @@ -59,13 +59,13 @@ func NewSReplConns(conns []*config.RemoteHost, reconnects int, // SReplConn represents one connection to a passive node where we will replicate session data type SReplConn struct { - Connection rpcclient.RpcClientConnection + Connection rpcclient.ClientConnector Synchronous bool } // NewSessionS constructs a new SessionS instance func NewSessionS(cgrCfg *config.CGRConfig, ralS, resS, thdS, - statS, splS, attrS, cdrS, chargerS rpcclient.RpcClientConnection, + statS, splS, attrS, cdrS, chargerS rpcclient.ClientConnector, sReplConns []*SReplConn, dm *engine.DataManager) *SessionS { cgrCfg.SessionSCfg().SessionIndexes[utils.OriginID] = true // Make sure we have indexing for OriginID since it is a requirement on prefix searching if chargerS != nil && reflect.ValueOf(chargerS).IsNil() { @@ -104,7 +104,7 @@ func NewSessionS(cgrCfg *config.CGRConfig, ralS, resS, thdS, attrS: attrS, cdrS: cdrS, sReplConns: sReplConns, - biJClnts: make(map[rpcclient.RpcClientConnection]string), + biJClnts: make(map[rpcclient.ClientConnector]string), biJIDs: make(map[string]*biJClient), aSessions: make(map[string]*Session), aSessionsIdx: make(map[string]map[string]map[string]utils.StringMap), @@ -117,8 +117,8 @@ func NewSessionS(cgrCfg *config.CGRConfig, ralS, resS, thdS, // biJClient contains info we need to reach back a bidirectional json client type biJClient struct { - conn rpcclient.RpcClientConnection // connection towards BiJ client - proto float64 // client protocol version + conn rpcclient.ClientConnector // connection towards BiJ client + proto float64 // client protocol version } // SessionS represents the session service @@ -126,18 +126,18 @@ type SessionS struct { cgrCfg *config.CGRConfig // Separate from smCfg since there can be multiple dm *engine.DataManager - chargerS rpcclient.RpcClientConnection - ralS rpcclient.RpcClientConnection // RALs connections - resS rpcclient.RpcClientConnection // ResourceS connections - thdS rpcclient.RpcClientConnection // ThresholdS connections - statS rpcclient.RpcClientConnection // StatS connections - splS rpcclient.RpcClientConnection // SupplierS connections - attrS rpcclient.RpcClientConnection // AttributeS connections - cdrS rpcclient.RpcClientConnection // CDR server connections + chargerS rpcclient.ClientConnector + ralS rpcclient.ClientConnector // RALs connections + resS rpcclient.ClientConnector // ResourceS connections + thdS rpcclient.ClientConnector // ThresholdS connections + statS rpcclient.ClientConnector // StatS connections + splS rpcclient.ClientConnector // SupplierS connections + attrS rpcclient.ClientConnector // AttributeS connections + cdrS rpcclient.ClientConnector // CDR server connections - biJMux sync.RWMutex // mux protecting BI-JSON connections - biJClnts map[rpcclient.RpcClientConnection]string // index BiJSONConnection so we can sync them later - biJIDs map[string]*biJClient // identifiers of bidirectional JSON conns, used to call RPC based on connIDs + biJMux sync.RWMutex // mux protecting BI-JSON connections + biJClnts map[rpcclient.ClientConnector]string // index BiJSONConnection so we can sync them later + biJIDs map[string]*biJClient // identifiers of bidirectional JSON conns, used to call RPC based on connIDs aSsMux sync.RWMutex // protects aSessions aSessions map[string]*Session // group sessions per sessionId @@ -209,7 +209,7 @@ func (sS *SessionS) OnBiJSONDisconnect(c *rpc2.Client) { } // RegisterIntBiJConn is called on internal BiJ connection towards SessionS -func (sS *SessionS) RegisterIntBiJConn(c rpcclient.RpcClientConnection) { +func (sS *SessionS) RegisterIntBiJConn(c rpcclient.ClientConnector) { sS.biJMux.Lock() nodeID := sS.cgrCfg.GeneralCfg().NodeID sS.biJClnts[c] = nodeID @@ -231,7 +231,7 @@ func (sS *SessionS) biJClnt(connID string) (clnt *biJClient) { } // biJClnt returns connection ID based on bidirectional connection received -func (sS *SessionS) biJClntID(c rpcclient.RpcClientConnection) (clntConnID string) { +func (sS *SessionS) biJClntID(c rpcclient.ClientConnector) (clntConnID string) { if c == nil { return } @@ -727,7 +727,7 @@ func (sS *SessionS) replicateSessions(cgrID string, psv bool, rplConns []*SReplC if rplConn.Synchronous { wg.Add(1) } - go func(conn rpcclient.RpcClientConnection, sync bool, ss []*Session) { + go func(conn rpcclient.ClientConnector, sync bool, ss []*Session) { for _, s := range ss { sCln := s.Clone() var rply string @@ -1554,8 +1554,8 @@ func (sS *SessionS) Call(serviceMethod string, args interface{}, reply interface return sS.CallBiRPC(nil, serviceMethod, args, reply) } -// CallBiRPC is part of utils.BiRPCServer interface to help internal connections do calls over rpcclient.RpcClientConnection interface -func (sS *SessionS) CallBiRPC(clnt rpcclient.RpcClientConnection, +// CallBiRPC is part of utils.BiRPCServer interface to help internal connections do calls over rpcclient.ClientConnector interface +func (sS *SessionS) CallBiRPC(clnt rpcclient.ClientConnector, serviceMethod string, args interface{}, reply interface{}) error { parts := strings.Split(serviceMethod, ".") if len(parts) != 2 { @@ -1592,7 +1592,7 @@ func (sS *SessionS) CallBiRPC(clnt rpcclient.RpcClientConnection, } // BiRPCv1GetActiveSessions returns the list of active sessions based on filter -func (sS *SessionS) BiRPCv1GetActiveSessions(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1GetActiveSessions(clnt rpcclient.ClientConnector, args *utils.SessionFilter, reply *[]*ExternalSession) (err error) { if args == nil { //protection in case on nil args = &utils.SessionFilter{} @@ -1606,7 +1606,7 @@ func (sS *SessionS) BiRPCv1GetActiveSessions(clnt rpcclient.RpcClientConnection, } // BiRPCv1GetActiveSessionsCount counts the active sessions -func (sS *SessionS) BiRPCv1GetActiveSessionsCount(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1GetActiveSessionsCount(clnt rpcclient.ClientConnector, args *utils.SessionFilter, reply *int) error { if args == nil { //protection in case on nil args = &utils.SessionFilter{} @@ -1616,7 +1616,7 @@ func (sS *SessionS) BiRPCv1GetActiveSessionsCount(clnt rpcclient.RpcClientConnec } // BiRPCv1GetPassiveSessions returns the passive sessions handled by SessionS -func (sS *SessionS) BiRPCv1GetPassiveSessions(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1GetPassiveSessions(clnt rpcclient.ClientConnector, args *utils.SessionFilter, reply *[]*ExternalSession) error { if args == nil { //protection in case on nil args = &utils.SessionFilter{} @@ -1630,7 +1630,7 @@ func (sS *SessionS) BiRPCv1GetPassiveSessions(clnt rpcclient.RpcClientConnection } // BiRPCv1GetPassiveSessionsCount counts the passive sessions handled by the system -func (sS *SessionS) BiRPCv1GetPassiveSessionsCount(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1GetPassiveSessionsCount(clnt rpcclient.ClientConnector, args *utils.SessionFilter, reply *int) error { if args == nil { //protection in case on nil args = &utils.SessionFilter{} @@ -1640,7 +1640,7 @@ func (sS *SessionS) BiRPCv1GetPassiveSessionsCount(clnt rpcclient.RpcClientConne } // BiRPCv1SetPassiveSession used for replicating Sessions -func (sS *SessionS) BiRPCv1SetPassiveSession(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1SetPassiveSession(clnt rpcclient.ClientConnector, s *Session, reply *string) (err error) { if s.CGRID == "" { return utils.NewErrMandatoryIeMissing(utils.CGRID) @@ -1674,7 +1674,7 @@ type ArgsReplicateSessions struct { // BiRPCv1ReplicateSessions will replicate active sessions to either args.Connections or the internal configured ones // args.Filter is used to filter the sessions which are replicated, CGRID is the only one possible for now -func (sS *SessionS) BiRPCv1ReplicateSessions(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1ReplicateSessions(clnt rpcclient.ClientConnector, args ArgsReplicateSessions, reply *string) (err error) { sSConns := sS.sReplConns if len(args.Connections) != 0 { @@ -1830,7 +1830,7 @@ func (v1AuthReply *V1AuthorizeReply) AsNavigableMap( } // BiRPCv1AuthorizeEvent performs authorization for CGREvent based on specific components -func (sS *SessionS) BiRPCv1AuthorizeEvent(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1AuthorizeEvent(clnt rpcclient.ClientConnector, args *V1AuthorizeArgs, authReply *V1AuthorizeReply) (err error) { var withErrors bool if args.CGREvent.ID == "" { @@ -1956,7 +1956,7 @@ type V1AuthorizeReplyWithDigest struct { // BiRPCv1AuthorizeEventWithDigest performs authorization for CGREvent based on specific components // returning one level fields instead of multiple ones returned by BiRPCv1AuthorizeEvent -func (sS *SessionS) BiRPCv1AuthorizeEventWithDigest(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1AuthorizeEventWithDigest(clnt rpcclient.ClientConnector, args *V1AuthorizeArgs, authReply *V1AuthorizeReplyWithDigest) (err error) { var initAuthRply V1AuthorizeReply if err = sS.BiRPCv1AuthorizeEvent(clnt, args, &initAuthRply); err != nil { @@ -2100,7 +2100,7 @@ func (v1Rply *V1InitSessionReply) AsNavigableMap( } // BiRPCv1InitiateSession initiates a new session -func (sS *SessionS) BiRPCv1InitiateSession(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1InitiateSession(clnt rpcclient.ClientConnector, args *V1InitSessionArgs, rply *V1InitSessionReply) (err error) { var withErrors bool if args.CGREvent.ID == "" { @@ -2232,7 +2232,7 @@ type V1InitReplyWithDigest struct { } // BiRPCv1InitiateSessionWithDigest returns the formated result of InitiateSession -func (sS *SessionS) BiRPCv1InitiateSessionWithDigest(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1InitiateSessionWithDigest(clnt rpcclient.ClientConnector, args *V1InitSessionArgs, initReply *V1InitReplyWithDigest) (err error) { var initSessionRply V1InitSessionReply if err = sS.BiRPCv1InitiateSession(clnt, args, &initSessionRply); err != nil { @@ -2325,7 +2325,7 @@ func (v1Rply *V1UpdateSessionReply) AsNavigableMap( } // BiRPCv1UpdateSession updates an existing session, returning the duration which the session can still last -func (sS *SessionS) BiRPCv1UpdateSession(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1UpdateSession(clnt rpcclient.ClientConnector, args *V1UpdateSessionArgs, rply *V1UpdateSessionReply) (err error) { if args.CGREvent.ID == "" { args.CGREvent.ID = utils.GenUUID() @@ -2458,7 +2458,7 @@ func (args *V1TerminateSessionArgs) ParseFlags(flags string) { } // BiRPCv1TerminateSession will stop debit loops as well as release any used resources -func (sS *SessionS) BiRPCv1TerminateSession(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1TerminateSession(clnt rpcclient.ClientConnector, args *V1TerminateSessionArgs, rply *string) (err error) { var withErrors bool if args.CGREvent.ID == "" { @@ -2581,7 +2581,7 @@ func (sS *SessionS) BiRPCv1TerminateSession(clnt rpcclient.RpcClientConnection, } // BiRPCv1ProcessCDR sends the CDR to CDRs -func (sS *SessionS) BiRPCv1ProcessCDR(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1ProcessCDR(clnt rpcclient.ClientConnector, cgrEvWithArgDisp *utils.CGREventWithArgDispatcher, rply *string) (err error) { if cgrEvWithArgDisp.ID == "" { cgrEvWithArgDisp.ID = utils.GenUUID() @@ -2808,7 +2808,7 @@ func (v1Rply *V1ProcessMessageReply) AsNavigableMap( } // BiRPCv1ProcessMessage processes one event with the right subsystems based on arguments received -func (sS *SessionS) BiRPCv1ProcessMessage(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1ProcessMessage(clnt rpcclient.ClientConnector, args *V1ProcessMessageArgs, rply *V1ProcessMessageReply) (err error) { var withErrors bool if args.CGREvent.ID == "" { @@ -2985,7 +2985,7 @@ func (v1Rply *V1ProcessEventReply) AsNavigableMap( } // BiRPCv1ProcessEvent processes one event with the right subsystems based on arguments received -func (sS *SessionS) BiRPCv1ProcessEvent(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1ProcessEvent(clnt rpcclient.ClientConnector, args *V1ProcessEventArgs, rply *V1ProcessEventReply) (err error) { var withErrors bool if args.CGREvent.ID == "" { @@ -3235,7 +3235,7 @@ func (sS *SessionS) BiRPCv1ProcessEvent(clnt rpcclient.RpcClientConnection, } // BiRPCv1SyncSessions will sync sessions on demand -func (sS *SessionS) BiRPCv1SyncSessions(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1SyncSessions(clnt rpcclient.ClientConnector, ignParam string, reply *string) error { sS.syncSessions() *reply = utils.OK @@ -3243,7 +3243,7 @@ func (sS *SessionS) BiRPCv1SyncSessions(clnt rpcclient.RpcClientConnection, } // BiRPCv1ForceDisconnect will force disconnecting sessions matching sessions -func (sS *SessionS) BiRPCv1ForceDisconnect(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1ForceDisconnect(clnt rpcclient.ClientConnector, args *utils.SessionFilter, reply *string) (err error) { if args == nil { //protection in case on nil args = &utils.SessionFilter{} @@ -3277,7 +3277,7 @@ func (sS *SessionS) BiRPCv1ForceDisconnect(clnt rpcclient.RpcClientConnection, } // BiRPCv1RegisterInternalBiJSONConn will register the client for a bidirectional comunication -func (sS *SessionS) BiRPCv1RegisterInternalBiJSONConn(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1RegisterInternalBiJSONConn(clnt rpcclient.ClientConnector, ign string, reply *string) error { sS.RegisterIntBiJConn(clnt) *reply = utils.OK @@ -3286,7 +3286,7 @@ func (sS *SessionS) BiRPCv1RegisterInternalBiJSONConn(clnt rpcclient.RpcClientCo // BiRPCv1ActivateSessions is called to activate a list/all sessions // returns utils.ErrPartiallyExecuted in case of errors -func (sS *SessionS) BiRPCv1ActivateSessions(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1ActivateSessions(clnt rpcclient.ClientConnector, sIDs []string, reply *string) (err error) { if len(sIDs) == 0 { sS.pSsMux.RLock() @@ -3312,7 +3312,7 @@ func (sS *SessionS) BiRPCv1ActivateSessions(clnt rpcclient.RpcClientConnection, // BiRPCv1DeactivateSessions is called to deactivate a list/all active sessios // returns utils.ErrPartiallyExecuted in case of errors -func (sS *SessionS) BiRPCv1DeactivateSessions(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCv1DeactivateSessions(clnt rpcclient.ClientConnector, sIDs []string, reply *string) (err error) { if len(sIDs) == 0 { sS.aSsMux.RLock() @@ -3421,7 +3421,7 @@ func (sS *SessionS) processAttributes(cgrEv *utils.CGREvent, argDisp *utils.ArgD // BiRPCV1GetMaxUsage returns the maximum usage as seconds, compatible with OpenSIPS 2.3 // DEPRECATED, it will be removed in future versions -func (sS *SessionS) BiRPCV1GetMaxUsage(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCV1GetMaxUsage(clnt rpcclient.ClientConnector, ev engine.MapEvent, maxUsage *float64) (err error) { var rply *V1AuthorizeReply if err = sS.BiRPCv1AuthorizeEvent( @@ -3444,7 +3444,7 @@ func (sS *SessionS) BiRPCV1GetMaxUsage(clnt rpcclient.RpcClientConnection, // BiRPCV1InitiateSession is called on session start, returns the maximum number of seconds the session can last // DEPRECATED, it will be removed in future versions // Kept for compatibility with OpenSIPS 2.3 -func (sS *SessionS) BiRPCV1InitiateSession(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCV1InitiateSession(clnt rpcclient.ClientConnector, ev engine.MapEvent, maxUsage *float64) (err error) { var rply *V1InitSessionReply if err = sS.BiRPCv1InitiateSession( @@ -3467,7 +3467,7 @@ func (sS *SessionS) BiRPCV1InitiateSession(clnt rpcclient.RpcClientConnection, // BiRPCV1UpdateSession processes interim updates, returns remaining duration from the RALs // DEPRECATED, it will be removed in future versions // Kept for compatibility with OpenSIPS 2.3 -func (sS *SessionS) BiRPCV1UpdateSession(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCV1UpdateSession(clnt rpcclient.ClientConnector, ev engine.MapEvent, maxUsage *float64) (err error) { var rply *V1UpdateSessionReply if err = sS.BiRPCv1UpdateSession( @@ -3490,7 +3490,7 @@ func (sS *SessionS) BiRPCV1UpdateSession(clnt rpcclient.RpcClientConnection, // BiRPCV1TerminateSession is called on session end, should stop debit loop // DEPRECATED, it will be removed in future versions // Kept for compatibility with OpenSIPS 2.3 -func (sS *SessionS) BiRPCV1TerminateSession(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCV1TerminateSession(clnt rpcclient.ClientConnector, ev engine.MapEvent, rply *string) (err error) { return sS.BiRPCv1TerminateSession( clnt, @@ -3508,7 +3508,7 @@ func (sS *SessionS) BiRPCV1TerminateSession(clnt rpcclient.RpcClientConnection, // BiRPCV1ProcessCDR should send the CDR to CDRS // DEPRECATED, it will be removed in future versions // Kept for compatibility with OpenSIPS 2.3 -func (sS *SessionS) BiRPCV1ProcessCDR(clnt rpcclient.RpcClientConnection, +func (sS *SessionS) BiRPCV1ProcessCDR(clnt rpcclient.ClientConnector, ev engine.MapEvent, rply *string) (err error) { return sS.BiRPCv1ProcessCDR( clnt, @@ -3524,7 +3524,7 @@ func (sS *SessionS) BiRPCV1ProcessCDR(clnt rpcclient.RpcClientConnection, // SetAttributeSConnection sets the new connection to the attribute service // only used on reload -func (sS *SessionS) SetAttributeSConnection(attrS rpcclient.RpcClientConnection) { +func (sS *SessionS) SetAttributeSConnection(attrS rpcclient.ClientConnector) { if attrS != nil && reflect.ValueOf(attrS).IsNil() { attrS = nil } @@ -3533,7 +3533,7 @@ func (sS *SessionS) SetAttributeSConnection(attrS rpcclient.RpcClientConnection) // SetThresholSConnection sets the new connection to the threshold service // only used on reload -func (sS *SessionS) SetThresholSConnection(thdS rpcclient.RpcClientConnection) { +func (sS *SessionS) SetThresholSConnection(thdS rpcclient.ClientConnector) { if thdS != nil && reflect.ValueOf(thdS).IsNil() { thdS = nil } @@ -3542,7 +3542,7 @@ func (sS *SessionS) SetThresholSConnection(thdS rpcclient.RpcClientConnection) { // SetStatSConnection sets the new connection to the stat service // only used on reload -func (sS *SessionS) SetStatSConnection(stS rpcclient.RpcClientConnection) { +func (sS *SessionS) SetStatSConnection(stS rpcclient.ClientConnector) { if stS != nil && reflect.ValueOf(stS).IsNil() { stS = nil } @@ -3551,7 +3551,7 @@ func (sS *SessionS) SetStatSConnection(stS rpcclient.RpcClientConnection) { // SetChargerSConnection sets the new connection to the charger service // only used on reload -func (sS *SessionS) SetChargerSConnection(chS rpcclient.RpcClientConnection) { +func (sS *SessionS) SetChargerSConnection(chS rpcclient.ClientConnector) { if chS != nil && reflect.ValueOf(chS).IsNil() { chS = nil } @@ -3560,7 +3560,7 @@ func (sS *SessionS) SetChargerSConnection(chS rpcclient.RpcClientConnection) { // SetRALsConnection sets the new connection to the RAL service // only used on reload -func (sS *SessionS) SetRALsConnection(rls rpcclient.RpcClientConnection) { +func (sS *SessionS) SetRALsConnection(rls rpcclient.ClientConnector) { if rls != nil && reflect.ValueOf(rls).IsNil() { rls = nil } @@ -3569,7 +3569,7 @@ func (sS *SessionS) SetRALsConnection(rls rpcclient.RpcClientConnection) { // SetResourceSConnection sets the new connection to the resource service // only used on reload -func (sS *SessionS) SetResourceSConnection(rS rpcclient.RpcClientConnection) { +func (sS *SessionS) SetResourceSConnection(rS rpcclient.ClientConnector) { if rS != nil && reflect.ValueOf(rS).IsNil() { rS = nil } @@ -3578,7 +3578,7 @@ func (sS *SessionS) SetResourceSConnection(rS rpcclient.RpcClientConnection) { // SetSupplierSConnection sets the new connection to the supplier service // only used on reload -func (sS *SessionS) SetSupplierSConnection(splS rpcclient.RpcClientConnection) { +func (sS *SessionS) SetSupplierSConnection(splS rpcclient.ClientConnector) { if splS != nil && reflect.ValueOf(splS).IsNil() { splS = nil } @@ -3587,7 +3587,7 @@ func (sS *SessionS) SetSupplierSConnection(splS rpcclient.RpcClientConnection) { // SetCDRSConnection sets the new connection to the CDR server // only used on reload -func (sS *SessionS) SetCDRSConnection(cdrS rpcclient.RpcClientConnection) { +func (sS *SessionS) SetCDRSConnection(cdrS rpcclient.ClientConnector) { if cdrS != nil && reflect.ValueOf(cdrS).IsNil() { cdrS = nil } diff --git a/sessions/sessions_bench_test.go b/sessions/sessions_bench_test.go index c50b00ca7..028dc1692 100644 --- a/sessions/sessions_bench_test.go +++ b/sessions/sessions_bench_test.go @@ -51,7 +51,7 @@ func startRPC() { log.Fatal(err) } config.SetCgrConfig(sBenchCfg) - if sBenchRPC, err = jsonrpc.Dial("tcp", sBenchCfg.ListenCfg().RPCJSONListen); err != nil { + if sBenchRPC, err = jsonrpc.Dial(utils.TCP, sBenchCfg.ListenCfg().RPCJSONListen); err != nil { log.Fatalf("Error at dialing rcp client:%v\n", err) } } @@ -197,7 +197,7 @@ func BenchmarkEncodingJSON(b *testing.B) { log.Fatal(err) } - if sBenchRPC, err = jsonrpc.Dial("tcp", sBenchCfg.ListenCfg().RPCJSONListen); err != nil { + if sBenchRPC, err = jsonrpc.Dial(utils.TCP, sBenchCfg.ListenCfg().RPCJSONListen); err != nil { log.Fatalf("Error at dialing rcp client:%v\n", err) } b.ResetTimer() @@ -219,7 +219,7 @@ func BenchmarkEncodingGOB(b *testing.B) { log.Fatal(err) } - if sBenchRPC, err = rpc.Dial("tcp", sBenchCfg.ListenCfg().RPCGOBListen); err != nil { + if sBenchRPC, err = rpc.Dial(utils.TCP, sBenchCfg.ListenCfg().RPCGOBListen); err != nil { log.Fatalf("Error at dialing rcp client:%v\n", err) } b.ResetTimer() diff --git a/sessions/sessions_test.go b/sessions/sessions_test.go index 719b77786..313a914c1 100644 --- a/sessions/sessions_test.go +++ b/sessions/sessions_test.go @@ -1732,7 +1732,7 @@ func (*testRPCClientConnection) Call(string, interface{}, interface{}) error { r func TestNewSessionS(t *testing.T) { cgrCGF, _ := config.NewDefaultCGRConfig() - var rpc rpcclient.RpcClientConnection + var rpc rpcclient.ClientConnector var ttest *testRPCClientConnection rpc = ttest @@ -1748,7 +1748,7 @@ func TestNewSessionS(t *testing.T) { attrS: nil, cdrS: nil, sReplConns: nil, - biJClnts: make(map[rpcclient.RpcClientConnection]string), + biJClnts: make(map[rpcclient.ClientConnector]string), biJIDs: make(map[string]*biJClient), aSessions: make(map[string]*Session), aSessionsIdx: make(map[string]map[string]map[string]utils.StringMap), diff --git a/utils/birpcint_client.go b/utils/birpcint_client.go index a1a2f0425..85ee2e8d8 100644 --- a/utils/birpcint_client.go +++ b/utils/birpcint_client.go @@ -28,7 +28,7 @@ import ( // NewBiJSONrpcClient will create a bidirectional JSON client connection func NewBiJSONrpcClient(addr string, handlers map[string]interface{}) (*rpc2.Client, error) { - conn, err := net.Dial("tcp", addr) + conn, err := net.Dial(TCP, addr) if err != nil { return nil, err } @@ -42,8 +42,8 @@ func NewBiJSONrpcClient(addr string, handlers map[string]interface{}) (*rpc2.Cli // Interface which the server needs to work as BiRPCServer type BiRPCServer interface { - Call(string, interface{}, interface{}) error // So we can use it also as rpcclient.RpcClientConnection - CallBiRPC(rpcclient.RpcClientConnection, string, interface{}, interface{}) error + Call(string, interface{}, interface{}) error // So we can use it also as rpcclient.ClientConnector + CallBiRPC(rpcclient.ClientConnector, string, interface{}, interface{}) error } func NewBiRPCInternalClient(serverConn BiRPCServer) *BiRPCInternalClient { @@ -53,15 +53,15 @@ func NewBiRPCInternalClient(serverConn BiRPCServer) *BiRPCInternalClient { // Need separate client from the original RpcClientConnection since diretly passing the server is not enough without passing the client's reference type BiRPCInternalClient struct { serverConn BiRPCServer - clntConn rpcclient.RpcClientConnection // conn to reach client and do calls over it + clntConn rpcclient.ClientConnector // conn to reach client and do calls over it } // Used in case when clientConn is not available at init time (eg: SMGAsterisk who needs the biRPCConn at initialization) -func (clnt *BiRPCInternalClient) SetClientConn(clntConn rpcclient.RpcClientConnection) { +func (clnt *BiRPCInternalClient) SetClientConn(clntConn rpcclient.ClientConnector) { clnt.clntConn = clntConn } -// Part of rpcclient.RpcClientConnection interface +// Part of rpcclient.ClientConnector interface func (clnt *BiRPCInternalClient) Call(serviceMethod string, args interface{}, reply interface{}) error { return clnt.serverConn.CallBiRPC(clnt.clntConn, serviceMethod, args, reply) } diff --git a/utils/birpcint_client_test.go b/utils/birpcint_client_test.go index 5c9de489c..cb9348da6 100644 --- a/utils/birpcint_client_test.go +++ b/utils/birpcint_client_test.go @@ -36,7 +36,7 @@ func TestNewBiJSONrpcClient(t *testing.T) { t.Error("Expencting: \"connection refused\", received : nil") } - l, err := net.Listen("tcp", addr) + l, err := net.Listen(TCP, addr) if err != nil { t.Error(err) } @@ -58,7 +58,7 @@ type testBiRPCServer struct { } func (*testBiRPCServer) Call(string, interface{}, interface{}) error { return nil } -func (t *testBiRPCServer) CallBiRPC(_ rpcclient.RpcClientConnection, metod string, args interface{}, reply interface{}) error { +func (t *testBiRPCServer) CallBiRPC(_ rpcclient.ClientConnector, metod string, args interface{}, reply interface{}) error { t.metod = metod t.args = args t.reply = reply diff --git a/utils/consts.go b/utils/consts.go index 0b8d8b876..65b5e0911 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -151,7 +151,6 @@ const ( FILTER_VAL_START = "(" FILTER_VAL_END = ")" JSON = "json" - GOB = "gob" MSGPACK = "msgpack" CSV_LOAD = "CSVLOAD" CGRID = "CGRID" diff --git a/utils/server.go b/utils/server.go index fd1032abe..057cc91d1 100644 --- a/utils/server.go +++ b/utils/server.go @@ -148,7 +148,7 @@ func (s *Server) ServeJSON(addr string) { return } - lJSON, e := net.Listen("tcp", addr) + lJSON, e := net.Listen(TCP, addr) if e != nil { log.Fatal("ServeJSON listen error:", e) } @@ -188,7 +188,7 @@ func (s *Server) ServeGOB(addr string) { if !enabled { return } - lGOB, e := net.Listen("tcp", addr) + lGOB, e := net.Listen(TCP, addr) if e != nil { log.Fatal("ServeGOB listen error:", e) } @@ -306,7 +306,7 @@ func (s *Server) ServeBiJSON(addr string, onConn func(*rpc2.Client), onDis func( return fmt.Errorf("BiRPCServer should not be nil") } var lBiJSON net.Listener - lBiJSON, err = net.Listen("tcp", addr) + lBiJSON, err = net.Listen(TCP, addr) if err != nil { log.Fatal("ServeBiJSON listen error:", err) return @@ -426,7 +426,7 @@ func (s *Server) ServeGOBTLS(addr, serverCrt, serverKey, caCert string, if err != nil { return } - listener, err := tls.Listen("tcp", addr, &config) + listener, err := tls.Listen(TCP, addr, &config) if err != nil { log.Fatalf("Error: %s when listening", err) } @@ -467,7 +467,7 @@ func (s *Server) ServeJSONTLS(addr, serverCrt, serverKey, caCert string, if err != nil { return } - listener, err := tls.Listen("tcp", addr, &config) + listener, err := tls.Listen(TCP, addr, &config) if err != nil { log.Fatalf("Error: %s when listening", err) }