forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoop.go
More file actions
42 lines (32 loc) · 1.31 KB
/
noop.go
File metadata and controls
42 lines (32 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package stores
import (
"context"
"database/sql"
"errors"
"github.com/sourcegraph/sourcegraph/internal/database/basestore"
)
type noopDB struct{}
type noopHandle struct {
noopDB
}
var (
NoopDB = noopDB{}
NoopHandle = noopHandle{}
ErrNoop = errors.New("this service is initialized without a connection to CodeIntelDB")
)
func (n noopDB) Handle() basestore.TransactableHandle { return NoopHandle }
func (n noopHandle) Transact(context.Context) (basestore.TransactableHandle, error) { return n, nil }
func (n noopDB) InTransaction() bool { return false }
func (n noopDB) Transact(context.Context) (CodeIntelDB, error) { return n, nil }
func (n noopDB) Done(err error) error { return err }
func (n noopDB) QueryContext(ctx context.Context, q string, args ...any) (*sql.Rows, error) {
return nil, ErrNoop
}
func (n noopDB) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) {
return nil, ErrNoop
}
func (n noopDB) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row {
// Unfortunately, can't do much about this one as it's a concrete type
// with no exported fields or constructors in the defining package.
return nil
}