MCPcopy
hub / github.com/TarsCloud/TarsGo / mainLoop

Method mainLoop

tars/application.go:582–623  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

580}
581
582func (a *application) mainLoop() {
583 ha := new(NodeFHelper)
584 comm := a.Communicator()
585 node := a.svrCfg.Node
586 app := a.svrCfg.App
587 server := a.svrCfg.Server
588 container := a.svrCfg.Container
589 ha.SetNodeInfo(comm, node, app, server, container)
590
591 svrCfg := a.ServerConfig()
592 go ha.ReportVersion(svrCfg.Version)
593 go ha.KeepAlive("") //first start
594 go a.handleSignal()
595 // registrar service
596 ctx := context.Background()
597 go a.registryAdapters(ctx)
598
599 loop := time.NewTicker(svrCfg.MainLoopTicker)
600 for {
601 select {
602 case <-a.shutdown:
603 ReportNotifyInfo(NotifyNormal, "stop")
604 return
605 case <-loop.C:
606 if atomic.LoadInt32(&a.isShutdowning) == 1 {
607 continue
608 }
609 for name, adapter := range a.svrCfg.Adapters {
610 if adapter.Protocol == "not_tars" {
611 // TODO not_tars support
612 ha.KeepAlive(name)
613 continue
614 }
615 if s, ok := a.goSvrs[adapter.Obj]; ok {
616 if !s.IsZombie(svrCfg.ZombieTimeout) {
617 ha.KeepAlive(name)
618 }
619 }
620 }
621 }
622 }
623}

Callers 1

RunMethod · 0.95

Calls 9

CommunicatorMethod · 0.95
ServerConfigMethod · 0.95
handleSignalMethod · 0.95
registryAdaptersMethod · 0.95
ReportNotifyInfoFunction · 0.85
SetNodeInfoMethod · 0.80
IsZombieMethod · 0.80
ReportVersionMethod · 0.65
KeepAliveMethod · 0.65

Tested by

no test coverage detected