Skip to content

Commit

Permalink
chore: make routine loop simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
robcxyz committed Mar 20, 2023
1 parent f89eea6 commit d88ad93
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/routines/routines.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func RoutinesCron(routines []func(), sleepDuration time.Duration) {
}
}


func LoopRoutine[M any, O any](Crud *crud.Crud[M, O], routines []func(*M)) {
i := 1
skip := i * config.Config.RoutinesBatchSize
Expand All @@ -105,9 +104,8 @@ func LoopRoutine[M any, O any](Crud *crud.Crud[M, O], routines []func(*M)) {

zap.S().Info("Starting skip=", skip, " limit=", limit, " table=", Crud.TableName, " workerId=", i)
for i := 0; i < len(*routineItems); i++ {
var item *M
item = &(*routineItems)[i]
for _, r := range routines {
item := &(*routineItems)[i]
r(item)
}
}
Expand All @@ -117,7 +115,6 @@ func LoopRoutine[M any, O any](Crud *crud.Crud[M, O], routines []func(*M)) {
}
}


//func LoopRoutine[M any, O any](Crud *crud.Crud[M, O], routines []func(*M)) {
// var wg sync.WaitGroup
// wg.Add(config.Config.RoutinesNumWorkers)
Expand Down Expand Up @@ -162,4 +159,4 @@ func LoopRoutine[M any, O any](Crud *crud.Crud[M, O], routines []func(*M)) {
// }()
// }
// wg.Wait()
//}
//}

0 comments on commit d88ad93

Please sign in to comment.