dependency/health_service.go
func NewHealthServiceQuery(s string) (*HealthServiceQuery, error) {
	if !HealthServiceQueryRe.MatchString(s) {
		return nil, fmt.Errorf("health.service: invalid format: %q", s)
	}

	m := regexpMatch(HealthServiceQueryRe, s)

	var filters []string
	if filter := m["filter"]; filter != "" {
		split := strings.Split(filter, ",")
		for _, f := range split {
			f = strings.TrimSpace(f)
			switch f {
			case HealthAny,
				HealthPassing,
				HealthWarning,
				HealthCritical,
				HealthMaint:
				filters = append(filters, f)
			case "":
			default:
				return nil, fmt.Errorf("health.service: invalid filter: %q in %q", f, s)
			}
		}
		sort.Strings(filters)
	} else {
		filters = []string{HealthPassing}
	}

	return &HealthServiceQuery{
		stopCh:  make(chan struct{}, 1),
		dc:      m["dc"],
		filters: filters,
		name:    m["name"],
		near:    m["near"],
		tag:     m["tag"],
	}, nil
}
func NewHealthServiceQuery(s string) (*HealthServiceQuery, error) {
	if !HealthServiceQueryRe.MatchString(s) {
		return nil, fmt.Errorf("health.service: invalid format: %q", s)
	}

	m := regexpMatch(HealthServiceQueryRe, s)

	var filters []string
	if filter := m["filter"]; filter != "" {
		split := strings.Split(filter, ",")
		for _, f := range split {
			f = strings.TrimSpace(f)
			switch f {
			case HealthAny,
				HealthPassing,
				HealthWarning,
				HealthCritical,
				HealthMaint:
				filters = append(filters, f)
			case "":
			default:
				return nil, fmt.Errorf("health.service: invalid filter: %q in %q", f, s)
			}
		}
		sort.Strings(filters)
	} else {
		filters = []string{HealthPassing}
	}

	return &HealthServiceQuery{
		stopCh:  make(chan struct{}, 1),
		dc:      m["dc"],
		filters: filters,
		name:    m["name"],
		near:    m["near"],
		tag:     m["tag"],
	}, nil
}
func NewHealthServiceQuery ( s string ) ( * HealthServiceQuery , error ) { if ! HealthServiceQueryRe . MatchString ( s ) { return nil , fmt . Errorf ( " " , s ) } m := regexpMatch ( HealthServiceQueryRe , s ) var filters [ ] string if filter := m [ " " ] ; filter != " " { split := strings . Split ( filter , " " ) for _ , f := range split { f = strings . TrimSpace ( f ) switch f { case HealthAny , HealthPassing , HealthWarning , HealthCritical , HealthMaint : filters = append ( filters , f ) case " " : default : return nil , fmt . Errorf ( " " , f , s ) } } sort . Strings ( filters ) } else { filters = [ ] string { HealthPassing } } return & HealthServiceQuery { stopCh : make ( chan struct { } , 1 ) , dc : m [ " " ] , filters : filters , name : m [ " " ] , near : m [ " " ] , tag : m [ " " ] , } , nil }
// NewHealthServiceQuery processes the strings to build a service dependency.
NewHealthServiceQuery processes the strings to build a service dependency .