execIndexQuery runs a CREATE INDEX statement with retries for transient query-service errors.
(scope *gocb.Scope, query string, timeout time.Duration)
| 156 | |
| 157 | // execIndexQuery runs a CREATE INDEX statement with retries for transient query-service errors. |
| 158 | func 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 | |
| 179 | func createBucketAndScope(cluster *gocb.Cluster, bucketName string, scopeName string, ramQuota string, waitTimeout time.Duration) (*gocb.Bucket, error) { |
| 180 | if ramQuota == "" { |
no test coverage detected