func (s *PetSchool) UpByKey(key service.Key) (proc.PetsProc, error) {
	services, err := s.healthyServices()
	if err != nil {
		return proc.PetsProc{}, err
	}
	return s.up(key, services)
}
Bring up the service with the given key, including all its dependencies.
package school
import (
	"fmt"
	"github.com/windmilleng/pets/internal/proc"
	"github.com/windmilleng/pets/internal/service"
)
type Provider func([]proc.PetsProc) (proc.PetsProc, error)
type ProviderSpec struct {
	inputNames []service.Name
	provider   Provider
	position string
}
type PetSchool struct {
	procfs proc.ProcFS
	providers map[service.Key]ProviderSpec
	overrides map[service.Name]service.Tier
}
func NewPetSchool(procfs proc.ProcFS) *PetSchool {
	return &PetSchool{
		procfs:    procfs,
		providers: make(map[service.Key]ProviderSpec),
		overrides: make(map[service.Name]service.Tier),
	}
}
func (s *PetSchool) AddOverride(name service.Name, tier service.Tier) error {
	key := service.NewKey(name, tier)
	_, hasProvider := s.providers[key]
	if !hasProvider {
		return fmt.Errorf("Could not find provider for service %q, tier %q", name, tier)
	}
	s.overrides[name] = tier
	return nil
}
func (s *PetSchool) AddProvider(key service.Key, provider Provider, deps []service.Name, position string) error {
	existing, exists := s.providers[key]
	if exists {
		return fmt.Errorf("Duplicate provider for service %q, tier %q\nFirst:  %s\nSecond: %s",
			key.Name, key.Tier, existing.position, position)
	}
	spec := ProviderSpec{
		inputNames: deps,
		provider:   provider,
		position:   position,
	}
	s.providers[key] = spec
	return nil
}
func (s *PetSchool) healthyServices() (map[service.Key]proc.PetsProc, error) {
	result := make(map[service.Key]proc.PetsProc)
	procs, err := s.procfs.ProcsFromFS()
	if err != nil {
		return nil, fmt.Errorf("school#healthServices: %v", err)
	}
	for _, p := range procs {
		isHealthyServiceProc := p.ServiceName != "" && p.ServiceTier != "" &&
			p.Hostname != "" && p.Port != 0
		if !isHealthyServiceProc {
			continue
		}
		key := p.ServiceKey()
		result[key] = p
	}
	return result, nil
}