Documentation
¶
Index ¶
- Constants
- func IsCodeError() bool
- type Config
- func (c *Config) Config() *gormdb.Config
- func (c *Config) New(cfg *gormdb.Config) (*gormdb.DB, liberr.Error)
- func (c *Config) RegisterContext(fct libctx.FuncContext)
- func (c *Config) RegisterGORMLogger(fct FuncGormLog)
- func (c *Config) RegisterLogger(fct func() liblog.Logger, ignoreRecordNotFoundError bool, ...)
- func (c *Config) Validate() liberr.Error
- type Database
- type Driver
- type FuncGormLog
Constants ¶
View Source
const ( DriverNone = "" DriverMysql = "mysql" DriverPostgreSQL = "psql" DriverSQLite = "sqlite" DriverSQLServer = "sqlserver" DriverClikHouse = "clickhouse" )
View Source
const ( ErrorParamsEmpty errors.CodeError = iota + errors.MinPkgDatabase ErrorDatabaseOpen ErrorDatabaseOpenPool ErrorValidatorError ErrorDatabaseNotInitialized ErrorDatabaseCannotSQLDB ErrorDatabasePing )
Variables ¶
This section is empty.
Functions ¶
func IsCodeError ¶
func IsCodeError() bool
Types ¶
type Config ¶
type Config struct {
// Driver is the driver to use for the DSN. It must be one of mysql, psql, sqlite, sqlserver, clickhouse.
Driver Driver `json:"driver" yaml:"driver" toml:"driver" mapstructure:"driver"`
// Name is a string to identify the instance into status.
Name string `json:"name" yaml:"name" toml:"name" mapstructure:"name"`
// DSN is the string options to connect to database following database engine. See https://gorm.io/docs/connecting_to_the_database.html for more information.
DSN string `json:"dsn" yaml:"dsn" toml:"dsn" mapstructure:"dsn"`
// SkipDefaultTransaction disable the default transaction for single create, update, delete operations.
// This single transactions by default is to ensure database data integrity.
SkipDefaultTransaction bool `` /* 135-byte string literal not displayed */
// FullSaveAssociations full save associations.
FullSaveAssociations bool `` /* 127-byte string literal not displayed */
// DryRun generate sql without execute.
DryRun bool `json:"dry-run" yaml:"dry-run" toml:"dry-run" mapstructure:"dry-run"`
// PrepareStmt executes the given query in cached statement.
PrepareStmt bool `json:"prepare-stmt" yaml:"prepare-stmt" toml:"prepare-stmt" mapstructure:"prepare-stmt"`
// DisableAutomaticPing is used to disable the automatic ping to the database server.
DisableAutomaticPing bool `` /* 127-byte string literal not displayed */
// DisableForeignKeyConstraintWhenMigrating is used to disable the foreign key constraint when migrating the database.
DisableForeignKeyConstraintWhenMigrating bool `` /* 219-byte string literal not displayed */
// DisableNestedTransaction disable nested transaction.
DisableNestedTransaction bool `` /* 143-byte string literal not displayed */
// AllowGlobalUpdate allow global update.
AllowGlobalUpdate bool `json:"allow-global-update" yaml:"allow-global-update" toml:"allow-global-update" mapstructure:"allow-global-update"`
// QueryFields executes the SQL query with all fields of the table.
QueryFields bool `json:"query-fields" yaml:"query-fields" toml:"query-fields" mapstructure:"query-fields"`
// CreateBatchSize default create batch size.
CreateBatchSize int `json:"create-batch-size" yaml:"create-batch-size" toml:"create-batch-size" mapstructure:"create-batch-size"`
// EnableConnectionPool is used to create a connection pool.
EnableConnectionPool bool `` /* 127-byte string literal not displayed */
// PoolMaxIdleConns sets the maximum number of connections idle in the connection pool.
PoolMaxIdleConns int `json:"pool-max-idle-conns" yaml:"pool-max-idle-conns" toml:"pool-max-idle-conns" mapstructure:"pool-max-idle-conns"`
// PoolMaxOpenConns sets the maximum number of connections open in the connection pool.
PoolMaxOpenConns int `json:"pool-max-open-conns" yaml:"pool-max-open-conns" toml:"pool-max-open-conns" mapstructure:"pool-max-open-conns"`
// PoolConnMaxLifetime sets the maximum lifetime of connections in the connection pool.
PoolConnMaxLifetime time.Duration `` /* 127-byte string literal not displayed */
// Disabled allow to disable a database connection without clean his configuration.
Disabled bool `mapstructure:"disabled" json:"disabled" yaml:"disabled" toml:"disabled"`
// Monitor defined the monitoring configuration
Monitor moncfg.Config `mapstructure:"monitor" json:"monitor" yaml:"monitor" toml:"monitor"`
// contains filtered or unexported fields
}
func (*Config) RegisterContext ¶
func (c *Config) RegisterContext(fct libctx.FuncContext)
func (*Config) RegisterGORMLogger ¶
func (c *Config) RegisterGORMLogger(fct FuncGormLog)
func (*Config) RegisterLogger ¶
type Database ¶
type Database interface {
GetDB() *gormdb.DB
SetDb(db *gormdb.DB)
Close()
WaitNotify(ctx context.Context, cancel context.CancelFunc)
CheckConn() liberr.Error
Config() *gormdb.Config
RegisterContext(fct libctx.FuncContext)
RegisterLogger(fct func() liblog.Logger, ignoreRecordNotFoundError bool, slowThreshold time.Duration)
RegisterGORMLogger(fct func() gorlog.Interface)
Monitor(vrs libver.Version) (montps.Monitor, error)
}
type FuncGormLog ¶ added in v1.10.0
Click to show internal directories.
Click to hide internal directories.