本文整理汇总了Golang中github.com/couchbaselabs/query/server.Server.ConfigurationStore方法的典型用法代码示例。如果您正苦于以下问题:Golang Server.ConfigurationStore方法的具体用法?Golang Server.ConfigurationStore怎么用?Golang Server.ConfigurationStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/couchbaselabs/query/server.Server
的用法示例。
在下文中一共展示了Server.ConfigurationStore方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
}
示例2: 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
}
}
示例3: 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
}
}
示例4: 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
}