mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
Replace interface{} with any
This commit is contained in:
committed by
Dan Christian Bogos
parent
97c3dab0f4
commit
6c16ff320f
@@ -94,13 +94,13 @@ func (c *capsServerCodec) ReadRequestHeader(r *rpc.Request) error {
|
||||
return c.sc.ReadRequestHeader(r)
|
||||
}
|
||||
|
||||
func (c *capsServerCodec) ReadRequestBody(x interface{}) error {
|
||||
func (c *capsServerCodec) ReadRequestBody(x any) error {
|
||||
if err := c.caps.Allocate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.sc.ReadRequestBody(x)
|
||||
}
|
||||
func (c *capsServerCodec) WriteResponse(r *rpc.Response, x interface{}) error {
|
||||
func (c *capsServerCodec) WriteResponse(r *rpc.Response, x any) error {
|
||||
if r.Error == utils.ErrMaxConcurrentRPCExceededNoCaps.Error() {
|
||||
r.Error = utils.ErrMaxConcurrentRPCExceeded.Error()
|
||||
} else {
|
||||
@@ -176,22 +176,22 @@ func (c *capsBiRPCCodec) ReadHeader(req *rpc2.Request, resp *rpc2.Response) (err
|
||||
}
|
||||
|
||||
// ReadRequestBody into args argument of handler function.
|
||||
func (c *capsBiRPCCodec) ReadRequestBody(x interface{}) (err error) {
|
||||
func (c *capsBiRPCCodec) ReadRequestBody(x any) (err error) {
|
||||
return c.sc.ReadRequestBody(x)
|
||||
}
|
||||
|
||||
// ReadResponseBody into reply argument of handler function.
|
||||
func (c *capsBiRPCCodec) ReadResponseBody(x interface{}) error {
|
||||
func (c *capsBiRPCCodec) ReadResponseBody(x any) error {
|
||||
return c.sc.ReadResponseBody(x)
|
||||
}
|
||||
|
||||
// WriteRequest must be safe for concurrent use by multiple goroutines.
|
||||
func (c *capsBiRPCCodec) WriteRequest(req *rpc2.Request, x interface{}) error {
|
||||
func (c *capsBiRPCCodec) WriteRequest(req *rpc2.Request, x any) error {
|
||||
return c.sc.WriteRequest(req, x)
|
||||
}
|
||||
|
||||
// WriteResponse must be safe for concurrent use by multiple goroutines.
|
||||
func (c *capsBiRPCCodec) WriteResponse(r *rpc2.Response, x interface{}) error {
|
||||
func (c *capsBiRPCCodec) WriteResponse(r *rpc2.Response, x any) error {
|
||||
if r.Error == utils.ErrMaxConcurrentRPCExceededNoCaps.Error() {
|
||||
r.Error = utils.ErrMaxConcurrentRPCExceeded.Error()
|
||||
} else {
|
||||
|
||||
@@ -41,10 +41,10 @@ func (c *mockServerCodec) ReadRequestHeader(r *rpc.Request) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (c *mockServerCodec) ReadRequestBody(x interface{}) (err error) {
|
||||
func (c *mockServerCodec) ReadRequestBody(x any) (err error) {
|
||||
return utils.ErrNotImplemented
|
||||
}
|
||||
func (c *mockServerCodec) WriteResponse(r *rpc.Response, x interface{}) error {
|
||||
func (c *mockServerCodec) WriteResponse(r *rpc.Response, x any) error {
|
||||
return nil
|
||||
}
|
||||
func (c *mockServerCodec) Close() error { return nil }
|
||||
@@ -147,11 +147,11 @@ func (mockBiRPCCodec) ReadHeader(r *rpc2.Request, _ *rpc2.Response) error {
|
||||
r.Method = utils.CoreSv1Ping
|
||||
return nil
|
||||
}
|
||||
func (mockBiRPCCodec) ReadRequestBody(interface{}) error { return utils.ErrNotImplemented }
|
||||
func (mockBiRPCCodec) ReadResponseBody(interface{}) error { return nil }
|
||||
func (mockBiRPCCodec) WriteRequest(*rpc2.Request, interface{}) error { return nil }
|
||||
func (mockBiRPCCodec) WriteResponse(*rpc2.Response, interface{}) error { return nil }
|
||||
func (mockBiRPCCodec) Close() error { return nil }
|
||||
func (mockBiRPCCodec) ReadRequestBody(any) error { return utils.ErrNotImplemented }
|
||||
func (mockBiRPCCodec) ReadResponseBody(any) error { return nil }
|
||||
func (mockBiRPCCodec) WriteRequest(*rpc2.Request, any) error { return nil }
|
||||
func (mockBiRPCCodec) WriteResponse(*rpc2.Response, any) error { return nil }
|
||||
func (mockBiRPCCodec) Close() error { return nil }
|
||||
|
||||
func TestNewCapsBiRPCCodec(t *testing.T) {
|
||||
mk := new(mockBiRPCCodec)
|
||||
|
||||
@@ -128,10 +128,10 @@ func MemProfiling(memProfDir string, interval time.Duration, nrFiles int, shdWg
|
||||
}
|
||||
|
||||
// Status returns the status of the engine
|
||||
func (cS *CoreService) Status(arg *utils.TenantWithAPIOpts, reply *map[string]interface{}) (err error) {
|
||||
func (cS *CoreService) Status(arg *utils.TenantWithAPIOpts, reply *map[string]any) (err error) {
|
||||
memstats := new(runtime.MemStats)
|
||||
runtime.ReadMemStats(memstats)
|
||||
response := make(map[string]interface{})
|
||||
response := make(map[string]any)
|
||||
response[utils.NodeID] = cS.cfg.GeneralCfg().NodeID
|
||||
response[utils.MemoryUsage] = utils.SizeFmt(float64(memstats.HeapAlloc), "")
|
||||
response[utils.ActiveGoroutines] = runtime.NumGoroutine()
|
||||
|
||||
@@ -66,16 +66,16 @@ func TestCoreServiceStatus(t *testing.T) {
|
||||
cores := NewCoreService(cfgDflt, caps, nil, "/tmp", stopChan, nil, nil, nil)
|
||||
args := &utils.TenantWithAPIOpts{
|
||||
Tenant: "cgrates.org",
|
||||
APIOpts: map[string]interface{}{},
|
||||
APIOpts: map[string]any{},
|
||||
}
|
||||
|
||||
var reply map[string]interface{}
|
||||
var reply map[string]any
|
||||
cfgVrs, err := utils.GetCGRVersion()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
expected := map[string]interface{}{
|
||||
expected := map[string]any{
|
||||
utils.GoVersion: runtime.Version(),
|
||||
utils.RunningSince: "TIME_CHANGED",
|
||||
utils.VersionName: cfgVrs,
|
||||
|
||||
@@ -51,11 +51,11 @@ func (c *gobServerCodec) ReadRequestHeader(r *rpc.Request) error {
|
||||
return c.dec.Decode(r)
|
||||
}
|
||||
|
||||
func (c *gobServerCodec) ReadRequestBody(body interface{}) error {
|
||||
func (c *gobServerCodec) ReadRequestBody(body any) error {
|
||||
return c.dec.Decode(body)
|
||||
}
|
||||
|
||||
func (c *gobServerCodec) WriteResponse(r *rpc.Response, body interface{}) (err error) {
|
||||
func (c *gobServerCodec) WriteResponse(r *rpc.Response, body any) (err error) {
|
||||
if err = c.enc.Encode(r); err != nil {
|
||||
if c.encBuf.Flush() == nil {
|
||||
// Gob couldn't encode the header. Should not happen, so if it does,
|
||||
|
||||
@@ -67,7 +67,7 @@ func (s *Server) SetAnalyzer(anz *analyzers.AnalyzerService) {
|
||||
s.anz = anz
|
||||
}
|
||||
|
||||
func (s *Server) RpcRegister(rcvr interface{}) {
|
||||
func (s *Server) RpcRegister(rcvr any) {
|
||||
utils.RegisterRpcParams(utils.EmptyString, rcvr)
|
||||
rpc.Register(rcvr)
|
||||
s.Lock()
|
||||
@@ -75,7 +75,7 @@ func (s *Server) RpcRegister(rcvr interface{}) {
|
||||
s.Unlock()
|
||||
}
|
||||
|
||||
func (s *Server) RpcRegisterName(name string, rcvr interface{}) {
|
||||
func (s *Server) RpcRegisterName(name string, rcvr any) {
|
||||
utils.RegisterRpcParams(name, rcvr)
|
||||
rpc.RegisterName(name, rcvr)
|
||||
s.Lock()
|
||||
@@ -108,7 +108,7 @@ func (s *Server) RegisterHttpHandler(pattern string, handler http.Handler) {
|
||||
}
|
||||
|
||||
// Registers a new BiJsonRpc name
|
||||
func (s *Server) BiRPCRegisterName(method string, handlerFunc interface{}) {
|
||||
func (s *Server) BiRPCRegisterName(method string, handlerFunc any) {
|
||||
s.RLock()
|
||||
isNil := s.birpcSrv == nil
|
||||
s.RUnlock()
|
||||
|
||||
@@ -94,7 +94,7 @@ func TestServerIT(t *testing.T) {
|
||||
|
||||
type mockRegister string
|
||||
|
||||
func (x *mockRegister) ForTest(method *rpc2.Client, args *interface{}, reply *interface{}) error {
|
||||
func (x *mockRegister) ForTest(method *rpc2.Client, args *any, reply *any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -735,7 +735,7 @@ func testBiRPCRegisterName(t *testing.T) {
|
||||
caps := engine.NewCaps(0, utils.MetaBusy)
|
||||
server := NewServer(caps)
|
||||
|
||||
handler := func(method *rpc2.Client, args *interface{}, reply *interface{}) error {
|
||||
handler := func(method *rpc2.Client, args *any, reply *any) error {
|
||||
return nil
|
||||
}
|
||||
go server.BiRPCRegisterName(utils.APIerSv1Ping, handler)
|
||||
|
||||
Reference in New Issue
Block a user