-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaskGen.go
48 lines (46 loc) · 987 Bytes
/
taskGen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"github.com/Mrmaxmeier/strgen"
protos "github.com/Pixelgaffer/dico-proto"
log "github.com/Sirupsen/logrus"
)
func generateTasks(str string) {
g := &strgen.Generator{Source: str}
log.WithFields(log.Fields{
"amount": g.Amount,
"options": g.Source,
}).Info("will generate tasks")
if g.Err != nil {
log.Error(g.Err)
return
}
err := g.Configure()
if err != nil {
log.Error(err)
return
}
go g.Generate()
for g.Alive() {
str, err := g.Next()
if err != nil {
log.Error(err)
break
}
task := new(Task)
task.id = getNextTaskID()
task.options = str
log.WithField("task", task).Info("generated task")
task.reportStatus(protos.TaskStatus_REGISTERED)
taskChan <- task
accumulatedStats.With(func(s *AccumulatedStats) {
s.submittedTasks++
})
}
log.WithFields(log.Fields{
"options": g.Source,
"alive": g.Alive(),
"amount": g.Amount,
"left": g.Left,
"err": g.Err,
}).Info("generating tasks stopped")
}