// services, returns all of the services that match the Mgr's match function.
768121
func (m *Mgr) services() ([]*mgr.Service, error) {
	names, err := m.m.ListServices()
	if err != nil {
		return nil, fmt.Errorf("winsvc: listing services: %s", err)
	}
	var svcs []*mgr.Service
	for _, name := range names {
		s, err := m.m.OpenService(name)
		if err != nil {
			continue // ignore - likely access denied
		}
		desc, err := serviceDescription(s)
		if err != nil {
			s.Close()
			continue // ignore - likely access denied
		}
		if m.match(desc) {
			svcs = append(svcs, s)
		} else {
			s.Close()
		}
	}
	return svcs, nil
}
1012519
func (_m *State) GetServices() []types.Service {
	ret := _m.Called()

	var r0 []types.Service
	if rf, ok := ret.Get(0).(func() []types.Service); ok {
		r0 = rf()
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]types.Service)
		}
	}

	return r0
}
37112
func (h *Health) Service(service, tag string, passingOnly bool, q *QueryOptions) ([]*ServiceEntry, *QueryMeta, error) {
	var tags []string
	if tag != "" {
		tags = []string{tag}
	}
	return h.service(service, tags, passingOnly, q, false)
}
1080640
func Service(g Generator, s *compile.ServiceSpec) (map[string]*bytes.Buffer, error) {
	files := make(map[string]*bytes.Buffer)

	for _, functionName := range sortStringKeys(s.Functions) {
		fileName := fmt.Sprintf("%s_%s.go", strings.ToLower(s.Name), strings.ToLower(functionName))

		function := s.Functions[functionName]
		if err := ServiceFunction(g, s, function); err != nil {
			return nil, fmt.Errorf(
				"could not generate types for %s.%s: %v",
				s.Name, functionName, err)
		}

		buff := new(bytes.Buffer)
		if err := g.Write(buff, token.NewFileSet()); err != nil {
			return nil, fmt.Errorf("could not write %s.%s: %v", s.Name, functionName, err)
		}

		// TODO check for conflicts
		files[fileName] = buff
	}

	return files, nil
}
1302446
func (r *registry) loadServices(file *File) error {
	var svcs []*Service
	for _, sd := range file.GetService() {
		svc := &Service{
			ServiceDescriptorProto: sd,
			File:                   file,
		}
		for _, md := range sd.GetMethod() {
			meth, err := r.newMethod(svc, md)
			if err != nil {
				return err
			}
			svc.Methods = append(svc.Methods, meth)
		}
		if len(svc.Methods) == 0 {
			continue
		}
		svcs = append(svcs, svc)
	}
	file.Services = svcs
	return nil
}
1292596
func (s *Simulation) Services(name string) (services map[enode.ID]node.Service) {
	nodes := s.Net.GetNodes()
	services = make(map[enode.ID]node.Service)
	for _, node := range nodes {
		if !node.Up() {
			continue
		}
		simNode, ok := node.Node.(*adapters.SimNode)
		if !ok {
			continue
		}
		services[node.ID()] = simNode.Service(name)
	}
	return services
}
215854
func Service() (c *ServiceController) {
	return &ServiceController{
		List:       serviceList,
		Detail:     serviceDetail,
		Raw:        serviceRaw,
		Logs:       serviceLogs,
		FetchLogs:  serviceFetchLogs,
		Delete:     serviceDelete,
		New:        serviceNew,
		Create:     serviceCreate,
		Edit:       serviceEdit,
		Update:     serviceUpdate,
		Scale:      serviceScale,
		Rollback:   serviceRollback,
		Restart:    serviceRestart,
		PermEdit:   servicePermEdit,
		PermUpdate: permUpdate("service", "name"),
		Stats:      serviceStats,
	}
}
1345986
func (f *Facade) GetAllServices(ctx datastore.Context) ([]service.Service, error) {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.GetAllServices"))
	var (
		err  error
		svcs []service.Service
	)
	plog.Debug("Started Facade.GetAllServices")
	defer plog.Debug("Finished Facade.GetAllServices")

	svcs, err = f.getServices(ctx)
	if err != nil {
		return nil, err
	}
	return svcs, nil
}
703851
func (actor Actor) MatchResources(resources []sharedaction.V3Resource) ([]sharedaction.V3Resource, []sharedaction.V3Resource, Warnings, error) {
	matches, warnings, err := actor.V7Actor.ResourceMatch(resources)

	mapChecksumToResource := map[string]sharedaction.V3Resource{}
	for _, resource := range matches {
		mapChecksumToResource[resource.Checksum.Value] = resource
	}

	var unmatches []sharedaction.V3Resource
	for _, resource := range resources {
		if _, ok := mapChecksumToResource[resource.Checksum.Value]; !ok {
			unmatches = append(unmatches, resource)
		}
	}

	return matches, unmatches, Warnings(warnings), err
}
637167
func (s *Supervisor) Services() []Service {
	ls := listServices{make(chan []Service)}

	if s.sendControl(ls) {
		return <-ls.c
	}
	return nil
}
541956
func (_m *FacadeInterface) GetServices(ctx datastore.Context, request dao.EntityRequest) ([]service.Service, error) {
	ret := _m.Called(ctx, request)

	var r0 []service.Service
	if rf, ok := ret.Get(0).(func(datastore.Context, dao.EntityRequest) []service.Service); ok {
		r0 = rf(ctx, request)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]service.Service)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(datastore.Context, dao.EntityRequest) error); ok {
		r1 = rf(ctx, request)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
116523
func (service RunstatusService) Match(other RunstatusService) bool {
	if other.Name != "" && service.Name == other.Name {
		return true
	}

	if other.ID > 0 && service.ID == other.ID {
		return true
	}

	return false
}
490494
func (s *IPServiceList) GetAllServices() ([]IPService, error) {
	services := s.Services
	t := s

	for t.HasNextPage() {
		var err error
		t, err = t.NextPage()
		if err != nil {
			return nil, err
		}
		services = append(services, t.Services...)
	}
	return services, nil
}
670439
func (d *StaticDiscovery) Services() []service.Service {
	var services []service.Service
	for _, target := range d.Targets {
		target.Service.Updated = time.Now().UTC()
		services = append(services, target.Service)
	}
	return services
}
862266
func (v *version) Services() ServiceInformer {
	return &serviceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
1063631
func (e *Etcd) Services(state request.Request, exact bool, opt plugin.Options) (services []msg.Service, err error) {
	services, err = e.Records(state, exact)
	if err != nil {
		return
	}

	services = msg.Group(services)
	return
}
1203170
func Services() ([]*Service, error) {
	// initialize a new etcd client
	c, err := client.New(cfg)
	if err != nil {
		log.WithFields(log.Fields{"service": "portmapper", "errstr": err.Error()}).Fatal("Error initializing etcd client")
		return nil, err
	}

	kAPI := client.NewKeysAPI(c)

	// attempt to delete the svc's path with exponential backoff
	for try := 0; try < MaxRetries; try++ {
		// 5 second context
		ctx, cancel := context.WithTimeout(context.Background(), RequestTimeoutSec*time.Second)
		defer cancel()

		resp, err := kAPI.Get(ctx, RegistryPath, &client.GetOptions{Sort: true})
		if err != nil {
			// handle error
			if err == context.DeadlineExceeded {
				log.WithFields(log.Fields{
					"action":  "Enumerate Services",
					"attempt": try,
					"errstr":  err.Error(),
				}).Warn("Service enumeration exceeded context deadline. Retrying")
			} else {
				log.WithFields(log.Fields{
					"action":  "Enumerate Services",
					"attempt": try,
					"errstr":  err.Error(),
				}).Error("Service enumeration failed")
				return nil, err
			}
		} else if resp == nil {
			log.WithFields(log.Fields{
				"action":  "Enumerate Services",
				"attempt": try,
				"errstr":  "nil response for etcd get",
			}).Error("Service enumeration failed")
			return nil, errors.New("Nil response from  etcd get")
		} else {
			svcNodes := resp.Node.Nodes
			services := make([]*Service, len(svcNodes))

			for i, node := range svcNodes {
				svcStr := node.Value
				svc, err := UnmarshalService([]byte(svcStr))

				if err != nil {
					return nil, err
				}

				services[i] = svc
			}

			return services, nil
		}

		time.Sleep(2 << uint(try) * time.Millisecond)
	}

	return nil, errors.New("Couldn't get services from etcd")
}