This repository has been archived by the owner on Sep 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.go
71 lines (54 loc) · 1.48 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"time"
log "github.com/Sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"
"github.bus.zalan.do/teapot/mate/consumers"
"github.bus.zalan.do/teapot/mate/controller"
"github.bus.zalan.do/teapot/mate/producers"
)
const (
// TODO: to run synchronize form time to time
defaultInterval = 10 * time.Minute
// defaultDomain = "oolong.gcp.zalan.do"
)
var params struct {
producer string
consumer string
interval time.Duration
once bool
debug bool
}
var version = "Unknown"
func init() {
kingpin.Flag("producer", "The endpoints producer to use.").Required().StringVar(¶ms.producer)
kingpin.Flag("consumer", "The endpoints consumer to use.").Required().StringVar(¶ms.consumer)
kingpin.Flag("interval", "Interval in Duration format, e.g. 60s.").Short('i').Default(defaultInterval.String()).DurationVar(¶ms.interval)
kingpin.Flag("once", "Run once and exit").BoolVar(¶ms.once)
kingpin.Flag("debug", "Enable debug logging.").BoolVar(¶ms.debug)
}
func main() {
kingpin.Version(version)
kingpin.Parse()
if params.debug {
log.SetLevel(log.DebugLevel)
}
p, err := producers.New(params.producer)
if err != nil {
log.Fatalf("Error creating producer: %v", err)
}
c, err := consumers.New(params.consumer)
if err != nil {
log.Fatalf("Error creating consumer: %v", err)
}
ctrl := controller.New(p, c)
err = ctrl.Synchronize()
if err != nil {
log.Fatalln(err)
}
err = ctrl.Watch()
if err != nil {
log.Fatalln(err)
}
ctrl.Wait()
}