11a8a0f99c
* Update cobra to require `head` or `historic` when using `capture`. * A very generic package for implementing PGX driver I copied most of the code from the `statediff` service from within geth. The idea is that I can create formal DB packages, that can be utilized in other projects down the road. * Put PGX and other future Postgres Drivers behind SQL package This PR makes allows users to provide a config, along with a driver string. It will then provide the respective driver. * Add DB Connection and Logging * Utilize LogRus * Create a DB connection using PGX. * Create an internal boot package for starting the application. * Code clean up + Beacon Chain Connection This concludes all the code needed to connect to the DB and beacon node. We will no longer reference the lighthouse client because this application should work interchangeably with any beacon node. I have also standardized logging. * Last second clean ups * Utilize Ginkgo toreplace `testing` library, and add CI/CD. (#9) * Utilize Ginkgo and replace `testing` library. * Add TOC to docs * Add Docker specific files * Remove -e * Update on-pr-manual.yml * Add depth * Add repositories * Remove $ from path * Update path for make * Setup Go and Ginkgo * Use go mod download * Use go install * Update on-pr-manual.yml * Use latest * Remove install of GINKGO * Add explicit gopath * Explicitly specify the gopath * Update on-pr-manual.yml * Update on-pr-manual.yml * Update on-pr-manual.yml * Update on-pr-manual.yml * Update on-pr-manual.yml * Update on-pr-manual.yml * Use which ginkgo * Try with make now * Final working Make
55 lines
1.5 KiB
Go
55 lines
1.5 KiB
Go
package sql
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"time"
|
|
)
|
|
|
|
// Database interfaces required by the sql indexer
|
|
type Database interface {
|
|
Driver
|
|
}
|
|
|
|
// Driver interface has all the methods required by a driver implementation to support the sql indexer
|
|
type Driver interface {
|
|
QueryRow(ctx context.Context, sql string, args ...interface{}) ScannableRow
|
|
Exec(ctx context.Context, sql string, args ...interface{}) (Result, error)
|
|
Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error
|
|
Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error
|
|
Begin(ctx context.Context) (Tx, error)
|
|
Stats() Stats
|
|
Context() context.Context
|
|
io.Closer
|
|
}
|
|
|
|
// Tx interface to accommodate different concrete SQL transaction types
|
|
type Tx interface {
|
|
QueryRow(ctx context.Context, sql string, args ...interface{}) ScannableRow
|
|
Exec(ctx context.Context, sql string, args ...interface{}) (Result, error)
|
|
Commit(ctx context.Context) error
|
|
Rollback(ctx context.Context) error
|
|
}
|
|
|
|
// ScannableRow interface to accommodate different concrete row types
|
|
type ScannableRow interface {
|
|
Scan(dest ...interface{}) error
|
|
}
|
|
|
|
// Result interface to accommodate different concrete result types
|
|
type Result interface {
|
|
RowsAffected() (int64, error)
|
|
}
|
|
|
|
// Stats interface to accommodate different concrete sql stats types
|
|
type Stats interface {
|
|
MaxOpen() int64
|
|
Open() int64
|
|
InUse() int64
|
|
Idle() int64
|
|
WaitCount() int64
|
|
WaitDuration() time.Duration
|
|
MaxIdleClosed() int64
|
|
MaxLifetimeClosed() int64
|
|
}
|