err = eh.chClient.Init() if err != nil { klog.Errorf("connection failed: %v, will reconnect after %s", err, waitTime.String()) time.Sleep(waitTime) continue } // execute hook func after connect eh.pubConnectInfo(true) go eh.routeToEdge() go eh.routeToCloud() go eh.keepalive()
// wait the stop signal // stop authinfo manager/websocket connection <-eh.reconnectChan eh.chClient.UnInit()
// execute hook fun after disconnect eh.pubConnectInfo(false)
// sleep one period of heartbeat, then try to connect cloud hub again klog.Warningf("connection is broken, will reconnect after %s", waitTime.String()) time.Sleep(waitTime)
// clean channel clean: for { select { case <-eh.reconnectChan: default: break clean } } } }