Documentation
¶
Index ¶
- Constants
- func Register(dbtype string, d Driver)
- func WrapContext(ctx context.Context, tx *gorm.DB) context.Context
- type Driver
- type Manager
- type Option
- func WithConnection(maxOpen int, maxIdle int, maxLifetime time.Duration, maxIdleTime time.Duration, ...) Option
- func WithDataSource(source Source) Option
- func WithLogger(logger log.Logger) Option
- func WithMigration(sqlDir string, version uint) Option
- func WithName(name string) Option
- func WithPlugins(plugins ...gorm.Plugin) Option
- func WithType(dbtype string) Option
- type Source
Constants ¶
const ( SQLite = "sqlite" MySQL = "mysql" Postgres = "postgres" Clickhouse = "clickhouse" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Driver ¶ added in v0.4.7
type Driver struct {
Dialector func(dsn string) gorm.Dialector
Migration func(sqlDB *sql.DB) (database.Driver, error)
DSN func(s Source) (string, error)
Cleanup func(db *gorm.DB, dbName string, schema bool) error
}
Driver is registered from a drivers/* subpackage's init() so the core imports no engine.
type Manager ¶
type Manager interface {
model.Database
// destructive ops, hidden from model.Database holders
model.DatabaseDebugger
// an unreachable server fails Ready, never Alive
common.Liveness
common.Readiness
common.Initializable
common.Debuggable
}
type Option ¶
type Option func(*manager)
func WithConnection ¶
func WithConnection(maxOpen int, maxIdle int, maxLifetime time.Duration, maxIdleTime time.Duration, execTimeout time.Duration) Option
WithConnection sets the defaults of db.connection.max_open, max_idle, max_lifetime, max_idle_time and exec_timeout (built-in: 10, 5, 5m, never, 30s; zero is unset).
func WithDataSource ¶
func WithLogger ¶
func WithMigration ¶
func WithPlugins ¶ added in v0.6.12
WithPlugins appends; plugins are reinstalled in order on every connect.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
drivers
|
|
|
clickhouse
Package clickhouse registers the ClickHouse driver with pkg/services/db; blank-import it.
|
Package clickhouse registers the ClickHouse driver with pkg/services/db; blank-import it. |
|
mysql
Package mysql registers the MySQL driver with pkg/services/db; blank-import it.
|
Package mysql registers the MySQL driver with pkg/services/db; blank-import it. |
|
postgres
Package postgres registers the Postgres driver with pkg/services/db; blank-import it.
|
Package postgres registers the Postgres driver with pkg/services/db; blank-import it. |
|
sqlite
Package sqlite registers the SQLite driver (mattn/go-sqlite3) with pkg/services/db; blank-import it.
|
Package sqlite registers the SQLite driver (mattn/go-sqlite3) with pkg/services/db; blank-import it. |
|
plugins
|
|
|
otelgorm
Package otelgorm traces GORM statements; a separate package because upstream imports the clickhouse, mysql and postgres dialectors.
|
Package otelgorm traces GORM statements; a separate package because upstream imports the clickhouse, mysql and postgres dialectors. |