-
Notifications
You must be signed in to change notification settings - Fork 4
/
stage_five.go
56 lines (46 loc) · 1.15 KB
/
stage_five.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
49
50
51
52
53
54
55
56
package main
import (
"github.com/spf13/viper"
"github.com/teamnsrg/mida/amqp"
t "github.com/teamnsrg/mida/base"
"github.com/teamnsrg/mida/log"
"github.com/teamnsrg/mida/storage"
"sync"
"time"
)
func stage5(finalResultChan <-chan *t.FinalResult, monitoringChan chan<- *t.TaskSummary,
storageWG *sync.WaitGroup, pipelineWG *sync.WaitGroup) {
for fr := range finalResultChan {
fr.Summary.TaskTiming.BeginStorage = time.Now()
err := storage.StoreAll(fr)
if err != nil {
log.Log.Error(err)
}
fr.Summary.TaskTiming.EndStorage = time.Now()
if *fr.Summary.TaskWrapper.SanitizedTask.OPS.PostQueue != "" {
var params = amqp.ConnParams{
User: viper.GetString("amqp_user"),
Pass: viper.GetString("amqp_pass"),
Uri: viper.GetString("amqp_uri"),
}
err = amqp.LoadSummaryPost(
fr.Summary,
params,
*fr.Summary.TaskWrapper.SanitizedTask.OPS.PostQueue,
amqp.DefaultPriority,
)
if err != nil {
log.Log.Error(err)
}
}
if viper.GetBool("monitor") {
monitoringChan <- &(fr.Summary)
}
err = storage.CleanupTask(fr)
if err != nil {
log.Log.Error(err)
}
pipelineWG.Done()
}
storageWG.Done()
}