MCPcopy Create free account
hub / github.com/AdRoll/baker / Main

Function Main

baker.go:27–59  ·  view source on GitHub ↗

Main runs the topology corresponding to the provided configuration. Depending on the input, it either blocks forever (daemon) or terminates when all the records have been processed (batch).

(cfg *Config)

Source from the content-addressed store, hash-verified

25// Depending on the input, it either blocks forever (daemon) or terminates when
26// all the records have been processed (batch).
27func Main(cfg *Config) error {
28 topology, err := NewTopologyFromConfig(cfg)
29 if err != nil {
30 return fmt.Errorf("can't create topology: %s", err)
31 }
32
33 // Start the topology
34 topology.Start()
35
36 // Now setup the wait condition for exiting the process in case the topology
37 // ends by itself.
38 topdone := make(chan bool)
39 go func() {
40 topology.Wait()
41 topdone <- true
42 }()
43
44 // Begin dump statistics
45 stats := NewStatsDumper(topology)
46 stopStats := stats.Run()
47
48 // Block until topology termination.
49 <-topdone
50
51 // Stop the stats dumping goroutine (this also prints stats one last time).
52 stopStats()
53
54 if err := topology.Metrics.Close(); err != nil {
55 logrus.WithError(err).Warnf("error closing metrics client")
56 }
57
58 return topology.Error()
59}

Callers 6

mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
MainCLIFunction · 0.85

Calls 7

RunMethod · 0.95
NewTopologyFromConfigFunction · 0.85
NewStatsDumperFunction · 0.85
CloseMethod · 0.65
StartMethod · 0.45
WaitMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected