Documentation ¶
Index ¶
- type Connection
- type ConnectionConfig
- type DBO
- func (dbo *DBO) Begin() (*SqlTx, error)
- func (dbo *DBO) BeginContext(ctx context.Context) (*SqlTx, error)
- func (dbo *DBO) Exec(query string, args ...interface{}) (sql.Result, error)
- func (dbo *DBO) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (dbo DBO) Init() (*DBO, error)
- func (dbo *DBO) Prepare(query string) (*SqlStmt, error)
- func (dbo *DBO) PrepareContext(ctx context.Context, query string) (*SqlStmt, error)
- func (dbo *DBO) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (dbo *DBO) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (dbo *DBO) QueryRow(query string, args ...interface{}) *sql.Row
- func (dbo *DBO) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- type ILogger
- type IMigrationFile
- type Migration
- type MigrationRegistry
- type Options
- type PostgresConnectionConfig
- type Queryer
- type SqlStmt
- func (st *SqlStmt) Exec(args ...interface{}) (sql.Result, error)
- func (st *SqlStmt) ExecContext(ctx context.Context, args ...interface{}) (sql.Result, error)
- func (st *SqlStmt) Query(args ...interface{}) (*sql.Rows, error)
- func (st *SqlStmt) QueryContext(ctx context.Context, args ...interface{}) (*sql.Rows, error)
- func (st *SqlStmt) QueryRow(args ...interface{}) *sql.Row
- func (st *SqlStmt) QueryRowContext(ctx context.Context, args ...interface{}) *sql.Row
- type SqlTx
- func (tx *SqlTx) Commit() error
- func (tx *SqlTx) Exec(query string, args ...interface{}) (sql.Result, error)
- func (tx *SqlTx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (tx *SqlTx) Prepare(query string) (*SqlStmt, error)
- func (tx *SqlTx) PrepareContext(ctx context.Context, query string) (*SqlStmt, error)
- func (tx *SqlTx) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (tx *SqlTx) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (tx *SqlTx) QueryRow(query string, args ...interface{}) *sql.Row
- func (tx *SqlTx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (tx *SqlTx) Rollback() error
- func (tx *SqlTx) Stmt(stmt *SqlStmt) *SqlStmt
- func (tx *SqlTx) StmtContext(ctx context.Context, stmt *SqlStmt) *SqlStmt
- type Transaction
- type TransactionId
- type TransactionPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface { String() string GetDbType() string GetMaxConnection() int GetConnMaxLifetime() int GetMaxIdleConns() int }
Database Object Connection Interface
type ConnectionConfig ¶
type ConnectionConfig struct { Host string Port int Name string User string Password string MaxConnections int `yaml:"maxConnections"` MaxIdleConnections int `yaml:"maxIdleConnections"` ConnectionIdleLifetime int `yaml:"connectionIdleLifetime"` }
ConnectionConfig Client connection config
func (*ConnectionConfig) GetConnMaxLifetime ¶
func (cc *ConnectionConfig) GetConnMaxLifetime() int
GetConnMaxLifetime Connection idle lifetime
func (*ConnectionConfig) GetMaxConnection ¶
func (cc *ConnectionConfig) GetMaxConnection() int
GetMaxConnection Get Max Connection
func (*ConnectionConfig) GetMaxIdleConns ¶
func (cc *ConnectionConfig) GetMaxIdleConns() int
GetMaxIdleConns Connection max idle connections
type DBO ¶
type DBO struct { *sql.DB Options Connection Connection }
Main Database Object
func (*DBO) BeginContext ¶
BeginContext transaction
func (*DBO) ExecContext ¶
func (dbo *DBO) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
ExecContext SQL run query
func (*DBO) PrepareContext ¶
PrepareContext statement
func (*DBO) QueryContext ¶
func (dbo *DBO) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
QueryContext SQL exec query
type ILogger ¶ added in v2.1.3
type ILogger interface { Output(callDepth int, message string) error Printf(format string, v ...interface{}) Print(v ...interface{}) Println(v ...interface{}) Fatal(v ...interface{}) Fatalf(format string, v ...interface{}) Fatalln(v ...interface{}) Panic(v ...interface{}) Panicf(format string, v ...interface{}) Panicln(v ...interface{}) }
type IMigrationFile ¶
IMigrationFile migration file interface
type Migration ¶
type Migration struct { MigrationPath string DBO *DBO Config ConnectionConfig Registry MigrationRegistry RegistryPath string RegistryXPath string }
Migration struct
func (*Migration) CreateMigrationFile ¶
CreateMigrationFile Create migration file
func (*Migration) GetTemplate ¶
func (*Migration) InitMigration ¶
InitMigration Init migration
type MigrationRegistry ¶
type MigrationRegistry map[string][]IMigrationFile
MigrationRegistry migration registry
type Options ¶
type Options struct { // Debug mode shows logs Debug bool // Logger Logger ILogger // TTL for transaction TransactionTTL time.Duration `yaml:"transactionTTL"` // contains filtered or unexported fields }
Options database object options
type PostgresConnectionConfig ¶
type PostgresConnectionConfig struct { ConnectionConfig `yaml:",inline"` SSLMode string `yaml:"sslMode"` BinaryParameters bool `yaml:"binaryParameters"` }
PostgresConnectionConfig Postgres connection config
func (*PostgresConnectionConfig) GetDbType ¶
func (pcc *PostgresConnectionConfig) GetDbType() string
GetDbType Get database type
func (*PostgresConnectionConfig) String ¶
func (pcc *PostgresConnectionConfig) String() string
To string
type Queryer ¶
type Queryer interface { Exec(query string, args ...interface{}) (sql.Result, error) Prepare(query string) (*SqlStmt, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row }
Queryer interface
type SqlStmt ¶
Stmt
func (*SqlStmt) ExecContext ¶
ExecContext Stmt Exec
func (*SqlStmt) QueryContext ¶
QueryContext Stmt Query
type SqlTx ¶
Transaction
func (*SqlTx) ExecContext ¶
func (tx *SqlTx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
ExecContext Transaction
func (*SqlTx) PrepareContext ¶
PrepareContext Stmt
func (*SqlTx) QueryContext ¶
func (tx *SqlTx) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
QueryContext Transaction
func (*SqlTx) QueryRowContext ¶
QueryRowContext Query Row transaction
type Transaction ¶
type Transaction struct { // Time to live in unix timestampt // 0 - no TTL for transaction TTL int // contains filtered or unexported fields }
Transaction params
type TransactionId ¶
type TransactionId string
TransactionId transaction identifier
func GenTransactionId ¶
func GenTransactionId() TransactionId
GenTransactionId Generate transaction id
type TransactionPool ¶
type TransactionPool struct {
// contains filtered or unexported fields
}
TransactionPool transaction pool
func NewTransactionPool ¶
func NewTransactionPool() *TransactionPool
NewTransactionPool Create transaction pool
func (*TransactionPool) Get ¶
func (p *TransactionPool) Get(id TransactionId) *SqlTx
Get transaction if exists
func (*TransactionPool) Set ¶
func (p *TransactionPool) Set(id TransactionId, tx *SqlTx) *TransactionPool
Set transaction
func (*TransactionPool) UnSet ¶
func (p *TransactionPool) UnSet(id TransactionId) *TransactionPool
UnSet transaction