本文整理匯總了Golang中github.com/couchbase/indexing/secondary/queryport/client.GsiClient.Close方法的典型用法代碼示例。如果您正苦於以下問題:Golang GsiClient.Close方法的具體用法?Golang GsiClient.Close怎麽用?Golang GsiClient.Close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/couchbase/indexing/secondary/queryport/client.GsiClient
的用法示例。
在下文中一共展示了GsiClient.Close方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CreateSecondaryIndex
// Creates an index and waits for it to become active
func CreateSecondaryIndex(
indexName, bucketName, server, whereExpr string, indexFields []string, isPrimary bool, with []byte,
skipIfExists bool, indexActiveTimeoutSeconds int64, client *qc.GsiClient) error {
if client == nil {
c, e := CreateClient(server, "2itest")
if e != nil {
return e
}
client = c
defer client.Close()
}
indexExists := IndexExistsWithClient(indexName, bucketName, server, client)
if skipIfExists == true && indexExists == true {
return nil
}
var secExprs []string
if isPrimary == false {
for _, indexField := range indexFields {
expr, err := n1ql.ParseExpression(indexField)
if err != nil {
log.Printf("Creating index %v. Error while parsing the expression (%v) : %v", indexName, indexField, err)
}
secExprs = append(secExprs, expression.NewStringer().Visit(expr))
}
}
using := "gsi"
exprType := "N1QL"
partnExp := ""
start := time.Now()
defnID, err := client.CreateIndex(indexName, bucketName, using, exprType, partnExp, whereExpr, secExprs, isPrimary, with)
if err == nil {
log.Printf("Created the secondary index %v. Waiting for it become active", indexName)
e := WaitTillIndexActive(defnID, client, indexActiveTimeoutSeconds)
if e != nil {
return e
} else {
elapsed := time.Since(start)
tc.LogPerfStat("CreateAndBuildIndex", elapsed)
return nil
}
}
return err
}
示例2: CreateSecondaryIndexAsync
// Creates an index and DOES NOT wait for it to become active
func CreateSecondaryIndexAsync(
indexName, bucketName, server, whereExpr string, indexFields []string, isPrimary bool, with []byte,
skipIfExists bool, client *qc.GsiClient) error {
if client == nil {
c, e := CreateClient(server, "2itest")
if e != nil {
return e
}
client = c
defer client.Close()
}
indexExists := IndexExistsWithClient(indexName, bucketName, server, client)
if skipIfExists == true && indexExists == true {
return nil
}
var secExprs []string
if isPrimary == false {
for _, indexField := range indexFields {
expr, err := n1ql.ParseExpression(indexField)
if err != nil {
log.Printf("Creating index %v. Error while parsing the expression (%v) : %v", indexName, indexField, err)
}
secExprs = append(secExprs, expression.NewStringer().Visit(expr))
}
}
using := "gsi"
exprType := "N1QL"
partnExp := ""
_, err := client.CreateIndex(indexName, bucketName, using, exprType, partnExp, whereExpr, secExprs, isPrimary, with)
if err == nil {
log.Printf("Created the secondary index %v", indexName)
return nil
}
return err
}