MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / execIndexQuery

Function execIndexQuery

internal/storage/db/couchbase/provider.go:158–177  ·  view source on GitHub ↗

execIndexQuery runs a CREATE INDEX statement with retries for transient query-service errors.

(scope *gocb.Scope, query string, timeout time.Duration)

Source from the content-addressed store, hash-verified

156
157// execIndexQuery runs a CREATE INDEX statement with retries for transient query-service errors.
158func execIndexQuery(scope *gocb.Scope, query string, timeout time.Duration) error {
159 deadline := time.Now().Add(timeout)
160 delay := 500 * time.Millisecond
161 for {
162 _, err := scope.Query(query, nil)
163 if err == nil {
164 return nil
165 }
166 if isIndexExistsErr(err.Error()) {
167 return nil
168 }
169 if time.Now().After(deadline) || !isTransientQueryErr(err) {
170 return err
171 }
172 time.Sleep(delay)
173 if delay < 3*time.Second {
174 delay += 500 * time.Millisecond
175 }
176 }
177}
178
179func createBucketAndScope(cluster *gocb.Cluster, bucketName string, scopeName string, ramQuota string, waitTimeout time.Duration) (*gocb.Bucket, error) {
180 if ramQuota == "" {

Callers 1

NewProviderFunction · 0.85

Calls 4

isIndexExistsErrFunction · 0.85
isTransientQueryErrFunction · 0.85
ErrorMethod · 0.80
QueryMethod · 0.65

Tested by

no test coverage detected