Documentation
¶
Index ¶
- Variables
- func EmptyOrError(err error, errorMessage string) error
- type Connection
- func (c *Connection) BeginContextualTxStatement(ctx context.Context) (context.Context, error)
- func (c *Connection) BeginReadCommittedTxRollbackOnError(ctx context.Context, callback func(txStmtCtx context.Context) error) error
- func (c *Connection) BeginReadUncommittedTxRollbackOnError(ctx context.Context, callback func(txStmtCtx context.Context) error) error
- func (c *Connection) BeginTx() (*sqlx.Tx, error)
- func (c *Connection) BeginTxWithRollbackOnError(ctx context.Context, callback func(txStmtCtx context.Context) error) error
- func (c *Connection) Close() error
- func (c *Connection) CommitContextualTxStatement(ctx context.Context) error
- func (c *Connection) Connect() (*Connection, error)
- func (c *Connection) IsHealed(ctx context.Context) bool
- func (c *Connection) MustWithTransaction(ctx context.Context, fn func(stmt *sqlx.Tx) error) error
- func (c *Connection) RollbackContextualTxStatement(ctx context.Context) error
- func (c *Connection) TryWithTransaction(ctx context.Context, fn func(stmt sqlx.Ext) error) error
- type DbConfig
- type PostgresConfig
- func (c *PostgresConfig) GetDatabaseDSN() string
- func (c *PostgresConfig) GetDbConnectTimeOut() uint16
- func (c *PostgresConfig) GetDbHost() string
- func (c *PostgresConfig) GetDbMaxIdleConns() uint8
- func (c *PostgresConfig) GetDbMaxOpenConns() uint8
- func (c *PostgresConfig) GetDbName() string
- func (c *PostgresConfig) GetDbPassword() string
- func (c *PostgresConfig) GetDbPort() uint16
- func (c *PostgresConfig) GetDbRetryCount() uint8
- func (c *PostgresConfig) GetDbTLSMode() string
- func (c *PostgresConfig) GetDbUser() string
- func (c *PostgresConfig) Prepare() error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUnableGetTransactionFromContext = errors.New("unable get transaction from context") ErrNotInContextualTxStatement = errors.New("unable to commit transaction statement - not in tx statement") )
Functions ¶
func EmptyOrError ¶
Types ¶
type Connection ¶
Connection struct to store and manipulate postgres database connection
func NewConnection ¶
NewConnection to postgres db
func (*Connection) BeginContextualTxStatement ¶
BeginContextualTxStatement ....
func (*Connection) BeginReadCommittedTxRollbackOnError ¶ added in v0.0.5
func (*Connection) BeginReadUncommittedTxRollbackOnError ¶ added in v0.0.5
func (*Connection) BeginTxWithRollbackOnError ¶
func (c *Connection) BeginTxWithRollbackOnError(ctx context.Context, callback func(txStmtCtx context.Context) error, ) error
BeginTxWithRollbackOnError ....
func (*Connection) Close ¶
func (c *Connection) Close() error
func (*Connection) CommitContextualTxStatement ¶
func (c *Connection) CommitContextualTxStatement(ctx context.Context) error
CommitContextualTxStatement ....
func (*Connection) Connect ¶
func (c *Connection) Connect() (*Connection, error)
Connect to postgres database
func (*Connection) IsHealed ¶ added in v0.0.6
func (c *Connection) IsHealed(ctx context.Context) bool
func (*Connection) MustWithTransaction ¶
func (*Connection) RollbackContextualTxStatement ¶
func (c *Connection) RollbackContextualTxStatement(ctx context.Context) error
RollbackContextualTxStatement ....
func (*Connection) TryWithTransaction ¶
type PostgresConfig ¶
type PostgresConfig struct {
DbHost string `envconfig:"POSTGRESQL_SERVICE_HOST"`
DbPort uint16 `envconfig:"POSTGRESQL_SERVICE_PORT"`
DbName string `envconfig:"POSTGRESQL_DATABASE_NAME" secret:"true"`
DbUsername string `envconfig:"POSTGRESQL_USERNAME" secret:"true"`
DbPassword string `envconfig:"POSTGRESQL_PASSWORD" secret:"true"`
DbSSLMode string `envconfig:"POSTGRESQL_SSL_MODE" default:"prefer"`
DbMaxOpenConns uint8 `envconfig:"POSTGRESQL_MAX_OPEN_CONNECTIONS" default:"8"`
DbMaxIdleConns uint8 `envconfig:"POSTGRESQL_MAX_IDLE_CONNECTIONS" default:"8" `
// DbConnectRetryCount is the maximum number of reconnection tries. If 0 - infinite loop
DbConnectRetryCount uint8 `envconfig:"POSTGRESQL_CONNECTION_RETRY_COUNT" default:"0"`
// DbConnectTimeOut is the timeout in millisecond to connect between connection tries
DbConnectTimeOut uint16 `envconfig:"POSTGRESQL_CONNECTION_RETRY_TIMEOUT" default:"5000"`
}
func (*PostgresConfig) GetDatabaseDSN ¶
func (c *PostgresConfig) GetDatabaseDSN() string
func (*PostgresConfig) GetDbConnectTimeOut ¶
func (c *PostgresConfig) GetDbConnectTimeOut() uint16
func (*PostgresConfig) GetDbHost ¶
func (c *PostgresConfig) GetDbHost() string
func (*PostgresConfig) GetDbMaxIdleConns ¶
func (c *PostgresConfig) GetDbMaxIdleConns() uint8
func (*PostgresConfig) GetDbMaxOpenConns ¶
func (c *PostgresConfig) GetDbMaxOpenConns() uint8
func (*PostgresConfig) GetDbName ¶
func (c *PostgresConfig) GetDbName() string
func (*PostgresConfig) GetDbPassword ¶
func (c *PostgresConfig) GetDbPassword() string
func (*PostgresConfig) GetDbPort ¶
func (c *PostgresConfig) GetDbPort() uint16
func (*PostgresConfig) GetDbRetryCount ¶
func (c *PostgresConfig) GetDbRetryCount() uint8
func (*PostgresConfig) GetDbTLSMode ¶
func (c *PostgresConfig) GetDbTLSMode() string
func (*PostgresConfig) GetDbUser ¶
func (c *PostgresConfig) GetDbUser() string
func (*PostgresConfig) Prepare ¶
func (c *PostgresConfig) Prepare() error
Click to show internal directories.
Click to hide internal directories.