remove loaders subsystem

This commit is contained in:
gezimbll
2026-01-23 16:40:36 +01:00
committed by Dan Christian Bogos
parent 16370dbe53
commit 3153bc8378
68 changed files with 44 additions and 13021 deletions

View File

@@ -1,65 +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 Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
*/
package console
import (
"github.com/cgrates/cgrates/loaders"
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdLoaderLoad{
name: "loader_load",
rpcMethod: utils.LoaderSv1Load,
rpcParams: &loaders.ArgsProcessFolder{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
type CmdLoaderLoad struct {
name string
rpcMethod string
rpcParams *loaders.ArgsProcessFolder
*CommandExecuter
}
func (self *CmdLoaderLoad) Name() string {
return self.name
}
func (self *CmdLoaderLoad) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdLoaderLoad) RpcParams(reset bool) any {
if reset || self.rpcParams == nil {
self.rpcParams = &loaders.ArgsProcessFolder{}
}
return self.rpcParams
}
func (self *CmdLoaderLoad) PostprocessRpcParams() error {
return nil
}
func (self *CmdLoaderLoad) RpcResult() any {
var s string
return &s
}

View File

@@ -1,54 +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 Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
*/
package console
import (
"reflect"
"strings"
"testing"
v1 "github.com/cgrates/cgrates/apier/v1"
"github.com/cgrates/cgrates/utils"
)
func TestCmdLoaderLoad(t *testing.T) {
// commands map is initiated in init function
command := commands["loader_load"]
// verify if ApierSv1 object has method on it
m, ok := reflect.TypeOf(new(v1.LoaderSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
if !ok {
t.Fatal("method not found")
}
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
// verify the type of input parameter
if ok := m.Type.In(2).AssignableTo(reflect.TypeOf(command.RpcParams(true))); !ok {
t.Fatalf("cannot assign input parameter")
}
// verify the type of output parameter
if ok := m.Type.In(3).AssignableTo(reflect.TypeOf(command.RpcResult())); !ok {
t.Fatalf("cannot assign output parameter")
}
// for coverage purpose
if err := command.PostprocessRpcParams(); err != nil {
t.Fatal(err)
}
}

View File

@@ -1,65 +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 Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
*/
package console
import (
"github.com/cgrates/cgrates/loaders"
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdLoaderRemove{
name: "loader_remove",
rpcMethod: utils.LoaderSv1Remove,
rpcParams: &loaders.ArgsProcessFolder{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
type CmdLoaderRemove struct {
name string
rpcMethod string
rpcParams *loaders.ArgsProcessFolder
*CommandExecuter
}
func (self *CmdLoaderRemove) Name() string {
return self.name
}
func (self *CmdLoaderRemove) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdLoaderRemove) RpcParams(reset bool) any {
if reset || self.rpcParams == nil {
self.rpcParams = &loaders.ArgsProcessFolder{}
}
return self.rpcParams
}
func (self *CmdLoaderRemove) PostprocessRpcParams() error {
return nil
}
func (self *CmdLoaderRemove) RpcResult() any {
var s string
return &s
}

View File

@@ -1,54 +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 Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
*/
package console
import (
"reflect"
"strings"
"testing"
v1 "github.com/cgrates/cgrates/apier/v1"
"github.com/cgrates/cgrates/utils"
)
func TestCmdLoaderRemove(t *testing.T) {
// commands map is initiated in init function
command := commands["loader_remove"]
// verify if ApierSv1 object has method on it
m, ok := reflect.TypeOf(new(v1.LoaderSv1)).MethodByName(strings.Split(command.RpcMethod(), utils.NestingSep)[1])
if !ok {
t.Fatal("method not found")
}
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
// verify the type of input parameter
if ok := m.Type.In(2).AssignableTo(reflect.TypeOf(command.RpcParams(true))); !ok {
t.Fatalf("cannot assign input parameter")
}
// verify the type of output parameter
if ok := m.Type.In(3).AssignableTo(reflect.TypeOf(command.RpcResult())); !ok {
t.Fatalf("cannot assign output parameter")
}
// for coverage purpose
if err := command.PostprocessRpcParams(); err != nil {
t.Fatal(err)
}
}

View File

@@ -65,8 +65,6 @@ func (self *CmdApierPing) RpcMethod() string {
return utils.ThresholdSv1Ping
case utils.SessionsLow:
return utils.SessionSv1Ping
case utils.LoaderSLow:
return utils.LoaderSv1Ping
case utils.DispatcherSLow:
return utils.DispatcherSv1Ping
case utils.AnalyzerSLow:

View File

@@ -303,45 +303,6 @@ func TestCmdPingSessionsLow(t *testing.T) {
}
}
func TestCmdPingLoaderSLow(t *testing.T) {
// commands map is initiated in init function
command := commands["ping"]
castCommand, canCast := command.(*CmdApierPing)
if !canCast {
t.Fatalf("cannot cast")
}
castCommand.item = utils.LoaderSLow
result2 := command.RpcMethod()
if !reflect.DeepEqual(result2, utils.LoaderSv1Ping) {
t.Errorf("Expected <%+v>, Received <%+v>", utils.LoaderSv1Ping, result2)
}
srv, err := engine.NewService(&v1.LoaderSv1{})
if err != nil {
t.Fatal(err)
}
mType, ok := srv.Methods["Ping"]
if !ok {
t.Fatal("method not found")
}
m := mType.Method
if m.Type.NumIn() != 4 { // expecting 4 inputs
t.Fatalf("invalid number of input parameters ")
}
// for coverage purpose
result := command.RpcParams(true)
if !reflect.DeepEqual(result, new(StringWrapper)) {
t.Errorf("Expected <%T>, Received <%T>", new(StringWrapper), result)
}
// verify the type of output parameter
if ok := m.Type.In(3).AssignableTo(reflect.TypeOf(command.RpcResult())); !ok {
t.Fatalf("cannot assign output parameter")
}
// for coverage purpose
if err := command.PostprocessRpcParams(); err != nil {
t.Fatal(err)
}
}
func TestCmdPingDispatcherSLow(t *testing.T) {
// commands map is initiated in init function
command := commands["ping"]