-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (32 loc) · 905 Bytes
/
main.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
package main
import (
"context"
"log"
"mongo_transporter/core"
"sync"
"time"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
config, err := core.DecodeConfig(core.DecodeFlag())
if err != nil {
log.Fatal(err)
}
var wgOnStart sync.WaitGroup
for _, transferCollection := range config.TransferCollections {
collectionMap := config.GetCollectionMap(transferCollection)
wgOnStart.Add(1)
go core.Start(ctx, transferCollection, collectionMap, &config, &wgOnStart)
}
wgOnStart.Wait()
ctx, cancel = context.WithCancel(context.Background())
defer cancel()
var wgOnWatch sync.WaitGroup
for _, watchCollection := range config.WatchCollections {
collectionMap := config.GetCollectionMap(watchCollection)
wgOnWatch.Add(1)
go core.Watch(ctx, watchCollection, collectionMap, &config, &wgOnWatch)
}
wgOnWatch.Wait()
}