// Service is used to query catalog entries for a given service
556967
func (c *Catalog) Service(service, tag string, q *QueryOptions) ([]*CatalogService, *QueryMeta, error) {
	var tags []string
	if tag != "" {
		tags = []string{tag}
	}
	return c.service(service, tags, q, false)
}
1114170
func (o *os) ListServices() ([]*registry.Service, error) {
	o.RLock()
	if cache := o.cache; len(cache) > 0 {
		var services []*registry.Service
		for _, service := range cache {
			services = append(services, service...)
		}
		o.RUnlock()
		return services, nil
	}
	o.RUnlock()

	var grsp *proto2.ListServicesResponse
	var grr error

	req := o.opts.Client.NewRequest("go.micro.srv.discovery", "Registry.ListServices", &proto2.ListServicesRequest{})

	for _, addr := range o.next() {
		rsp := &proto2.ListServicesResponse{}
		err := o.opts.Client.CallRemote(context.TODO(), addr, req, rsp)
		if err != nil {
			grr = err
			continue
		}
		grsp = rsp
		break
	}

	if grr != nil {
		return nil, grr
	}

	var services []*registry.Service
	for _, service := range grsp.Services {
		services = append(services, toService(service))
	}
	return services, nil
}
1140606
func (s *Supervisor) Services() map[string]Service {
	svclist := make(map[string]Service)
	s.mu.Lock()
	for k, v := range s.services {
		svclist[k] = v.svc
	}
	s.mu.Unlock()
	return svclist
}
841924
func (s *Server) ServiceUse(request *ServiceUseRequest, response *string) error {
	if err := s.f.ServiceUse(s.context(), request.ServiceID, request.ImageID, request.Registry, request.ReplaceImgs, request.NoOp); err != nil {
		return err
	}
	*response = ""
	return nil
}
501018
func (c *Config) Service(client *api.Client, logger *log.Logger) (*connect.Service, error) {
	return connect.NewServiceWithLogger(c.ProxiedServiceName, client, logger)
}
588563
func ListServices() ([]string, error) {
	fis, err := ioutil.ReadDir(InitDir)
	if err != nil {
		return nil, errors.Trace(err)
	}

	var services []string
	for _, fi := range fis {
		if groups := servicesRe.FindStringSubmatch(fi.Name()); len(groups) > 0 {
			services = append(services, groups[1])
		}
	}
	return services, nil
}
1015908
func Services(s map[string][]*registry.Service) registry.Option {
	return func(o *registry.Options) {
		if o.Context == nil {
			o.Context = context.Background()
		}
		o.Context = context.WithValue(o.Context, servicesKey{}, s)
	}
}
534428
func (s *Simulation) Service(name string, id enode.ID) node.Service {
	simNode, ok := s.Net.GetNode(id).Node.(*adapters.SimNode)
	if !ok {
		return nil
	}
	services := simNode.ServiceMap()
	if len(services) == 0 {
		return nil
	}
	return services[name]
}
1252189
func (p Partition) Services() map[string]Service {
	ss := map[string]Service{}
	for id := range p.p.Services {
		ss[id] = Service{
			id: id,
			p:  p.p,
		}
	}

	return ss
}
691842
func (b *Broker) Catalog() *api.Response {
	klog.V(4).Infof("Template service broker: Catalog")

	var services []*api.Service

	for namespace := range b.templateNamespaces {
		templates, err := b.lister.Templates(namespace).List(labels.Everything())
		if err != nil {
			return api.InternalServerError(err)
		}

		for _, template := range templates {
			services = append(services, serviceFromTemplate(template))
		}
	}

	return api.NewResponse(http.StatusOK, &api.CatalogResponse{Services: services}, nil)
}
1031888
func (m *Module) LookupService(name string) (*ServiceSpec, error) {
	if s, ok := m.Services[name]; ok {
		return s, nil
	}

	return nil, lookupError{Name: name}
}
561967
func (c *Client) GetServices() ([]*models.Service, error) {
	resp, err := c.Service.GetService(nil)
	if err != nil {
		return nil, Hint(err)
	}
	return resp.Payload, nil
}
204488
func (c *kregistry) ListServices() ([]*registry.Service, error) {
	pods, err := c.client.ListPods(podSelector)
	if err != nil {
		return nil, err
	}

	// svcs mapped by name
	svcs := make(map[string]bool)

	for _, pod := range pods.Items {
		if pod.Status.Phase != podRunning {
			continue
		}
		for k, v := range pod.Metadata.Annotations {
			if !strings.HasPrefix(k, annotationServiceKeyPrefix) {
				continue
			}

			// we have to unmarshal the annotation itself since the
			// key is encoded to match the regex restriction.
			var svc registry.Service
			if err := json.Unmarshal([]byte(*v), &svc); err != nil {
				continue
			}
			svcs[svc.Name] = true
		}
	}

	var list []*registry.Service
	for val := range svcs {
		list = append(list, &registry.Service{Name: val})
	}
	return list, nil
}
930234
func (_m *Store) AddService(svc *types.Service) error {
	ret := _m.Called(svc)

	var r0 error
	if rf, ok := ret.Get(0).(func(*types.Service) error); ok {
		r0 = rf(svc)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
824312
func (c *Client) ServiceUse(serviceID string, imageID string, registry string, replaceImgs []string, noOp bool) (string, error) {
	svcUseRequest := &ServiceUseRequest{ServiceID: serviceID, ImageID: imageID, ReplaceImgs: replaceImgs, Registry: registry, NoOp: noOp}
	result := ""
	plog.WithFields(logrus.Fields{
		"imageid": imageID,
		"registry": registry,
	}).Info("Pulling image, tagging to latest, and pushing to registry - this may take a while")
	err := c.call("ServiceUse", svcUseRequest, &result)
	if err != nil {
		return "", err
	}
	return result, nil
}
81653
func (s *storeImpl) Get(ctx datastore.Context, id string) (*Service, error) {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.Get"))
	// Get the service from elastic and fill additional info into the
	// service object.
	svc, err := s.get(ctx, id)
	if err == nil {
		s.fillAdditionalInfo(svc) // Mutex RLock
	}
	return svc, err
}
920397
func Services(
	namespace Namespace,
	config *composetypes.Config,
	client *client.Client,
) (map[string]swarm.ServiceSpec, error) {
	result := make(map[string]swarm.ServiceSpec)

	services := config.Services
	volumes := config.Volumes
	networks := config.Networks

	for _, service := range services {
		secrets, err := convertServiceSecrets(client, namespace, service.Secrets, config.Secrets)
		if err != nil {
			return nil, errors.Wrapf(err, "service %s", service.Name)
		}
		configs, err := convertServiceConfigObjs(client, namespace, service, config.Configs)
		if err != nil {
			return nil, errors.Wrapf(err, "service %s", service.Name)
		}

		serviceSpec, err := Service(client.ClientVersion(), namespace, service, networks, volumes, secrets, configs)
		if err != nil {
			return nil, errors.Wrapf(err, "service %s", service.Name)
		}
		result[service.Name] = serviceSpec
	}

	return result, nil
}