當前位置: 首頁>>代碼示例>>Golang>>正文


Golang server.Server類代碼示例

本文整理匯總了Golang中github.com/couchbaselabs/query/server.Server的典型用法代碼示例。如果您正苦於以下問題:Golang Server類的具體用法?Golang Server怎麽用?Golang Server使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Server類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: doStats

func doStats(s *server.Server, w http.ResponseWriter, req *http.Request) (interface{}, errors.Error) {
	acctStore := s.AccountingStore()
	reg := acctStore.MetricRegistry()

	switch req.Method {
	case "GET":
		stats := make(map[string]interface{})
		for name, metric := range reg.Counters() {
			addMetricData(name, stats, getMetricData(metric))
		}
		for name, metric := range reg.Gauges() {
			addMetricData(name, stats, getMetricData(metric))
		}
		for name, metric := range reg.Timers() {
			addMetricData(name, stats, getMetricData(metric))
		}
		for name, metric := range reg.Meters() {
			addMetricData(name, stats, getMetricData(metric))
		}
		for name, metric := range reg.Histograms() {
			addMetricData(name, stats, getMetricData(metric))
		}
		return stats, nil
	default:
		return nil, nil
	}
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:27,代碼來源:admin_accounting_endpoint.go

示例2: writePrefix

func (this *httpRequest) writePrefix(srvr *server.Server, signature value.Value) bool {
	return this.writeString("{\n") &&
		this.writeRequestID() &&
		this.writeClientContextID() &&
		this.writeSignature(srvr.Signature(), signature) &&
		this.writeString(",\n    \"results\": [")
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:7,代碼來源:service_response.go

示例3: Run

func Run(mockServer *server.Server, q string) ([]interface{}, []errors.Error, errors.Error) {

	var metrics value.Tristate
	base := server.NewBaseRequest(q, nil, nil, nil, "json", value.FALSE, metrics, value.TRUE, nil, "", nil)

	mr := &MockResponse{
		results: []interface{}{}, warnings: []errors.Error{}, done: make(chan bool),
	}

	query := &MockQuery{
		BaseRequest: *base,
		response:    mr,
	}

	select {
	case mockServer.Channel() <- query:
		// Wait until the request exits.
		<-query.CloseNotify()
	default:
		// Timeout.
		return nil, nil, errors.NewError(nil, "Query timed out")
	}

	// wait till all the results are ready
	<-mr.done
	return mr.results, mr.warnings, mr.err
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:27,代碼來源:json.go

示例4: Execute

func (this *httpRequest) Execute(srvr *server.Server, signature value.Value, stopNotify chan bool) {
	defer this.Stop(server.COMPLETED)

	this.NotifyStop(stopNotify)

	this.httpRespCode = http.StatusOK
	_ = this.writePrefix(srvr, signature) &&
		this.writeResults()
	this.writeSuffix(srvr.Metrics(), "")
	this.writer.noMoreData()
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:11,代碼來源:service_response.go

示例5: Failed

func (this *httpRequest) Failed(srvr *server.Server) {
	this.writeString("{\n")
	this.writeRequestID()
	this.writeClientContextID()
	this.writeErrors()
	this.writeWarnings()
	this.writeState("")
	this.writeMetrics(srvr.Metrics())
	this.writeString("\n}\n")
	this.writer.noMoreData()
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:11,代碼來源:service_response.go

示例6: doClusters

func doClusters(s *server.Server, w http.ResponseWriter, req *http.Request) (interface{}, errors.Error) {
	cfgStore := s.ConfigurationStore()
	cm := cfgStore.ConfigurationManager()
	switch req.Method {
	case "GET":
		return cm.GetClusters()
	case "POST":
		cluster, err := getClusterFromRequest(req)
		if err != nil {
			return nil, err
		}
		return cfgStore.ConfigurationManager().AddCluster(cluster)
	default:
		return nil, nil
	}
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:16,代碼來源:admin_clustering_endpoint.go

示例7: doCluster

func doCluster(s *server.Server, w http.ResponseWriter, req *http.Request) (interface{}, errors.Error) {
	vars := mux.Vars(req)
	name := vars["cluster"]
	cfgStore := s.ConfigurationStore()
	cluster, err := cfgStore.ClusterByName(name)
	if err != nil {
		return nil, err
	}

	switch req.Method {
	case "GET":
		return cluster, nil
	case "DELETE":
		return cfgStore.ConfigurationManager().RemoveCluster(cluster)
	default:
		return nil, nil
	}
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:18,代碼來源:admin_clustering_endpoint.go

示例8: NewServiceEndpoint

func NewServiceEndpoint(server *server.Server, staticPath string, metrics bool) *HttpEndpoint {
	rv := &HttpEndpoint{
		server:  server,
		metrics: metrics,
		bufpool: NewSyncPool(server.KeepAlive()),
	}

	rv.registerHandlers(staticPath)
	return rv
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:10,代碼來源:service_endpoint.go

示例9: doStat

func doStat(s *server.Server, w http.ResponseWriter, req *http.Request) (interface{}, errors.Error) {
	vars := mux.Vars(req)
	name := vars["stat"]
	acctStore := s.AccountingStore()
	reg := acctStore.MetricRegistry()

	switch req.Method {
	case "GET":
		metric := reg.Get(name)
		if metric != nil {
			return getMetricData(metric), nil
		} else {
			return nil, nil
		}
	case "DELETE":
		return nil, reg.Unregister(name)
	default:
		return nil, nil
	}
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:20,代碼來源:admin_accounting_endpoint.go

示例10: doNodes

func doNodes(s *server.Server, w http.ResponseWriter, req *http.Request) (interface{}, errors.Error) {
	vars := mux.Vars(req)
	name := vars["cluster"]
	cfgStore := s.ConfigurationStore()
	cluster, err := cfgStore.ClusterByName(name)
	if err != nil || cluster == nil {
		return cluster, err
	}
	switch req.Method {
	case "GET":
		return cluster.ClusterManager().GetQueryNodes()
	case "POST":
		node, err := getNodeFromRequest(req)
		if err != nil {
			return nil, err
		}
		return cluster.ClusterManager().AddQueryNode(node)
	default:
		return nil, nil
	}
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:21,代碼來源:admin_clustering_endpoint.go

示例11: doConfig

func doConfig(s *server.Server, w http.ResponseWriter, req *http.Request) (interface{}, errors.Error) {
	if localConfig.myConfig != nil {
		return localConfig.myConfig, nil
	}
	var self clustering.QueryNode
	ip, err := util.ExternalIP()
	if err != nil {
		return nil, err
	}

	name, er := os.Hostname()
	if er != nil {
		return nil, err
	}

	cm := s.ConfigurationStore().ConfigurationManager()
	clusters, err := cm.GetClusters()
	if err != nil {
		return nil, err
	}

	for _, c := range clusters {
		clm := c.ClusterManager()
		queryNodes, err := clm.GetQueryNodes()
		if err != nil {
			return nil, err
		}

		for _, qryNode := range queryNodes {
			if qryNode.Name() == ip || qryNode.Name() == name {
				self = qryNode
				break
			}
		}
	}
	localConfig.Lock()
	defer localConfig.Unlock()
	localConfig.myConfig = self
	return localConfig.myConfig, nil
}
開發者ID:amarantha-k,項目名稱:query,代碼行數:40,代碼來源:admin_clustering_endpoint.go


注:本文中的github.com/couchbaselabs/query/server.Server類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。