MCPcopy Create free account
hub / github.com/TalkingData/owl / InitController

Function InitController

controller/controller.go:26–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24}
25
26func InitController() error {
27 protocol := &tcp.DefaultProtocol{}
28 protocol.SetMaxPacketSize(uint32(GlobalConfig.MAX_PACKET_SIZE))
29 server := tcp.NewAsyncTCPServer(GlobalConfig.TCP_BIND, &callback{}, protocol)
30 if err := server.ListenAndServe(); err != nil {
31 return err
32 }
33 lg.Info("Start listen: %v", GlobalConfig.TCP_BIND)
34
35 controller = &Controller{server,
36 NewTaskPool(GlobalConfig.TASK_POOL_SIZE),
37 NewResultPool(GlobalConfig.RESULT_POOL_SIZE),
38 NewNodePool(),
39 make(map[int]*EventPool),
40 new(sync.RWMutex),
41 cache.New(time.Duration(GlobalConfig.LOAD_STRATEGIES_INTERVAL)*time.Second, 30*time.Second),
42 cache.New(10*time.Minute, 10*time.Minute)}
43
44 go controller.processStrategyResultForever()
45 go controller.processStrategyEventForever()
46 go controller.checkNodesForever()
47 go controller.startHttpServer()
48 go controller.loadStrategiesForever()
49
50 return nil
51}
52
53//checkNodesForever 持续运行检查节点函数,并维护节点数组
54func (c *Controller) checkNodesForever() {

Callers 1

mainFunction · 0.85

Calls 10

NewNodePoolFunction · 0.85
SetMaxPacketSizeMethod · 0.80
ListenAndServeMethod · 0.80
checkNodesForeverMethod · 0.80
startHttpServerMethod · 0.80
loadStrategiesForeverMethod · 0.80
NewTaskPoolFunction · 0.70
NewResultPoolFunction · 0.70

Tested by

no test coverage detected