mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-22 07:38:45 +05:00
Add infrastructure for service
This commit is contained in:
committed by
Dan Christian Bogos
parent
530ad1e541
commit
a717fc4f3d
@@ -21,6 +21,8 @@ package v1
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/actions"
|
||||
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
@@ -139,3 +141,25 @@ func (apierSv1 *APIerSv1) RemoveActionProfile(arg *utils.TenantIDWithCache, repl
|
||||
*reply = utils.OK
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewActionSv1 initializes ActionSv1
|
||||
func NewActionSv1(aS *actions.ActionS) *ActionSv1 {
|
||||
return &ActionSv1{aS: aS}
|
||||
}
|
||||
|
||||
// ActionSv1 exports RPC from RLs
|
||||
type ActionSv1 struct {
|
||||
aS *actions.ActionS
|
||||
}
|
||||
|
||||
// Call implements rpcclient.ClientConnector interface for internal RPC
|
||||
func (aSv1 *ActionSv1) Call(serviceMethod string,
|
||||
args interface{}, reply interface{}) error {
|
||||
return utils.APIerRPCCall(aSv1, serviceMethod, args, reply)
|
||||
}
|
||||
|
||||
// Ping return pong if the service is active
|
||||
func (aSv1 *ActionSv1) Ping(ign *utils.CGREvent, reply *string) error {
|
||||
*reply = utils.Pong
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ var (
|
||||
testActionSRPCConn,
|
||||
testActionSLoadFromFolder,
|
||||
testActionSGetActionProfile,
|
||||
testActionSPing,
|
||||
testActionSKillEngine,
|
||||
}
|
||||
)
|
||||
@@ -179,6 +180,15 @@ func testActionSGetActionProfile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testActionSPing(t *testing.T) {
|
||||
var resp string
|
||||
if err := actSRPC.Call(utils.ActionSv1Ping, new(utils.CGREvent), &resp); err != nil {
|
||||
t.Error(err)
|
||||
} else if resp != utils.Pong {
|
||||
t.Error("Unexpected reply returned", resp)
|
||||
}
|
||||
}
|
||||
|
||||
func testActionSKillEngine(t *testing.T) {
|
||||
if err := engine.KillEngine(100); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -1299,3 +1299,17 @@ type DispatcherRateSv1 struct {
|
||||
func (dR *DispatcherRateSv1) Ping(args *utils.CGREventWithOpts, reply *string) error {
|
||||
return dR.dR.RateSv1Ping(args, reply)
|
||||
}
|
||||
|
||||
func NewDispatcherActionSv1(dps *dispatchers.DispatcherService) *DispatcherActionSv1 {
|
||||
return &DispatcherActionSv1{dR: dps}
|
||||
}
|
||||
|
||||
// Exports RPC from RLs
|
||||
type DispatcherActionSv1 struct {
|
||||
dR *dispatchers.DispatcherService
|
||||
}
|
||||
|
||||
// Ping implements RateSv1Ping
|
||||
func (dR *DispatcherActionSv1) Ping(args *utils.CGREventWithOpts, reply *string) error {
|
||||
return dR.dR.ActionSv1Ping(args, reply)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user