Documentation
¶
Index ¶
- Variables
- func QuoteString(str string) string
- type Config
- type ErrorLineExtract
- type Repo
- func (db *Repo) ConnectDB(ctx context.Context, tlsConfig *tls.Config) (*pgconn.PgConn, error)
- func (db *Repo) ConnectDBPool(ctx context.Context, tlsConfig *tls.Config) (*pgxpool.Pool, error)
- func (db *Repo) DebugLogSqlErr(q string, err error) error
- func (db *Repo) GetConnConfig() (*pgconn.Config, error)
- func (db *Repo) GetPoolConfig() (*pgxpool.Config, error)
- func (db *Repo) GracefulShutdown()
- func (db *Repo) Migrate(ctx context.Context) error
- func (db *Repo) PoolFromString(ctx context.Context, connString string) (*pgxpool.Pool, error)
- func (db *Repo) SanitizeString(str string) string
- type SSL
Constants ¶
This section is empty.
Variables ¶
View Source
var MigrationsTable = "public.schema_version"
MigrationsTable is for saving actual schema version
Functions ¶
func QuoteString ¶
according to https://github.com/jackc/pgx/blob/master/conn.go#L84 have to watch changes, to prevent internal issues
Types ¶
type Config ¶ added in v0.6.0
type Config struct {
DbUri string `json:"db_uri" yaml:"db_uri"`
MigrationsPath string `json:"migration_schemas" yaml:"migration_schemas"`
DataDir string `json:"data_dir" yaml:"data_dir"`
Host string `json:"host" yaml:"host"`
Port string `json:"port" yaml:"port"`
Name string `json:"name" yaml:"name"`
User string `json:"user" yaml:"user"`
Password string `json:"password" yaml:"password"`
SslMode string `json:"ssl_mode" yaml:"ssl_mode"`
TLS SSL `json:"tls" yaml:"tls"`
TLSConfig *tls.Config `json:"-" yaml:"-"`
}
func (*Config) GetConnString ¶ added in v1.4.0
type ErrorLineExtract ¶ added in v1.4.0
type ErrorLineExtract struct {
LineNum int // Line number starting with 1
ColumnNum int // Column number starting with 1
Text string // Text of the line without a new line character.
}
referred to original: https://github.com/jackc/tern/blob/master/error_line_extract.go
func ExtractErrorLine ¶ added in v1.4.0
func ExtractErrorLine(source string, position int) (ErrorLineExtract, error)
ExtractErrorLine takes source and character position extracts the line number, column number, and the line of text.
The first character is position 1.
type Repo ¶
type Repo struct {
Logger *zap.SugaredLogger `json:"-" yaml:"-"`
Pool *pgxpool.Pool `json:"-" yaml:"-"`
Config *Config `json:"-" yaml:"-"`
}
func (*Repo) ConnectDBPool ¶ added in v1.4.0
ConnectDBPool initializes Pool connection
func (*Repo) DebugLogSqlErr ¶ added in v0.2.1
handleSqlErr used to avoid not exists and already exists debug queries
func (*Repo) GetConnConfig ¶ added in v1.4.0
func (*Repo) GetPoolConfig ¶ added in v1.4.0
func (*Repo) GracefulShutdown ¶
func (db *Repo) GracefulShutdown()
func (*Repo) PoolFromString ¶
func (*Repo) SanitizeString ¶
Click to show internal directories.
Click to hide internal directories.