mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 05:09:54 +05:00
Add backwards compatible with ApierV1/ApierV2 prefix
This commit is contained in:
committed by
Dan Christian Bogos
parent
a1c61a76d0
commit
0fcafbb526
@@ -136,6 +136,7 @@ var (
|
||||
testApierReplayFailedPosts,
|
||||
testApierGetDataDBVesions,
|
||||
testApierGetStorDBVesions,
|
||||
testApierBackwardsCompatible,
|
||||
testApierStopEngine,
|
||||
}
|
||||
)
|
||||
@@ -1999,6 +2000,15 @@ func testApierGetStorDBVesions(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testApierBackwardsCompatible(t *testing.T) {
|
||||
var reply string
|
||||
if err := rater.Call("ApierV1.Ping", new(utils.CGREvent), &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.Pong {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.Pong, reply)
|
||||
}
|
||||
}
|
||||
|
||||
// Simply kill the engine after we are done with tests within this file
|
||||
func testApierStopEngine(t *testing.T) {
|
||||
if err := engine.KillEngine(100); err != nil {
|
||||
|
||||
@@ -334,3 +334,9 @@ func (apiv2 *APIerSv2) SetActions(attrs utils.AttrSetActions, reply *string) err
|
||||
*reply = utils.OK
|
||||
return nil
|
||||
}
|
||||
|
||||
// Ping return pong if the service is active
|
||||
func (apiv2 *APIerSv2) Ping(ign *utils.CGREvent, reply *string) error {
|
||||
*reply = utils.Pong
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ var (
|
||||
testAPIerSv2itSetActionWithCategory,
|
||||
testAPIerSv2itSetActionPlanWithWrongTiming,
|
||||
testAPIerSv2itSetActionPlanWithWrongTiming2,
|
||||
testAPIerSv2BackwardsCompatible,
|
||||
testAPIerSv2itKillEngine,
|
||||
}
|
||||
)
|
||||
@@ -430,6 +431,15 @@ func testAPIerSv2itSetActionPlanWithWrongTiming2(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testAPIerSv2BackwardsCompatible(t *testing.T) {
|
||||
var reply string
|
||||
if err := apierRPC.Call("ApierV2.Ping", new(utils.CGREvent), &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.Pong {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.Pong, reply)
|
||||
}
|
||||
}
|
||||
|
||||
func testAPIerSv2itKillEngine(t *testing.T) {
|
||||
if err := engine.KillEngine(delay); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -115,13 +115,14 @@ func (apiService *APIerSv1Service) Start() (err error) {
|
||||
|
||||
if !apiService.cfg.DispatcherSCfg().Enabled {
|
||||
apiService.server.RpcRegister(apiService.api)
|
||||
apiService.server.RpcRegisterName(utils.ApierV1, apiService.api)
|
||||
apiService.server.RpcRegister(v1.NewReplicatorSv1(datadb))
|
||||
}
|
||||
|
||||
utils.RegisterRpcParams("", &v1.CDRsV1{})
|
||||
utils.RegisterRpcParams("", &v1.SMGenericV1{})
|
||||
utils.RegisterRpcParams("", apiService.api)
|
||||
utils.RegisterRpcParams("ApierV1", apiService.api)
|
||||
utils.RegisterRpcParams(utils.ApierV1, apiService.api)
|
||||
//backwards compatible
|
||||
|
||||
apiService.connChan <- apiService.api
|
||||
|
||||
@@ -71,11 +71,12 @@ func (api *APIerSv2Service) Start() (err error) {
|
||||
|
||||
if !api.cfg.DispatcherSCfg().Enabled {
|
||||
api.server.RpcRegister(api.api)
|
||||
api.server.RpcRegisterName(utils.ApierV2, api.api)
|
||||
}
|
||||
|
||||
utils.RegisterRpcParams("", &v2.CDRsV2{})
|
||||
utils.RegisterRpcParams("", api.api)
|
||||
utils.RegisterRpcParams("ApierV2", api.api)
|
||||
utils.RegisterRpcParams(utils.ApierV2, api.api)
|
||||
|
||||
api.connChan <- api.api
|
||||
return
|
||||
|
||||
@@ -968,6 +968,8 @@ const (
|
||||
|
||||
// APIerSv1 APIs
|
||||
const (
|
||||
ApierV1 = "ApierV1"
|
||||
ApierV2 = "ApierV2"
|
||||
APIerSv1 = "APIerSv1"
|
||||
APIerSv1ComputeFilterIndexes = "APIerSv1.ComputeFilterIndexes"
|
||||
APIerSv1ComputeFilterIndexIDs = "APIerSv1.ComputeFilterIndexIDs"
|
||||
|
||||
Reference in New Issue
Block a user