Documentation ¶
Index ¶
- func MigrateDown(db *sql.DB, log logrus.FieldLogger) error
- func MigrateUp(db *sql.DB, log logrus.FieldLogger) error
- func NewDBHandle(dc DatabaseCredentials, logMode bool, log logrus.FieldLogger) (*gorm.DB, error)
- func NewFromGormString(connStr string, logMode bool, log logrus.FieldLogger) (*gorm.DB, error)
- type DatabaseCredentials
- type DatabaseInstance
- type TransactionManager
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MigrateDown ¶
func MigrateDown(db *sql.DB, log logrus.FieldLogger) error
MigrateDown run sql-migrate migrations
func MigrateUp ¶
func MigrateUp(db *sql.DB, log logrus.FieldLogger) error
MigrateUp run sql-migrate migrations
func NewDBHandle ¶
func NewDBHandle(dc DatabaseCredentials, logMode bool, log logrus.FieldLogger) (*gorm.DB, error)
NewDBHandle provides the database handle to its callers
func NewFromGormString ¶
NewFromGormString creates a gorm db handler from a connection string
Types ¶
type DatabaseCredentials ¶
type DatabaseCredentials struct { Readers []DatabaseInstance `json:"readers"` Writers []DatabaseInstance `json:"writers"` Database string `json:"database"` Password string `json:"password"` User string `json:"user"` Type string `json:"type"` }
DatabaseCredentials credentials
func (*DatabaseCredentials) GetRO ¶
func (dc *DatabaseCredentials) GetRO() (string, error)
GetRO get a read only database
func (*DatabaseCredentials) GetRW ¶
func (dc *DatabaseCredentials) GetRW() (string, error)
GetRW get a read/write database
type DatabaseInstance ¶
type DatabaseInstance struct { Port int `json:"port"` Host string `json:"host"` Ssl string `json:"sslmode"` }
DatabaseInstance host and port
type TransactionManager ¶
type TransactionManager interface { DB() *gorm.DB Transaction(func(*gorm.DB) error, logrus.FieldLogger) error }
TransactionManager allows to control a DB transaction
func NewTransactionManager ¶
func NewTransactionManager(db *gorm.DB) TransactionManager
NewTransactionManager returns a new TransactionManager
Click to show internal directories.
Click to hide internal directories.