Documentation
¶
Index ¶
- Constants
- func AppendParams(dsn string, params map[string]string, firstSep, sep string) string
- 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 WithType(dbtype string) Option
- type Source
Constants ¶
View Source
const ( SQLite = "sqlite" MySQL = "mysql" Postgres = "postgres" Clickhouse = "clickhouse" )
Variables ¶
This section is empty.
Functions ¶
func AppendParams ¶ added in v0.4.7
AppendParams formats params as key=value pairs joined by sep and prefixed by firstSep, producing a deterministic ordering. Exported so driver subpackages can share the formatting logic.
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 bundles the per-database-engine hooks needed by the manager. Each driver subpackage under pkg/services/db/drivers/* registers a Driver during its init() so the core package never imports concrete GORM or golang-migrate drivers.
type Manager ¶
type Manager interface {
// business
model.Database
// lifecycle
common.Initializable
common.Debuggable
}
type Option ¶
type Option func(*manager)
func WithConnection ¶
func WithDataSource ¶
func WithLogger ¶
func WithMigration ¶
type Source ¶
type Source struct {
Host string
Port uint
User string
Password string `print:"-"`
DBName string
Secure bool
Params map[string]string
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
drivers
|
|
|
clickhouse
Package clickhouse registers the ClickHouse GORM dialector, golang-migrate driver, DSN builder, and cleanup hooks with pkg/services/db.
|
Package clickhouse registers the ClickHouse GORM dialector, golang-migrate driver, DSN builder, and cleanup hooks with pkg/services/db. |
|
mysql
Package mysql registers the MySQL GORM dialector, golang-migrate driver, DSN builder, and cleanup hooks with pkg/services/db.
|
Package mysql registers the MySQL GORM dialector, golang-migrate driver, DSN builder, and cleanup hooks with pkg/services/db. |
|
postgres
Package postgres registers the Postgres GORM dialector, golang-migrate driver, DSN builder, and cleanup hooks with pkg/services/db.
|
Package postgres registers the Postgres GORM dialector, golang-migrate driver, DSN builder, and cleanup hooks with pkg/services/db. |
|
sqlite
Package sqlite registers the SQLite GORM dialector, golang-migrate driver, DSN builder, and cleanup hooks with pkg/services/db.
|
Package sqlite registers the SQLite GORM dialector, golang-migrate driver, DSN builder, and cleanup hooks with pkg/services/db. |
Click to show internal directories.
Click to hide internal directories.