N1QlQueryWithStats is a wrapper for gocbBucket.Query that performs additional diagnostic processing (expvars, slow query logging)
(ctx context.Context, dataStore base.DataStore, queryName string, statement string, params map[string]interface{}, consistency base.ConsistencyMode, adhoc bool, dbStats *base.DbStats, slowQueryWarningThreshold time.Duration)
| 371 | |
| 372 | // N1QlQueryWithStats is a wrapper for gocbBucket.Query that performs additional diagnostic processing (expvars, slow query logging) |
| 373 | func N1QLQueryWithStats(ctx context.Context, dataStore base.DataStore, queryName string, statement string, params map[string]interface{}, consistency base.ConsistencyMode, adhoc bool, dbStats *base.DbStats, slowQueryWarningThreshold time.Duration) (results sgbucket.QueryResultIterator, err error) { |
| 374 | |
| 375 | startTime := time.Now() |
| 376 | if threshold := slowQueryWarningThreshold; threshold > 0 { |
| 377 | defer base.SlowQueryLog(ctx, startTime, threshold, "N1QL Query(%q)", queryName) |
| 378 | } |
| 379 | |
| 380 | n1QLStore, ok := base.AsN1QLStore(dataStore) |
| 381 | if !ok { |
| 382 | return nil, errors.New("Cannot perform N1QL query on non-Couchbase bucket.") |
| 383 | } |
| 384 | |
| 385 | results, err = n1QLStore.Query(ctx, statement, params, consistency, adhoc) |
| 386 | |
| 387 | if len(queryName) > 0 { |
| 388 | queryStat := dbStats.Query(queryName) |
| 389 | if queryStat == nil { |
| 390 | // This panic is more recognizable than the one that will otherwise occur below |
| 391 | panic(fmt.Sprintf("DbStats has no entry for query %q", queryName)) |
| 392 | } |
| 393 | if err != nil { |
| 394 | queryStat.QueryErrorCount.Add(1) |
| 395 | } |
| 396 | queryStat.QueryCount.Add(1) |
| 397 | queryStat.QueryTime.Add(time.Since(startTime).Nanoseconds()) |
| 398 | } |
| 399 | return results, err |
| 400 | } |
| 401 | |
| 402 | // ViewQueryWithStats is a wrapper for gocbBucket.Query that performs additional diagnostic processing (expvars, slow query logging) |
| 403 | func (context *DatabaseContext) ViewQueryWithStats(ctx context.Context, dataStore base.DataStore, ddoc string, viewName string, params map[string]interface{}) (results sgbucket.QueryResultIterator, err error) { |
no test coverage detected