mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated task execution
This commit is contained in:
committed by
Dan Christian Bogos
parent
ffaac358d5
commit
5830d9fcf0
@@ -289,7 +289,6 @@ func testCGRConfigReloadSupplierS(t *testing.T) {
|
||||
AttributeSConns: []string{},
|
||||
RateSConns: []string{},
|
||||
RALsConns: []string{},
|
||||
RateSConns: []string{},
|
||||
IndexedSelects: true,
|
||||
DefaultRatio: 1,
|
||||
}
|
||||
|
||||
@@ -246,6 +246,9 @@ func (at *ActionTiming) Execute(successActions, failedActions chan *Action) (err
|
||||
utils.Logger.Err(fmt.Sprintf("Function type %v not available, aborting execution!", a.ActionType))
|
||||
partialyExecuted = true
|
||||
transactionFailed = true
|
||||
if failedActions != nil {
|
||||
go func(a *Action) { failedActions <- a }(a)
|
||||
}
|
||||
break
|
||||
}
|
||||
if err := actionFunction(acc, a, aac, at.ExtraData); err != nil {
|
||||
@@ -253,12 +256,12 @@ func (at *ActionTiming) Execute(successActions, failedActions chan *Action) (err
|
||||
partialyExecuted = true
|
||||
transactionFailed = true
|
||||
if failedActions != nil {
|
||||
go func() { failedActions <- a }()
|
||||
go func(a *Action) { failedActions <- a }(a)
|
||||
}
|
||||
break
|
||||
}
|
||||
if successActions != nil {
|
||||
go func() { successActions <- a }()
|
||||
go func(a *Action) { successActions <- a }(a)
|
||||
}
|
||||
if a.ActionType == utils.REMOVE_ACCOUNT {
|
||||
removeAccountActionFound = true
|
||||
@@ -288,7 +291,7 @@ func (at *ActionTiming) Execute(successActions, failedActions chan *Action) (err
|
||||
utils.Logger.Err(fmt.Sprintf("Function type %v not available, aborting execution!", a.ActionType))
|
||||
partialyExecuted = true
|
||||
if failedActions != nil {
|
||||
go func() { failedActions <- a }()
|
||||
go func(a *Action) { failedActions <- a }(a)
|
||||
}
|
||||
break
|
||||
}
|
||||
@@ -296,12 +299,12 @@ func (at *ActionTiming) Execute(successActions, failedActions chan *Action) (err
|
||||
utils.Logger.Err(fmt.Sprintf("Error executing accountless action %s: %v!", a.ActionType, err))
|
||||
partialyExecuted = true
|
||||
if failedActions != nil {
|
||||
go func() { failedActions <- a }()
|
||||
go func(a *Action) { failedActions <- a }(a)
|
||||
}
|
||||
break
|
||||
}
|
||||
if successActions != nil {
|
||||
go func() { successActions <- a }()
|
||||
go func(a *Action) { successActions <- a }(a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,11 +33,14 @@ type Task struct {
|
||||
}
|
||||
|
||||
func (t *Task) Execute() error {
|
||||
return (&ActionTiming{
|
||||
Uuid: t.Uuid,
|
||||
ActionsID: t.ActionsID,
|
||||
accountIDs: utils.StringMap{t.AccountID: true},
|
||||
}).Execute(nil, nil)
|
||||
at := &ActionTiming{
|
||||
Uuid: t.Uuid,
|
||||
ActionsID: t.ActionsID,
|
||||
}
|
||||
if len(t.AccountID) != 0 {
|
||||
at.accountIDs = utils.StringMap{t.AccountID: true}
|
||||
}
|
||||
return at.Execute(nil, nil)
|
||||
}
|
||||
|
||||
// String implements utils.DataProvider
|
||||
@@ -51,7 +54,7 @@ func (t *Task) FieldAsInterface(fldPath []string) (iface interface{}, err error)
|
||||
return t.FieldAsString(fldPath)
|
||||
}
|
||||
|
||||
// FieldAsInterface implements utils.DataProvider
|
||||
// FieldAsString implements utils.DataProvider
|
||||
// ToDo: support Action fields
|
||||
func (t *Task) FieldAsString(fldPath []string) (s string, err error) {
|
||||
if len(fldPath) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user