mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 20:51:43 +00:00
Movin enterprise codeintel stuff (and ~two others that had to be dragged
along) out of `enterprise/internal` and into `internal` as part of the
shift towards enterprise-only
## Test plan
Successfully built frontend with bazel, CI will check the rest
😎 no logic changed, just shufflin things around
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package stores
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
|
|
"github.com/sourcegraph/log"
|
|
|
|
"github.com/sourcegraph/sourcegraph/internal/database/basestore"
|
|
"github.com/sourcegraph/sourcegraph/internal/database/dbutil"
|
|
)
|
|
|
|
type CodeIntelDB interface {
|
|
dbutil.DB
|
|
basestore.ShareableStore
|
|
|
|
Transact(context.Context) (CodeIntelDB, error)
|
|
Done(error) error
|
|
}
|
|
|
|
func NewCodeIntelDB(logger log.Logger, inner *sql.DB) CodeIntelDB {
|
|
return &codeIntelDB{basestore.NewWithHandle(basestore.NewHandleWithDB(logger, inner, sql.TxOptions{}))}
|
|
}
|
|
|
|
func NewCodeIntelDBWith(other basestore.ShareableStore) CodeIntelDB {
|
|
return &codeIntelDB{basestore.NewWithHandle(other.Handle())}
|
|
}
|
|
|
|
type codeIntelDB struct {
|
|
*basestore.Store
|
|
}
|
|
|
|
func (d *codeIntelDB) Transact(ctx context.Context) (CodeIntelDB, error) {
|
|
tx, err := d.Store.Transact(ctx)
|
|
return &codeIntelDB{tx}, err
|
|
}
|
|
|
|
func (db *codeIntelDB) Done(err error) error {
|
|
return db.Store.Done(err)
|
|
}
|
|
|
|
func (db *codeIntelDB) QueryContext(ctx context.Context, q string, args ...any) (*sql.Rows, error) {
|
|
return db.Handle().QueryContext(ctx, q, args...)
|
|
}
|
|
|
|
func (db *codeIntelDB) ExecContext(ctx context.Context, q string, args ...any) (sql.Result, error) {
|
|
return db.Handle().ExecContext(ctx, q, args...)
|
|
}
|
|
|
|
func (db *codeIntelDB) QueryRowContext(ctx context.Context, q string, args ...any) *sql.Row {
|
|
return db.Handle().QueryRowContext(ctx, q, args...)
|
|
}
|