本文整理匯總了Golang中github.com/couchbase/cbgt.Manager.TagsMap方法的典型用法代碼示例。如果您正苦於以下問題:Golang Manager.TagsMap方法的具體用法?Golang Manager.TagsMap怎麽用?Golang Manager.TagsMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/couchbase/cbgt.Manager
的用法示例。
在下文中一共展示了Manager.TagsMap方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: InitRESTRouter
// InitRESTRouter initializes a mux.Router with REST API
// routes.
func InitRESTRouter(r *mux.Router, versionMain string,
mgr *cbgt.Manager, staticDir, staticETag string,
mr *cbgt.MsgRing,
assetDir func(name string) ([]string, error),
asset func(name string) ([]byte, error)) (
*mux.Router, map[string]RESTMeta, error) {
PIndexTypesInitRouter(r, "manager.before")
meta := map[string]RESTMeta{}
handle := func(path string, method string, h http.Handler,
opts map[string]string) {
if a, ok := h.(RESTOpts); ok {
a.RESTOpts(opts)
}
meta[path+" "+RESTMethodOrds[method]+method] =
RESTMeta{path, method, opts}
r.Handle(path, h).Methods(method)
}
handleFunc := func(path string, method string, h http.HandlerFunc,
opts map[string]string) {
meta[path+" "+RESTMethodOrds[method]+method] =
RESTMeta{path, method, opts}
r.HandleFunc(path, h).Methods(method)
}
handle("/api/index", "GET", NewListIndexHandler(mgr),
map[string]string{
"_category": "Indexing|Index definition",
"_about": `Returns all index definitions as JSON.`,
"version introduced": "0.0.1",
})
handle("/api/index/{indexName}", "PUT", NewCreateIndexHandler(mgr),
map[string]string{
"_category": "Indexing|Index definition",
"_about": `Creates/updates an index definition.`,
"version introduced": "0.0.1",
})
handle("/api/index/{indexName}", "DELETE", NewDeleteIndexHandler(mgr),
map[string]string{
"_category": "Indexing|Index definition",
"_about": `Deletes an index definition.`,
"version introduced": "0.0.1",
})
handle("/api/index/{indexName}", "GET", NewGetIndexHandler(mgr),
map[string]string{
"_category": "Indexing|Index definition",
"_about": `Returns the definition of an index as JSON.`,
"version introduced": "0.0.1",
})
if mgr == nil || mgr.TagsMap() == nil || mgr.TagsMap()["queryer"] {
handle("/api/index/{indexName}/count", "GET",
NewCountHandler(mgr),
map[string]string{
"_category": "Indexing|Index querying",
"_about": `Returns the count of indexed documents.`,
"version introduced": "0.0.1",
})
handle("/api/index/{indexName}/query", "POST",
NewQueryHandler(mgr),
map[string]string{
"_category": "Indexing|Index querying",
"_about": `Queries an index.`,
"version introduced": "0.2.0",
})
}
handle("/api/index/{indexName}/planFreezeControl/{op}", "POST",
NewIndexControlHandler(mgr, "planFreeze", map[string]bool{
"freeze": true,
"unfreeze": true,
}),
map[string]string{
"_category": "Indexing|Index management",
"_about": `Freeze the assignment of index partitions to nodes.`,
"param: op": "required, string, URL path parameter\n\n" +
`Allowed values for op are "freeze" or "unfreeze".`,
"version introduced": "0.0.1",
})
handle("/api/index/{indexName}/ingestControl/{op}", "POST",
NewIndexControlHandler(mgr, "write", map[string]bool{
"pause": true,
"resume": true,
}),
map[string]string{
"_category": "Indexing|Index management",
"_about": `Pause index updates and maintenance (no more
ingesting document mutations).`,
"param: op": "required, string, URL path parameter\n\n" +
`Allowed values for op are "pause" or "resume".`,
"version introduced": "0.0.1",
})
handle("/api/index/{indexName}/queryControl/{op}", "POST",
NewIndexControlHandler(mgr, "read", map[string]bool{
"allow": true,
"disallow": true,
}),
map[string]string{
//.........這裏部分代碼省略.........
示例2: InitRESTRouterEx
// InitRESTRouter initializes a mux.Router with REST API routes with
// extra option.
func InitRESTRouterEx(r *mux.Router, versionMain string,
mgr *cbgt.Manager, staticDir, staticETag string,
mr *cbgt.MsgRing,
assetDir func(name string) ([]string, error),
asset func(name string) ([]byte, error),
options map[string]interface{}) (
*mux.Router, map[string]RESTMeta, error) {
var authHandler func(http.Handler) http.Handler
mapRESTPathStats := map[string]*RESTPathStats{} // Keyed by path spec.
if options != nil {
if v, ok := options["auth"]; ok {
authHandler, ok = v.(func(http.Handler) http.Handler)
if !ok {
return nil, nil, fmt.Errorf("rest: auth function invalid")
}
}
if v, ok := options["mapRESTPathStats"]; ok {
mapRESTPathStats, ok = v.(map[string]*RESTPathStats)
if !ok {
return nil, nil, fmt.Errorf("rest: mapRESTPathStats invalid")
}
}
}
prefix := mgr.Options()["urlPrefix"]
PIndexTypesInitRouter(r, "manager.before", mgr)
meta := map[string]RESTMeta{}
handle := func(path string, method string, h http.Handler,
opts map[string]string) {
opts["_path"] = path
if a, ok := h.(RESTOpts); ok {
a.RESTOpts(opts)
}
prefixPath := prefix + path
restMeta := RESTMeta{prefixPath, method, opts}
meta[prefixPath+" "+RESTMethodOrds[method]+method] = restMeta
h = &HandlerWithRESTMeta{
h: h,
RESTMeta: &restMeta,
pathStats: mapRESTPathStats[path],
focusName: PathFocusName(path),
}
if authHandler != nil {
h = authHandler(h)
}
r.Handle(prefixPath, h).Methods(method).Name(prefixPath)
}
handle("/api/index", "GET", NewListIndexHandler(mgr),
map[string]string{
"_category": "Indexing|Index definition",
"_about": `Returns all index definitions as JSON.`,
"version introduced": "0.0.1",
})
handle("/api/index/{indexName}", "PUT", NewCreateIndexHandler(mgr),
map[string]string{
"_category": "Indexing|Index definition",
"_about": `Creates/updates an index definition.`,
"version introduced": "0.0.1",
})
handle("/api/index/{indexName}", "DELETE", NewDeleteIndexHandler(mgr),
map[string]string{
"_category": "Indexing|Index definition",
"_about": `Deletes an index definition.`,
"version introduced": "0.0.1",
})
handle("/api/index/{indexName}", "GET", NewGetIndexHandler(mgr),
map[string]string{
"_category": "Indexing|Index definition",
"_about": `Returns the definition of an index as JSON.`,
"version introduced": "0.0.1",
})
if mgr == nil || mgr.TagsMap() == nil || mgr.TagsMap()["queryer"] {
handle("/api/index/{indexName}/count", "GET",
NewCountHandler(mgr),
map[string]string{
"_category": "Indexing|Index querying",
"_about": `Returns the count of indexed documents.`,
"version introduced": "0.0.1",
})
handle("/api/index/{indexName}/query", "POST",
NewQueryHandler(mgr,
mapRESTPathStats["/api/index/{indexName}/query"]),
map[string]string{
"_category": "Indexing|Index querying",
"_about": `Queries an index.`,
"version introduced": "0.2.0",
})
}
handle("/api/index/{indexName}/planFreezeControl/{op}", "POST",
//.........這裏部分代碼省略.........