func()

in plugins/client/grpc/client_sniffer.go [33:52]


func (c *Client) snifferChannelStatus() {
	ctx, cancel := context.WithCancel(c.ctx)
	defer cancel()
	timeTicker := time.NewTicker(time.Duration(c.CheckPeriod) * time.Second)
	for {
		select {
		case <-timeTicker.C:
			state := c.client.GetState()
			log.Logger.Debugf("current grpc client state: %s", state)
			if state == connectivity.Shutdown || state == connectivity.TransientFailure {
				c.updateStatus(api.Disconnect)
			} else if state == connectivity.Ready || state == connectivity.Idle {
				c.updateStatus(api.Connected)
			}
		case <-ctx.Done():
			timeTicker.Stop()
			return
		}
	}
}