本文整理匯總了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
}