本文整理汇总了Golang中github.com/couchbase/cbgt.Manager.CoveringPIndexes方法的典型用法代码示例。如果您正苦于以下问题:Golang Manager.CoveringPIndexes方法的具体用法?Golang Manager.CoveringPIndexes怎么用?Golang Manager.CoveringPIndexes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/couchbase/cbgt.Manager
的用法示例。
在下文中一共展示了Manager.CoveringPIndexes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: bleveIndexAlias
// Returns a bleve.IndexAlias that represents all the PIndexes for the
// index, including perhaps bleve remote client PIndexes.
//
// TODO: Perhaps need a tighter check around indexUUID, as the current
// implementation might have a race where old pindexes with a matching
// (but invalid) indexUUID might be hit.
//
// TODO: If this returns an error, perhaps the caller somewhere up the
// chain should close the cancelCh to help stop any other inflight
// activities.
func bleveIndexAlias(mgr *cbgt.Manager, indexName, indexUUID string,
ensureCanRead bool, consistencyParams *cbgt.ConsistencyParams,
cancelCh <-chan bool) (bleve.IndexAlias, error) {
planPIndexNodeFilter := cbgt.PlanPIndexNodeOk
if ensureCanRead {
planPIndexNodeFilter = cbgt.PlanPIndexNodeCanRead
}
localPIndexes, remotePlanPIndexes, err :=
mgr.CoveringPIndexes(indexName, indexUUID, planPIndexNodeFilter,
"queries")
if err != nil {
return nil, fmt.Errorf("bleve: bleveIndexAlias, err: %v", err)
}
alias := bleve.NewIndexAlias()
for _, remotePlanPIndex := range remotePlanPIndexes {
baseURL := "http://" + remotePlanPIndex.NodeDef.HostPort +
"/api/pindex/" + remotePlanPIndex.PlanPIndex.Name
alias.Add(&IndexClient{
QueryURL: baseURL + "/query",
CountURL: baseURL + "/count",
Consistency: consistencyParams,
// TODO: Propagate auth to remote client.
})
}
// TODO: Should kickoff remote queries concurrently before we wait.
err = cbgt.ConsistencyWaitGroup(indexName, consistencyParams,
cancelCh, localPIndexes,
func(localPIndex *cbgt.PIndex) error {
bindex, ok := localPIndex.Impl.(bleve.Index)
if !ok || bindex == nil ||
!strings.HasPrefix(localPIndex.IndexType, "bleve") {
return fmt.Errorf("bleve: wrong type, localPIndex: %#v",
localPIndex)
}
alias.Add(bindex)
return nil
})
if err != nil {
return nil, err
}
return alias, nil
}
示例2: bleveIndexTargets
func bleveIndexTargets(mgr *cbgt.Manager, indexName, indexUUID string,
ensureCanRead bool, consistencyParams *cbgt.ConsistencyParams,
cancelCh <-chan bool, collector BleveIndexCollector) error {
planPIndexNodeFilter := cbgt.PlanPIndexNodeOk
if ensureCanRead {
planPIndexNodeFilter = cbgt.PlanPIndexNodeCanRead
}
localPIndexes, remotePlanPIndexes, err :=
mgr.CoveringPIndexes(indexName, indexUUID, planPIndexNodeFilter,
"queries")
if err != nil {
return fmt.Errorf("bleve: bleveIndexTargets, err: %v", err)
}
prefix := mgr.Options()["urlPrefix"]
for _, remotePlanPIndex := range remotePlanPIndexes {
baseURL := "http://" + remotePlanPIndex.NodeDef.HostPort +
prefix + "/api/pindex/" + remotePlanPIndex.PlanPIndex.Name
collector.Add(&IndexClient{
name: fmt.Sprintf("IndexClient - %s", baseURL),
QueryURL: baseURL + "/query",
CountURL: baseURL + "/count",
Consistency: consistencyParams,
// TODO: Propagate auth to remote client.
})
}
// TODO: Should kickoff remote queries concurrently before we wait.
return cbgt.ConsistencyWaitGroup(indexName, consistencyParams,
cancelCh, localPIndexes,
func(localPIndex *cbgt.PIndex) error {
bindex, ok := localPIndex.Impl.(bleve.Index)
if !ok || bindex == nil ||
!strings.HasPrefix(localPIndex.IndexType, "fulltext-index") {
return fmt.Errorf("bleve: wrong type, localPIndex: %#v",
localPIndex)
}
collector.Add(bindex)
return nil
})
}