// getSpecificServer returns the server with the given endpoint.
511900
func (c *clusterConnection) getSpecificServer(endpoint string) (driver.Connection, error) {
	c.mutex.RLock()
	defer c.mutex.RUnlock()

	for _, s := range c.servers {
		endpoints := s.Endpoints()
		found := false
		for _, x := range endpoints {
			if x == endpoint {
				found = true
				break
			}
		}
		if found {
			return s, nil
		}
	}

	return nil, driver.WithStack(driver.InvalidArgumentError{Message: fmt.Sprintf("unknown endpoint: %s", endpoint)})
}
665063
func MakeSimpleStreamsServerSpec(name, host string) ServerSpec {
	return ServerSpec{
		Name:     name,
		Host:     EnsureHTTPS(host),
		Protocol: SimpleStreamsProtocol,
	}
}
1160444
func (s *HTTPServer) PreparedQuerySpecific(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
	if req.Method == "OPTIONS" {
		return s.preparedQuerySpecificOptions(resp, req), nil
	}

	path := req.URL.Path
	id := strings.TrimPrefix(path, "/v1/query/")

	switch {
	case strings.HasSuffix(path, "/execute"):
		if req.Method != "GET" {
			return nil, MethodNotAllowedError{req.Method, []string{"GET"}}
		}
		id = strings.TrimSuffix(id, "/execute")
		return s.preparedQueryExecute(id, resp, req)

	case strings.HasSuffix(path, "/explain"):
		if req.Method != "GET" {
			return nil, MethodNotAllowedError{req.Method, []string{"GET"}}
		}
		id = strings.TrimSuffix(id, "/explain")
		return s.preparedQueryExplain(id, resp, req)

	default:
		switch req.Method {
		case "GET":
			return s.preparedQueryGet(id, resp, req)

		case "PUT":
			return s.preparedQueryUpdate(id, resp, req)

		case "DELETE":
			return s.preparedQueryDelete(id, resp, req)

		default:
			return nil, MethodNotAllowedError{req.Method, []string{"GET", "PUT", "DELETE"}}
		}
	}
}
71025
func (api *SwitchAPI) GetServers(switchID int64) ([]sacloud.Server, error) {
	var (
		method = "GET"
		uri    = fmt.Sprintf("%s/%d/server", api.getResourceURL(), switchID)
		res    = &sacloud.SearchResponse{}
	)
	err := api.baseAPI.request(method, uri, nil, res)
	if err != nil {
		return nil, err
	}
	return res.Servers, nil
}
561806
func (is *InfoSyncer) GetServerInfoByID(ctx context.Context, id string) (*ServerInfo, error) {
	if is.etcdCli == nil || id == is.info.ID {
		return is.info, nil
	}
	key := fmt.Sprintf("%s/%s", ServerInformationPath, id)
	infoMap, err := getInfo(ctx, is.etcdCli, key, keyOpDefaultRetryCnt, keyOpDefaultTimeout)
	if err != nil {
		return nil, err
	}
	info, ok := infoMap[id]
	if !ok {
		return nil, errors.Errorf("[info-syncer] get %s failed", key)
	}
	return info, nil
}
520726
func (mr *MockServiceDiscoveryMockRecorder) GetServer(id interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetServer", reflect.TypeOf((*MockServiceDiscovery)(nil).GetServer), id)
}
787731
func getAllServers(w http.ResponseWriter, r *http.Request) {
	mx.RLock()
	defer mx.RUnlock()
	if err := json.NewEncoder(w).Encode(servers); err != nil {
		log.Printf("[JSON Encoding Error] %s", err)
		http.Error(w, err.Error(), http.StatusInternalServerError)
	}
}
396445
func (s *ConfigService) GetServerInfo() (*ServerInfo, *Response, error) {
	u := "config/server/info"

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	v := new(ServerInfo)
	resp, err := s.client.Do(req, v)
	if err != nil {
		return nil, resp, err
	}

	return v, resp, err
}
1155100
func httpInspectEndpointGroup(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
	var obj EndpointGroupInspect
	log.Debugf("Received httpInspectEndpointGroup: %+v", vars)

	key := vars["key"]

	collections.endpointGroupMutex.Lock()
	defer collections.endpointGroupMutex.Unlock()
	objConfig := collections.endpointGroups[key]
	if objConfig == nil {
		log.Errorf("endpointGroup %s not found", key)
		return nil, errors.New("endpointGroup not found")
	}
	obj.Config = *objConfig

	if err := GetOperEndpointGroup(&obj); err != nil {
		log.Errorf("GetEndpointGroup error for: %+v. Err: %v", obj, err)
		return nil, err
	}

	// Return the obj
	return &obj, nil
}
520964
func getServer(vm *VM) (*servers.Server, error) {
	if vm.InstanceID == "" {
		// Probably need to call Provision first.
		return nil, ErrNoInstanceID
	}

	client, err := getComputeClient(vm)
	if err != nil {
		return nil, err
	}

	status, err := servers.Get(client, vm.InstanceID).Extract()
	if status != nil && err != nil {
		return nil, fmt.Errorf("failed to retrieve the server for VM")
	}

	return status, nil
}
476314
func (s *Server) GetInfo() services.Server {
	return &services.ServerV2{
		Kind:    services.KindNode,
		Version: services.V2,
		Metadata: services.Metadata{
			Name:      s.ID(),
			Namespace: s.GetNamespace(),
		},
		Spec: services.ServerSpecV2{
			Addr: s.AdvertiseAddr(),
		},
	}
}
459978
func (r *Registry) GetServerFunc(stream string) (func(*Peer, string, bool) (Server, error), error) {
	r.serverMu.RLock()
	defer r.serverMu.RUnlock()

	f := r.serverFuncs[stream]
	if f == nil {
		return nil, fmt.Errorf("stream %v not registered", stream)
	}
	return f, nil
}
1268939
func (soc *Socket) GetGssapiServer() (bool, error) {
	if minor < 1 {
		return false, ErrorNotImplemented41
	}
	v, err := soc.getInt(C.ZMQ_GSSAPI_SERVER)
	return v != 0, err
}
866105
func (p *propServerPlan) GetCPU() int {
	if p.ServerPlan == nil {
		return -1
	}

	return p.ServerPlan.GetCPU()
}
588150
func GetAndServeWithHTTP(
	registerFunc func(*grpc.Server),
	httpRegisterFunc func(context.Context, *runtime.ServeMux, *grpc.ClientConn) error,
	options ServeWithHTTPOptions,
) error {
	serveEnv, err := GetServeEnv()
	if err != nil {
		return err
	}
	handlerEnv, err := pkghttp.GetHandlerEnv()
	if err != nil {
		return err
	}
	return ServeWithHTTP(
		registerFunc,
		httpRegisterFunc,
		options,
		serveEnv,
		handlerEnv,
	)
}
129513
func (s cloudSpecAPI) CloudSpec(args params.Entities) (params.CloudSpecResults, error) {
	authFunc, err := s.getAuthFunc()
	if err != nil {
		return params.CloudSpecResults{}, err
	}
	results := params.CloudSpecResults{
		Results: make([]params.CloudSpecResult, len(args.Entities)),
	}
	for i, arg := range args.Entities {
		tag, err := names.ParseModelTag(arg.Tag)
		if err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		if !authFunc(tag) {
			results.Results[i].Error = common.ServerError(common.ErrPerm)
			continue
		}
		results.Results[i] = s.GetCloudSpec(tag)
	}
	return results, nil
}
346094
func (c *clusterConnection) getCurrentServer() driver.Connection {
	c.mutex.RLock()
	defer c.mutex.RUnlock()
	return c.servers[c.current]
}