diff --git a/dispatchers/dispatchers_it_test.go b/dispatchers/dispatchers_it_test.go
index 18f8ae338..815f5e079 100644
--- a/dispatchers/dispatchers_it_test.go
+++ b/dispatchers/dispatchers_it_test.go
@@ -107,7 +107,8 @@ func testDspApierGetAttributes(t *testing.T) {
if err := dispEngine.RCP.Call("ApierV1.GetAttributeProfile",
utils.TenantIDWithArgDispatcher{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_Dispatcher"},
- ArgDispatcher: &utils.ArgDispatcher{APIKey: utils.StringPointer("apier12345")}}, &reply); err != nil {
+ ArgDispatcher: &utils.ArgDispatcher{APIKey: utils.StringPointer("apier12345")},
+ }, &reply); err != nil {
t.Fatal(err)
}
reply.Compile()
@@ -119,12 +120,11 @@ func testDspApierGetAttributes(t *testing.T) {
func testDspApierUnkownAPiKey(t *testing.T) {
var reply *engine.AttributeProfile
-
if err := dispEngine.RCP.Call("ApierV1.GetAttributeProfile",
utils.TenantIDWithArgDispatcher{
TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_Dispatcher"},
- ArgDispatcher: &utils.ArgDispatcher{APIKey: utils.StringPointer("RandomApiKey")}}, &reply); err == nil || err.Error() != utils.ErrUnknownApiKey.Error() {
+ ArgDispatcher: &utils.ArgDispatcher{APIKey: utils.StringPointer("RandomApiKey")},
+ }, &reply); err == nil || err.Error() != utils.ErrUnknownApiKey.Error() {
t.Fatal(err)
}
-
}
diff --git a/sessions/sessions_bench_test.go b/sessions/sessions_bench_test.go
index 7e5b37c2d..572724841 100644
--- a/sessions/sessions_bench_test.go
+++ b/sessions/sessions_bench_test.go
@@ -46,7 +46,7 @@ var (
func startRPC() {
var err error
sBenchCfg, err = config.NewCGRConfigFromPath(
- path.Join(config.CgrConfig().DataFolderPath, "conf", "samples", "tutmysql"))
+ path.Join(config.CgrConfig().DataFolderPath, "conf", "samples", "tutmongo"))
if err != nil {
log.Fatal(err)
}
@@ -183,6 +183,50 @@ func BenchmarkSendInitSession(b *testing.B) {
}
}
+func BenchmarkEncodingJSON(b *testing.B) {
+ maxCps = make(chan struct{}, *cps)
+ for i := 0; i < *cps; i++ { // init CPS limitation
+ maxCps <- struct{}{}
+ }
+ var err error
+ sBenchCfg, err = config.NewCGRConfigFromPath(
+ path.Join(config.CgrConfig().DataFolderPath, "conf", "samples", "tutmongo"))
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ if sBenchRPC, err = jsonrpc.Dial("tcp", sBenchCfg.ListenCfg().RPCJSONListen); err != nil {
+ log.Fatalf("Error at dialing rcp client:%v\n", err)
+ }
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ initSession(i)
+ }
+
+}
+
+func BenchmarkEncodingGOB(b *testing.B) {
+ maxCps = make(chan struct{}, *cps)
+ for i := 0; i < *cps; i++ { // init CPS limitation
+ maxCps <- struct{}{}
+ }
+ var err error
+ sBenchCfg, err = config.NewCGRConfigFromPath(
+ path.Join(config.CgrConfig().DataFolderPath, "conf", "samples", "tutmongo"))
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ if sBenchRPC, err = rpc.Dial("tcp", sBenchCfg.ListenCfg().RPCGOBListen); err != nil {
+ log.Fatalf("Error at dialing rcp client:%v\n", err)
+ }
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ initSession(i)
+ }
+
+}
+
func benchmarkSendInitSessionx10(b *testing.B) {
connOnce.Do(func() {
startRPC()
diff --git a/utils/gob_codec.go b/utils/gob_codec.go
deleted file mode 100644
index 97bba67d6..000000000
--- a/utils/gob_codec.go
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package utils
diff --git a/utils/server.go b/utils/server.go
index 6574a5df7..dd0db4977 100644
--- a/utils/server.go
+++ b/utils/server.go
@@ -497,7 +497,11 @@ func (s *Server) ServeHTTPTLS(addr, serverCrt, serverKey, caCert string, serverP
s.Unlock()
Logger.Info(" enabling handler for WebSocket connections")
wsHandler := websocket.Handler(func(ws *websocket.Conn) {
- jsonrpc.ServeConn(ws)
+ if s.isDispatched {
+ rpc.ServeCodec(NewCustomJSONServerCodec(ws))
+ } else {
+ jsonrpc.ServeConn(ws)
+ }
})
if useBasicAuth {
s.httpsMux.HandleFunc(wsRPCURL, use(func(w http.ResponseWriter, r *http.Request) {