diff --git a/apier/v1/api_interfaces.go b/apier/v1/api_interfaces.go
index 142458821..b44ad9333 100644
--- a/apier/v1/api_interfaces.go
+++ b/apier/v1/api_interfaces.go
@@ -176,6 +176,10 @@ type CoreSv1Interface interface {
Ping(ign *utils.CGREventWithArgDispatcher, reply *string) error
}
+type RateSv1Interface interface {
+ Ping(ign *utils.CGREventWithArgDispatcher, reply *string) error
+}
+
type ReplicatorSv1Interface interface {
Ping(ign *utils.CGREventWithArgDispatcher, reply *string) error
GetAccount(args *utils.StringWithApiKey, reply *engine.Account) error
diff --git a/apier/v1/api_interfaces_test.go b/apier/v1/api_interfaces_test.go
index bd0fcd1d4..56638bf4c 100644
--- a/apier/v1/api_interfaces_test.go
+++ b/apier/v1/api_interfaces_test.go
@@ -108,3 +108,8 @@ func TestReplicatorSv1Interface(t *testing.T) {
_ = ReplicatorSv1Interface(NewDispatcherReplicatorSv1(nil))
_ = ReplicatorSv1Interface(NewReplicatorSv1(nil))
}
+
+func TestRateSv1Interface(t *testing.T) {
+ _ = RateSv1Interface(NewDispatcherRateSv1(nil))
+ _ = RateSv1Interface(NewRateSv1(nil))
+}
diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go
index 9904899a9..85e9d250f 100755
--- a/apier/v1/dispatcher.go
+++ b/apier/v1/dispatcher.go
@@ -1254,3 +1254,17 @@ func (dS *DispatcherReplicatorSv1) SetIndexes(args *utils.SetIndexesArg, reply *
func (dS *DispatcherReplicatorSv1) RemoveIndexes(args *utils.GetIndexesArg, reply *string) error {
return dS.dS.ReplicatorSv1RemoveIndexes(args, reply)
}
+
+func NewDispatcherRateSv1(dps *dispatchers.DispatcherService) *DispatcherRateSv1 {
+ return &DispatcherRateSv1{dR: dps}
+}
+
+// Exports RPC from RLs
+type DispatcherRateSv1 struct {
+ dR *dispatchers.DispatcherService
+}
+
+// Ping implements SupplierSv1Ping
+func (dR *DispatcherRateSv1) Ping(args *utils.CGREventWithArgDispatcher, reply *string) error {
+ return dR.dR.RateSv1Ping(args, reply)
+}
diff --git a/data/conf/samples/dispatchers/all/cgrates.json b/data/conf/samples/dispatchers/all/cgrates.json
index 50aed8677..a47e2e422 100644
--- a/data/conf/samples/dispatchers/all/cgrates.json
+++ b/data/conf/samples/dispatchers/all/cgrates.json
@@ -71,6 +71,12 @@
"enabled": true,
},
+
+"rates": {
+ "enabled": true,
+},
+
+
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/conf/samples/dispatchers/all2/cgrates.json b/data/conf/samples/dispatchers/all2/cgrates.json
index 6a2e871e2..770ddbad9 100644
--- a/data/conf/samples/dispatchers/all2/cgrates.json
+++ b/data/conf/samples/dispatchers/all2/cgrates.json
@@ -66,6 +66,12 @@
"enabled": true,
},
+
+"rates": {
+ "enabled": true,
+},
+
+
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/conf/samples/dispatchers/all2_mongo/cgrates.json b/data/conf/samples/dispatchers/all2_mongo/cgrates.json
index 34ca0e53b..8cf290555 100644
--- a/data/conf/samples/dispatchers/all2_mongo/cgrates.json
+++ b/data/conf/samples/dispatchers/all2_mongo/cgrates.json
@@ -70,6 +70,12 @@
"enabled": true,
},
+
+"rates": {
+ "enabled": true,
+},
+
+
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/conf/samples/dispatchers/all2_mysql/cgrates.json b/data/conf/samples/dispatchers/all2_mysql/cgrates.json
index 00fc2281b..a697920d0 100644
--- a/data/conf/samples/dispatchers/all2_mysql/cgrates.json
+++ b/data/conf/samples/dispatchers/all2_mysql/cgrates.json
@@ -67,6 +67,12 @@
"enabled": true,
},
+
+"rates": {
+ "enabled": true,
+},
+
+
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/conf/samples/dispatchers/all_mongo/cgrates.json b/data/conf/samples/dispatchers/all_mongo/cgrates.json
index 9cd1b498a..583c6781c 100644
--- a/data/conf/samples/dispatchers/all_mongo/cgrates.json
+++ b/data/conf/samples/dispatchers/all_mongo/cgrates.json
@@ -74,6 +74,12 @@
"enabled": true,
},
+
+"rates": {
+ "enabled": true,
+},
+
+
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/conf/samples/dispatchers/all_mysql/cgrates.json b/data/conf/samples/dispatchers/all_mysql/cgrates.json
index 5a81c9f37..68ea5ebf9 100644
--- a/data/conf/samples/dispatchers/all_mysql/cgrates.json
+++ b/data/conf/samples/dispatchers/all_mysql/cgrates.json
@@ -72,6 +72,12 @@
"enabled": true,
},
+
+"rates": {
+ "enabled": true,
+},
+
+
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/tariffplans/dispatchers/Attributes.csv b/data/tariffplans/dispatchers/Attributes.csv
index e80282a45..e2a1c8d92 100644
--- a/data/tariffplans/dispatchers/Attributes.csv
+++ b/data/tariffplans/dispatchers/Attributes.csv
@@ -22,3 +22,4 @@ cgrates.org,ATTR_API_APIER_AUTH,*auth,*string:~*req.APIKey:apier12345,,,*req.API
cgrates.org,ATTR_API_RALS_AUTH,*auth,*string:~*req.APIKey:rals12345,,,*req.APIMethods,*constant,RALsV1.Ping&RALsV1.GetRatingPlansCost,false,20
cgrates.org,ATTR_API_REPLICATOR_AUTH,*auth,*string:~*req.APIKey:repl12345,,,*req.APIMethods,*constant,ReplicatorSv1.Ping&ReplicatorSv1.GetAccount&ReplicatorSv1.SetAccount&ReplicatorSv1.RemoveAccount&ReplicatorSv1.GetRouteProfile&ReplicatorSv1.SetRouteProfile&ReplicatorSv1.RemoveRouteProfile&ReplicatorSv1.GetAttributeProfile&ReplicatorSv1.SetAttributeProfile&ReplicatorSv1.RemoveAttributeProfile&ReplicatorSv1.SetChargerProfile&ReplicatorSv1.GetChargerProfile&ReplicatorSv1.RemoveChargerProfile&ReplicatorSv1.GetDispatcherProfile&ReplicatorSv1.SetDispatcherProfile&ReplicatorSv1.RemoveDispatcherProfile&ReplicatorSv1.GetDispatcherHost&ReplicatorSv1.SetDispatcherHost&ReplicatorSv1.RemoveDispatcherHost&ReplicatorSv1.GetFilter&ReplicatorSv1.SetFilter&ReplicatorSv1.RemoveFilter&ReplicatorSv1.GetThreshold&ReplicatorSv1.SetThreshold&ReplicatorSv1.RemoveThreshold&ReplicatorSv1.GetStatQueue&ReplicatorSv1.SetStatQueue&ReplicatorSv1.RemoveStatQueue&ReplicatorSv1.GetResource&ReplicatorSv1.SetResource&ReplicatorSv1.RemoveResource&ReplicatorSv1.GetResourceProfile&ReplicatorSv1.SetResourceProfile&ReplicatorSv1.RemoveResourceProfile&ReplicatorSv1.GetStatQueueProfile&ReplicatorSv1.SetStatQueueProfile&ReplicatorSv1.RemoveStatQueueProfile&ReplicatorSv1.GetThresholdProfile&ReplicatorSv1.SetThresholdProfile&ReplicatorSv1.RemoveThresholdProfile&ReplicatorSv1.GetTiming&ReplicatorSv1.SetTiming&ReplicatorSv1.RemoveTiming&ReplicatorSv1.GetActionTriggers&ReplicatorSv1.SetActionTriggers&ReplicatorSv1.RemoveActionTriggers&ReplicatorSv1.SetSharedGroup&ReplicatorSv1.GetSharedGroup&ReplicatorSv1.RemoveSharedGroup&ReplicatorSv1.SetActions&ReplicatorSv1.GetActions&ReplicatorSv1.RemoveActions&ReplicatorSv1.SetActionPlan&ReplicatorSv1.GetActionPlan&ReplicatorSv1.RemoveActionPlan&ReplicatorSv1.SetAccountActionPlans&ReplicatorSv1.GetAccountActionPlans&ReplicatorSv1.RemAccountActionPlans&ReplicatorSv1.SetRatingPlan&ReplicatorSv1.GetRatingPlan&ReplicatorSv1.RemoveRatingPlan&ReplicatorSv1.SetRatingProfile&ReplicatorSv1.GetRatingProfile&ReplicatorSv1.RemoveRatingProfile&ReplicatorSv1.SetDestination&ReplicatorSv1.GetDestination&ReplicatorSv1.RemoveDestination&ReplicatorSv1.SetLoadIDs&ReplicatorSv1.GetItemLoadIDs&ReplicatorSv1.SetRateProfile&ReplicatorSv1.GetRateProfile&ReplicatorSv1.RemoveRateProfile,false,20
cgrates.org,ATTR_API_CDRSV2,*auth,*string:~*req.APIKey:cdrsv212345,,,*req.APIMethods,*constant,CDRsV2.ProcessEvent&CDRsV2.StoreSessionCost,false,20
+cgrates.org,ATTR_API_RATES_AUTH,*auth,*string:~*req.APIKey:rPrf12345,,,*req.APIMethods,*constant,RateSv1.Ping,false,20
diff --git a/data/tariffplans/dispatchers_gob/Attributes.csv b/data/tariffplans/dispatchers_gob/Attributes.csv
index 357aa3c91..ebad76499 100644
--- a/data/tariffplans/dispatchers_gob/Attributes.csv
+++ b/data/tariffplans/dispatchers_gob/Attributes.csv
@@ -22,3 +22,4 @@ cgrates.org,ATTR_API_APIER_AUTH,*auth,*string:~*req.APIKey:apier12345,,,*req.API
cgrates.org,ATTR_API_RALS_AUTH,*auth,*string:~*req.APIKey:rals12345,,,*req.APIMethods,*constant,RALsV1.Ping&RALsV1.GetRatingPlansCost,false,20
cgrates.org,ATTR_API_REPLICATOR_AUTH,*auth,*string:~*req.APIKey:repl12345,,,*req.APIMethods,*constant,ReplicatorSv1.Ping&ReplicatorSv1.GetAccount&ReplicatorSv1.SetAccount&ReplicatorSv1.RemoveAccount&ReplicatorSv1.GetRouteProfile&ReplicatorSv1.SetRouteProfile&ReplicatorSv1.RemoveRouteProfile&ReplicatorSv1.GetAttributeProfile&ReplicatorSv1.SetAttributeProfile&ReplicatorSv1.RemoveAttributeProfile&ReplicatorSv1.SetChargerProfile&ReplicatorSv1.GetChargerProfile&ReplicatorSv1.RemoveChargerProfile&ReplicatorSv1.GetDispatcherProfile&ReplicatorSv1.SetDispatcherProfile&ReplicatorSv1.RemoveDispatcherProfile&ReplicatorSv1.GetDispatcherHost&ReplicatorSv1.SetDispatcherHost&ReplicatorSv1.RemoveDispatcherHost&ReplicatorSv1.GetFilter&ReplicatorSv1.SetFilter&ReplicatorSv1.RemoveFilter&ReplicatorSv1.GetThreshold&ReplicatorSv1.SetThreshold&ReplicatorSv1.RemoveThreshold&ReplicatorSv1.GetStatQueue&ReplicatorSv1.SetStatQueue&ReplicatorSv1.RemoveStatQueue&ReplicatorSv1.GetResource&ReplicatorSv1.SetResource&ReplicatorSv1.RemoveResource&ReplicatorSv1.GetResourceProfile&ReplicatorSv1.SetResourceProfile&ReplicatorSv1.RemoveResourceProfile&ReplicatorSv1.GetStatQueueProfile&ReplicatorSv1.SetStatQueueProfile&ReplicatorSv1.RemoveStatQueueProfile&ReplicatorSv1.GetThresholdProfile&ReplicatorSv1.SetThresholdProfile&ReplicatorSv1.RemoveThresholdProfile&ReplicatorSv1.GetTiming&ReplicatorSv1.SetTiming&ReplicatorSv1.RemoveTiming&ReplicatorSv1.GetActionTriggers&ReplicatorSv1.SetActionTriggers&ReplicatorSv1.RemoveActionTriggers&ReplicatorSv1.SetSharedGroup&ReplicatorSv1.GetSharedGroup&ReplicatorSv1.RemoveSharedGroup&ReplicatorSv1.SetActions&ReplicatorSv1.GetActions&ReplicatorSv1.RemoveActions&ReplicatorSv1.SetActionPlan&ReplicatorSv1.GetActionPlan&ReplicatorSv1.RemoveActionPlan&ReplicatorSv1.SetAccountActionPlans&ReplicatorSv1.GetAccountActionPlans&ReplicatorSv1.RemAccountActionPlans&ReplicatorSv1.SetRatingPlan&ReplicatorSv1.GetRatingPlan&ReplicatorSv1.RemoveRatingPlan&ReplicatorSv1.SetRatingProfile&ReplicatorSv1.GetRatingProfile&ReplicatorSv1.RemoveRatingProfile&ReplicatorSv1.SetDestination&ReplicatorSv1.GetDestination&ReplicatorSv1.RemoveDestination&ReplicatorSv1.SetLoadIDs&ReplicatorSv1.GetItemLoadIDs&ReplicatorSv1.SetRateProfile&ReplicatorSv1.GetRateProfile&ReplicatorSv1.RemoveRateProfile,false,20
cgrates.org,ATTR_API_CDRSV2,*auth,*string:~*req.APIKey:cdrsv212345,,,*req.APIMethods,*constant,CDRsV2.ProcessEvent&CDRsV2.StoreSessionCost,false,20
+cgrates.org,ATTR_API_RATES_AUTH,*auth,*string:~*req.APIKey:rPrf12345,,,*req.APIMethods,*constant,RateSv1.Ping,false,20
diff --git a/dispatchers/rates.go b/dispatchers/rates.go
new file mode 100644
index 000000000..99a8103ea
--- /dev/null
+++ b/dispatchers/rates.go
@@ -0,0 +1,43 @@
+/*
+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 dispatchers
+
+import "github.com/cgrates/cgrates/utils"
+
+func (dS *DispatcherService) RateSv1Ping(args *utils.CGREventWithArgDispatcher, rpl *string) (err error) {
+ if args == nil {
+ args = utils.NewCGREventWithArgDispatcher()
+ }
+ args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
+ if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
+ if args.ArgDispatcher == nil {
+ return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
+ }
+ if err = dS.authorize(utils.RateSv1Ping, args.CGREvent.Tenant,
+ args.APIKey, args.CGREvent.Time); err != nil {
+ return
+ }
+ }
+ var routeID *string
+ if args.ArgDispatcher != nil {
+ routeID = args.ArgDispatcher.RouteID
+ }
+ return dS.Dispatch(args.CGREvent, utils.RateS, routeID,
+ utils.RateSv1Ping, args, rpl)
+}
diff --git a/dispatchers/rates_it_test.go b/dispatchers/rates_it_test.go
new file mode 100644
index 000000000..f862451e0
--- /dev/null
+++ b/dispatchers/rates_it_test.go
@@ -0,0 +1,79 @@
+// +build integration
+
+/*
+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 dispatchers
+
+import (
+ "testing"
+
+ "github.com/cgrates/cgrates/utils"
+)
+
+var sTestsDspRPrf = []func(t *testing.T){
+ testDspRPrfPing,
+}
+
+//Test start here
+func TestDspRateSIT(t *testing.T) {
+ var config1, config2, config3 string
+ switch *dbType {
+ case utils.MetaInternal:
+ t.SkipNow()
+ case utils.MetaMySQL:
+ config1 = "all_mysql"
+ config2 = "all2_mysql"
+ config3 = "dispatchers_mysql"
+ case utils.MetaMongo:
+ config1 = "all_mongo"
+ config2 = "all2_mongo"
+ config3 = "dispatchers_mongo"
+ case utils.MetaPostgres:
+ t.SkipNow()
+ default:
+ t.Fatal("Unknown Database type")
+ }
+
+ dispDIR := "dispatchers"
+ if *encoding == utils.MetaGOB {
+ dispDIR += "_gob"
+ }
+ testDsp(t, sTestsDspRPrf, "TestDspRateSIT", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
+}
+
+func testDspRPrfPing(t *testing.T) {
+ var reply string
+ if err := allEngine.RPC.Call(utils.RateSv1Ping, new(utils.CGREvent), &reply); err != nil {
+ t.Error(err)
+ } else if reply != utils.Pong {
+ t.Errorf("Received: %s", reply)
+ }
+ if err := dispEngine.RPC.Call(utils.RateSv1Ping, &utils.CGREventWithArgDispatcher{
+ CGREvent: &utils.CGREvent{
+ Tenant: "cgrates.org",
+ },
+ ArgDispatcher: &utils.ArgDispatcher{
+ APIKey: utils.StringPointer("rPrf12345"),
+ },
+ }, &reply); err != nil {
+ t.Error(err)
+ } else if reply != utils.Pong {
+ t.Errorf("Received: %s", reply)
+ }
+}
diff --git a/services/dispatchers.go b/services/dispatchers.go
index 1f6df2de3..9522f1f0e 100644
--- a/services/dispatchers.go
+++ b/services/dispatchers.go
@@ -143,6 +143,9 @@ func (dspS *DispatcherService) Start() (err error) {
dspS.server.RpcRegisterName(utils.CDRsV2,
v2.NewDispatcherSCDRsV2(dspS.dspS))
+ dspS.server.RpcRegisterName(utils.RateSv1,
+ v1.NewDispatcherRateSv1(dspS.dspS))
+
dspS.connChan <- dspS.dspS
return