func()

in internal/daemon/sqlserver/sqlserver.go [131:158]


func (s *Service) checkServiceCommunication(ctx context.Context) {
	// Effectively give ctx.Done() priority over the channel.
	if ctx.Err() != nil {
		return
	}

	select {
	case <-ctx.Done():
		return
	case msg := <-s.CommonCh:
		log.CtxLogger(ctx).Debugw("SQL Server workload agent service received a message on the common channel", "message", msg)
		switch msg.Origin {
		case servicecommunication.Discovery:
			log.CtxLogger(ctx).Debugw("SQL Server workload agent service received a discovery message")
			for _, p := range msg.DiscoveryResult.Processes {
				name, err := p.Name()
				if err == nil && strings.Contains(name, sqlserverProcessSubstring) {
					s.isProcessPresent = true
					break
				}
			}
		case servicecommunication.DWActivation:
			log.CtxLogger(ctx).Debugw("SQL Server workload agent service received a DW activation message")
		default:
			log.CtxLogger(ctx).Debugw("SQL Server workload agent service received a message with an unexpected origin", "origin", msg.Origin)
		}
	}
}