Documentation ¶
Index ¶
- Constants
- func CreatePostgresDbIfNotExists(ctx context.Context, gormConfig *gorm.Config, pgConfig PostgresConfig) (*gorm.DB, error)
- func CreatePostgresReadOnlyDbConnection(ctx context.Context, gormConfig *gorm.Config, pgConfig PostgresConfig) (*gorm.DB, error)
- func GetDB(ctx context.Context, dbConfig *DbConfig, logConfig *logger.Config) (*gorm.DB, error)
- func GetGormLogger(ctx context.Context, logConfig *logger.Config) gormLogger.Interface
- func GetReadOnlyDB(ctx context.Context, dbConfig *DbConfig, logConfig *logger.Config) (*gorm.DB, error)
- func IsPgErrorWithCode(err error, code string) bool
- func Migrate(ctx context.Context, databaseConfig *DbConfig, ...) error
- func Rollback(ctx context.Context, databaseConfig *DbConfig, ...) error
- type DbConfig
- type PostgresConfig
- type SQLiteConfig
Constants ¶
const PgDuplicatedForeignKey = "23503"
const PgDuplicatedKey = "23505"
const PqDbAlreadyExistsCode = "42P04"
const PqInvalidDBCode = "3D000"
Variables ¶
This section is empty.
Functions ¶
func CreatePostgresDbIfNotExists ¶ added in v1.10.7
func CreatePostgresDbIfNotExists(ctx context.Context, gormConfig *gorm.Config, pgConfig PostgresConfig) (*gorm.DB, error)
CreatePostgresDbIfNotExists creates DB if it doesn't exist for the passed in config
func CreatePostgresReadOnlyDbConnection ¶ added in v1.13.3
func CreatePostgresReadOnlyDbConnection(ctx context.Context, gormConfig *gorm.Config, pgConfig PostgresConfig) (*gorm.DB, error)
CreatePostgresDbConnection creates DB connection and returns the gorm.DB object and error
func GetDB ¶ added in v1.10.7
GetDB uses the dbConfig to create gorm DB object. If the db doesn't exist for the dbConfig then a new one is created using the default db for the provider. eg : postgres has default dbName as postgres
func GetGormLogger ¶
GetGormLogger converts between the flytestdlib configured log level to the equivalent gorm log level and outputs a gorm/logger implementation accordingly configured.
func GetReadOnlyDB ¶ added in v1.13.3
func GetReadOnlyDB(ctx context.Context, dbConfig *DbConfig, logConfig *logger.Config) (*gorm.DB, error)
GetReadOnlyDB uses the dbConfig to create gorm DB object for the read replica passed via the config
func IsPgErrorWithCode ¶ added in v1.10.7
Types ¶
type DbConfig ¶
type DbConfig struct { // deprecated: Please use Postgres.Host DeprecatedHost string `json:"host" pflag:"-,deprecated"` // deprecated: Please use Postgres.Port DeprecatedPort int `json:"port" pflag:"-,deprecated"` // deprecated: Please use Postgres.DbName DeprecatedDbName string `json:"dbname" pflag:"-,deprecated"` // deprecated: Please use Postgres.User DeprecatedUser string `json:"username" pflag:"-,deprecated"` // deprecated: Please use Postgres.Password DeprecatedPassword string `json:"password" pflag:"-,deprecated"` // deprecated: Please use Postgres.PasswordPath DeprecatedPasswordPath string `json:"passwordPath" pflag:"-,deprecated"` // deprecated: Please use Postgres.ExtraOptions DeprecatedExtraOptions string `json:"options" pflag:"-,deprecated"` // deprecated: Please use Postgres.Debug DeprecatedDebug bool `json:"debug" pflag:"-,deprecated"` EnableForeignKeyConstraintWhenMigrating bool `json:"enableForeignKeyConstraintWhenMigrating" pflag:",Whether to enable gorm foreign keys when migrating the db"` MaxIdleConnections int `json:"maxIdleConnections" pflag:",maxIdleConnections sets the maximum number of connections in the idle connection pool."` MaxOpenConnections int `json:"maxOpenConnections" pflag:",maxOpenConnections sets the maximum number of open connections to the database."` ConnMaxLifeTime config.Duration `json:"connMaxLifeTime" pflag:",sets the maximum amount of time a connection may be reused"` Postgres PostgresConfig `json:"postgres,omitempty"` SQLite SQLiteConfig `json:"sqlite,omitempty"` }
DbConfig is used to for initiating the database connection with the store that holds registered entities (e.g. workflows, tasks, launch plans...)
type PostgresConfig ¶
type PostgresConfig struct { Host string `json:"host" pflag:",The host name of the database server"` ReadReplicaHost string `json:"readReplicaHost" pflag:",The host name of the read replica database server"` Port int `json:"port" pflag:",The port name of the database server"` DbName string `json:"dbname" pflag:",The database name"` User string `json:"username" pflag:",The database user who is connecting to the server."` // Either Password or PasswordPath must be set. Password string `json:"password" pflag:",The database password."` PasswordPath string `json:"passwordPath" pflag:",Points to the file containing the database password."` ExtraOptions string `` /* 135-byte string literal not displayed */ Debug bool `json:"debug" pflag:" Whether or not to start the database connection with debug mode enabled."` }
PostgresConfig includes specific config options for opening a connection to a postgres database.
func (PostgresConfig) IsEmpty ¶
func (s PostgresConfig) IsEmpty() bool
type SQLiteConfig ¶
type SQLiteConfig struct {
File string `` /* 167-byte string literal not displayed */
}
SQLiteConfig can be used to configure
func (SQLiteConfig) IsEmpty ¶
func (s SQLiteConfig) IsEmpty() bool