chore: replace interface{} with any

This commit is contained in:
ionutboangiu
2024-08-29 09:49:32 +03:00
committed by Dan Christian Bogos
parent 66b334f6fb
commit fee2712a23
9 changed files with 62 additions and 62 deletions

View File

@@ -48,7 +48,7 @@ func newJanusHTTPjsonDP(req *http.Request) (utils.DataProvider, error) {
// decoded data is only searched once and cached
type janusHTTPjsonDP struct {
req *http.Request
reqBody map[string]interface{} // unmarshal JSON body here
reqBody map[string]any // unmarshal JSON body here
cache utils.MapStorage
}

View File

@@ -477,8 +477,8 @@ func TestPopulateCostForRoutesAccountCostOverMax(t *testing.T) {
cc := make(chan birpc.ClientConnector, 1)
cc <- &ccMock{
calls: map[string]func(ctx *context.Context, args interface{}, reply interface{}) error{
utils.AccountSv1MaxAbstracts: func(ctx *context.Context, args, reply interface{}) error {
calls: map[string]func(ctx *context.Context, args any, reply any) error{
utils.AccountSv1MaxAbstracts: func(ctx *context.Context, args, reply any) error {
rplCast, canCast := reply.(*utils.EventCharges)
if !canCast {
t.Errorf("Wrong argument type : %T", reply)
@@ -505,10 +505,10 @@ func TestPopulateCostForRoutesAccountCostOverMax(t *testing.T) {
ev := &utils.CGREvent{
Tenant: "cgrates.org",
ID: "TestEvent",
Event: map[string]interface{}{
Event: map[string]any{
utils.AccountField: 1001,
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]any{},
}
extraOpts := &optsGetRoutes{
maxCost: 1,
@@ -561,8 +561,8 @@ func TestPopulateCostForRoutesAppendAccounts(t *testing.T) {
cc := make(chan birpc.ClientConnector, 1)
cc <- &ccMock{
calls: map[string]func(ctx *context.Context, args interface{}, reply interface{}) error{
utils.AccountSv1MaxAbstracts: func(ctx *context.Context, args, reply interface{}) error {
calls: map[string]func(ctx *context.Context, args any, reply any) error{
utils.AccountSv1MaxAbstracts: func(ctx *context.Context, args, reply any) error {
rplCast, canCast := reply.(*utils.EventCharges)
if !canCast {
t.Errorf("Wrong argument type : %T", reply)
@@ -589,10 +589,10 @@ func TestPopulateCostForRoutesAppendAccounts(t *testing.T) {
ev := &utils.CGREvent{
Tenant: "cgrates.org",
ID: "TestEvent",
Event: map[string]interface{}{
Event: map[string]any{
utils.AccountField: 1001,
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]any{},
}
extraOpts := &optsGetRoutes{}
@@ -600,7 +600,7 @@ func TestPopulateCostForRoutesAppendAccounts(t *testing.T) {
{
RouteID: "local",
RouteParameters: "",
SortingData: map[string]interface{}{
SortingData: map[string]any{
utils.AccountIDs: []string{"accID1"},
utils.Cost: 5,
utils.Weight: 10,
@@ -629,8 +629,8 @@ func TestPopulateCostForRoutesRateSIgnoreErr(t *testing.T) {
cc := make(chan birpc.ClientConnector, 1)
cc <- &ccMock{
calls: map[string]func(ctx *context.Context, args interface{}, reply interface{}) error{
utils.RateSv1CostForEvent: func(ctx *context.Context, args, reply interface{}) error {
calls: map[string]func(ctx *context.Context, args any, reply any) error{
utils.RateSv1CostForEvent: func(ctx *context.Context, args, reply any) error {
return utils.ErrNotImplemented
},
},
@@ -651,10 +651,10 @@ func TestPopulateCostForRoutesRateSIgnoreErr(t *testing.T) {
ev := &utils.CGREvent{
Tenant: "cgrates.org",
ID: "TestEvent",
Event: map[string]interface{}{
Event: map[string]any{
utils.AccountField: 1001,
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]any{},
}
extraOpts := &optsGetRoutes{
ignoreErrors: true,

View File

@@ -56,8 +56,8 @@ func TestPopulatStatsForQOSRouteOK(t *testing.T) {
cc := make(chan birpc.ClientConnector, 1)
cc <- &ccMock{
calls: map[string]func(ctx *context.Context, args interface{}, reply interface{}) error{
utils.StatSv1GetQueueDecimalMetrics: func(ctx *context.Context, args, reply interface{}) error {
calls: map[string]func(ctx *context.Context, args any, reply any) error{
utils.StatSv1GetQueueDecimalMetrics: func(ctx *context.Context, args, reply any) error {
rplCast, canCast := reply.(*map[string]*utils.Decimal)
if !canCast {
t.Errorf("Wrong argument type : %T", reply)
@@ -96,8 +96,8 @@ func TestQOSRouteSorterRoutesNoStatSConns(t *testing.T) {
cgrEv := &utils.CGREvent{
Tenant: "cgrates.org",
ID: "EV",
Event: map[string]interface{}{},
APIOpts: map[string]interface{}{},
Event: map[string]any{},
APIOpts: map[string]any{},
}
extraOpts := &optsGetRoutes{}
@@ -124,8 +124,8 @@ func TestQOSRouteSorterRoutesOK(t *testing.T) {
cc := make(chan birpc.ClientConnector, 1)
cc <- &ccMock{
calls: map[string]func(ctx *context.Context, args interface{}, reply interface{}) error{
utils.StatSv1GetQueueDecimalMetrics: func(ctx *context.Context, args, reply interface{}) error {
calls: map[string]func(ctx *context.Context, args any, reply any) error{
utils.StatSv1GetQueueDecimalMetrics: func(ctx *context.Context, args, reply any) error {
rplCast, canCast := reply.(*map[string]*utils.Decimal)
if !canCast {
t.Errorf("Wrong argument type : %T", reply)
@@ -156,8 +156,8 @@ func TestQOSRouteSorterRoutesOK(t *testing.T) {
cgrEv := &utils.CGREvent{
Tenant: "cgrates.org",
ID: "EV",
Event: map[string]interface{}{},
APIOpts: map[string]interface{}{},
Event: map[string]any{},
APIOpts: map[string]any{},
}
extraOpts := &optsGetRoutes{
@@ -170,7 +170,7 @@ func TestQOSRouteSorterRoutesOK(t *testing.T) {
Routes: []*SortedRoute{{
RouteID: "local",
RouteParameters: "",
SortingData: map[string]interface{}{
SortingData: map[string]any{
utils.MetaPDD: 1.7976931348623157e+308,
utils.Blocker: true,
utils.MetaTCD: 5,
@@ -204,8 +204,8 @@ func TestQOSRouteSorterRoutesLazyPassErr(t *testing.T) {
cc := make(chan birpc.ClientConnector, 1)
cc <- &ccMock{
calls: map[string]func(ctx *context.Context, args interface{}, reply interface{}) error{
utils.StatSv1GetQueueDecimalMetrics: func(ctx *context.Context, args, reply interface{}) error {
calls: map[string]func(ctx *context.Context, args any, reply any) error{
utils.StatSv1GetQueueDecimalMetrics: func(ctx *context.Context, args, reply any) error {
rplCast, canCast := reply.(*map[string]*utils.Decimal)
if !canCast {
t.Errorf("Wrong argument type : %T", reply)
@@ -242,8 +242,8 @@ func TestQOSRouteSorterRoutesLazyPassErr(t *testing.T) {
cgrEv := &utils.CGREvent{
Tenant: "cgrates.org",
ID: "EV",
Event: map[string]interface{}{},
APIOpts: map[string]interface{}{},
Event: map[string]any{},
APIOpts: map[string]any{},
}
extraOpts := &optsGetRoutes{}
@@ -266,8 +266,8 @@ func TestQOSRouteSorterRoutesIgnoreErr(t *testing.T) {
cc := make(chan birpc.ClientConnector, 1)
cc <- &ccMock{
calls: map[string]func(ctx *context.Context, args interface{}, reply interface{}) error{
utils.StatSv1GetQueueDecimalMetrics: func(ctx *context.Context, args, reply interface{}) error {
calls: map[string]func(ctx *context.Context, args any, reply any) error{
utils.StatSv1GetQueueDecimalMetrics: func(ctx *context.Context, args, reply any) error {
return utils.ErrNotImplemented
},
},
@@ -291,8 +291,8 @@ func TestQOSRouteSorterRoutesIgnoreErr(t *testing.T) {
cgrEv := &utils.CGREvent{
Tenant: "cgrates.org",
ID: "EV",
Event: map[string]interface{}{},
APIOpts: map[string]interface{}{},
Event: map[string]any{},
APIOpts: map[string]any{},
}
extraOpts := &optsGetRoutes{
@@ -324,8 +324,8 @@ func TestQOSRouteSorterRoutesPopulateErr(t *testing.T) {
cc := make(chan birpc.ClientConnector, 1)
cc <- &ccMock{
calls: map[string]func(ctx *context.Context, args interface{}, reply interface{}) error{
utils.StatSv1GetQueueDecimalMetrics: func(ctx *context.Context, args, reply interface{}) error {
calls: map[string]func(ctx *context.Context, args any, reply any) error{
utils.StatSv1GetQueueDecimalMetrics: func(ctx *context.Context, args, reply any) error {
return utils.ErrNotImplemented
},
},
@@ -349,8 +349,8 @@ func TestQOSRouteSorterRoutesPopulateErr(t *testing.T) {
cgrEv := &utils.CGREvent{
Tenant: "cgrates.org",
ID: "EV",
Event: map[string]interface{}{},
APIOpts: map[string]interface{}{},
Event: map[string]any{},
APIOpts: map[string]any{},
}
extraOpts := &optsGetRoutes{}

View File

@@ -35,8 +35,8 @@ func TestPopulateResourcesForRoutesNoResourceSConns(t *testing.T) {
routes := map[string]*RouteWithWeight{}
ev := &utils.CGREvent{
Tenant: "cgrates.org",
Event: map[string]interface{}{},
APIOpts: map[string]interface{}{},
Event: map[string]any{},
APIOpts: map[string]any{},
}
extraOpts := &optsGetRoutes{}
@@ -58,8 +58,8 @@ func TestPopulateResourcesForRoutesNoResourceIDs(t *testing.T) {
}
ev := &utils.CGREvent{
Tenant: "cgrates.org",
Event: map[string]interface{}{},
APIOpts: map[string]interface{}{},
Event: map[string]any{},
APIOpts: map[string]any{},
}
extraOpts := &optsGetRoutes{}
@@ -88,8 +88,8 @@ func TestPopulateResourcesForRoutesOK(t *testing.T) {
cc := make(chan birpc.ClientConnector, 1)
cc <- &ccMock{
calls: map[string]func(ctx *context.Context, args interface{}, reply interface{}) error{
utils.ResourceSv1GetResource: func(ctx *context.Context, args, reply interface{}) error {
calls: map[string]func(ctx *context.Context, args any, reply any) error{
utils.ResourceSv1GetResource: func(ctx *context.Context, args, reply any) error {
rplCast, canCast := reply.(*Resource)
if !canCast {
t.Errorf("Wrong argument type : %T", reply)
@@ -116,8 +116,8 @@ func TestPopulateResourcesForRoutesOK(t *testing.T) {
}
ev := &utils.CGREvent{
Tenant: "cgrates.org",
Event: map[string]interface{}{},
APIOpts: map[string]interface{}{},
Event: map[string]any{},
APIOpts: map[string]any{},
}
extraOpts := &optsGetRoutes{}
@@ -125,7 +125,7 @@ func TestPopulateResourcesForRoutesOK(t *testing.T) {
{
RouteID: "Route1",
RouteParameters: "param1",
SortingData: map[string]interface{}{
SortingData: map[string]any{
utils.Blocker: true,
utils.ResourceUsage: 0,
utils.Weight: 10,
@@ -156,8 +156,8 @@ func TestPopulateResourcesForRoutesCallErr(t *testing.T) {
cc := make(chan birpc.ClientConnector, 1)
cc <- &ccMock{
calls: map[string]func(ctx *context.Context, args interface{}, reply interface{}) error{
utils.ResourceSv1GetResource: func(ctx *context.Context, args, reply interface{}) error {
calls: map[string]func(ctx *context.Context, args any, reply any) error{
utils.ResourceSv1GetResource: func(ctx *context.Context, args, reply any) error {
return utils.ErrNotImplemented
},
},
@@ -178,8 +178,8 @@ func TestPopulateResourcesForRoutesCallErr(t *testing.T) {
}
ev := &utils.CGREvent{
Tenant: "cgrates.org",
Event: map[string]interface{}{},
APIOpts: map[string]interface{}{},
Event: map[string]any{},
APIOpts: map[string]any{},
}
extraOpts := &optsGetRoutes{}
@@ -187,7 +187,7 @@ func TestPopulateResourcesForRoutesCallErr(t *testing.T) {
{
RouteID: "Route1",
RouteParameters: "param1",
SortingData: map[string]interface{}{
SortingData: map[string]any{
utils.Blocker: true,
utils.ResourceUsage: 0,
utils.Weight: 10,
@@ -225,8 +225,8 @@ func TestPopulateResourcesForRoutesLazyPassErr(t *testing.T) {
cc := make(chan birpc.ClientConnector, 1)
cc <- &ccMock{
calls: map[string]func(ctx *context.Context, args interface{}, reply interface{}) error{
utils.ResourceSv1GetResource: func(ctx *context.Context, args, reply interface{}) error {
calls: map[string]func(ctx *context.Context, args any, reply any) error{
utils.ResourceSv1GetResource: func(ctx *context.Context, args, reply any) error {
rplCast, canCast := reply.(*Resource)
if !canCast {
t.Errorf("Wrong argument type : %T", reply)
@@ -260,8 +260,8 @@ func TestPopulateResourcesForRoutesLazyPassErr(t *testing.T) {
}
ev := &utils.CGREvent{
Tenant: "cgrates.org",
Event: map[string]interface{}{},
APIOpts: map[string]interface{}{},
Event: map[string]any{},
APIOpts: map[string]any{},
}
extraOpts := &optsGetRoutes{}

View File

@@ -115,7 +115,7 @@ type DataDBDriver interface {
type StorDB interface {
Storage
SetCDR(*context.Context, *utils.CGREvent, bool) error
GetCDRs(*context.Context, []*Filter, map[string]interface{}) ([]*utils.CDR, error)
GetCDRs(*context.Context, []*Filter, map[string]any) ([]*utils.CDR, error)
RemoveCDRs(*context.Context, []*Filter) error
}

View File

@@ -67,7 +67,7 @@ func (iDB *InternalDB) SetCDR(_ *context.Context, cdr *utils.CGREvent, allowUpda
return nil
}
func (iDB *InternalDB) GetCDRs(ctx *context.Context, qryFltr []*Filter, opts map[string]interface{}) (cdrs []*utils.CDR, err error) {
func (iDB *InternalDB) GetCDRs(ctx *context.Context, qryFltr []*Filter, opts map[string]any) (cdrs []*utils.CDR, err error) {
pairFltrs := make(map[string][]string)
notPairFltrs := make(map[string][]string)
notIndexed := []*FilterRule{}

View File

@@ -170,7 +170,7 @@ func isMongoDuplicateError(err error) bool {
return false
}
func (ms *MongoStorage) GetCDRs(ctx *context.Context, qryFltr []*Filter, opts map[string]interface{}) (cdrs []*utils.CDR, err error) {
func (ms *MongoStorage) GetCDRs(ctx *context.Context, qryFltr []*Filter, opts map[string]any) (cdrs []*utils.CDR, err error) {
fltrs := make(bson.M)
for _, fltr := range qryFltr {
for _, rule := range fltr.Rules {

View File

@@ -181,7 +181,7 @@ func (sqls *SQLStorage) SetCDR(_ *context.Context, cdr *utils.CGREvent, allowUpd
// GetCDRs has ability to get the filtered CDRs, count them or simply return them
// qryFltr.Unscoped will ignore soft deletes or delete records permanently
func (sqls *SQLStorage) GetCDRs(ctx *context.Context, qryFltr []*Filter, opts map[string]interface{}) (cdrs []*utils.CDR, err error) {
func (sqls *SQLStorage) GetCDRs(ctx *context.Context, qryFltr []*Filter, opts map[string]any) (cdrs []*utils.CDR, err error) {
q := sqls.db.Table(utils.CDRsTBL)
var excludedCdrQueryFilterTypes []*FilterRule
for _, fltr := range qryFltr {

View File

@@ -28,8 +28,8 @@ import (
type CDR struct {
Tenant string
Opts map[string]interface{}
Event map[string]interface{}
Opts map[string]any
Event map[string]any
CreatedAt time.Time `json:",omitempty"`
UpdatedAt time.Time `json:",omitempty"`
DeletedAt *time.Time `json:",omitempty"`
@@ -50,14 +50,14 @@ func (CDRSQLTable) TableName() string {
}
// JSONB type for storing maps of events and opts into gorm columns as jsob type
type JSONB map[string]interface{}
type JSONB map[string]any
func (j JSONB) GormDataType() string {
return "JSONB"
}
// Scan scan value into Jsonb, implements sql.Scanner interface
func (j *JSONB) Scan(value interface{}) (err error) {
func (j *JSONB) Scan(value any) (err error) {
switch v := value.(type) {
case []byte:
return json.Unmarshal(v, &j)
@@ -105,5 +105,5 @@ type CDRFilters struct {
Tenant string
ID string
FilterIDs []string
APIOpts map[string]interface{}
APIOpts map[string]any
}