当前位置: 首页>>代码示例>>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;未经允许,请勿转载。