pgxs

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MigrationsTable = "public.schema_version"

MigrationsTable is for saving actual schema version

Functions

func QuoteString

func QuoteString(str string) string

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

func (c *Config) GetConnString() string

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 NewPool

func NewPool(ctx context.Context, lg *zap.SugaredLogger, conf *Config) (*Repo, error)

func (*Repo) ConnectDB

func (db *Repo) ConnectDB(ctx context.Context, tlsConfig *tls.Config) (*pgconn.PgConn, error)

func (*Repo) ConnectDBPool added in v1.4.0

func (db *Repo) ConnectDBPool(ctx context.Context, tlsConfig *tls.Config) (*pgxpool.Pool, error)

ConnectDBPool initializes Pool connection

func (*Repo) DebugLogSqlErr added in v0.2.1

func (db *Repo) DebugLogSqlErr(q string, err error) error

handleSqlErr used to avoid not exists and already exists debug queries

func (*Repo) GetConnConfig added in v1.4.0

func (db *Repo) GetConnConfig() (*pgconn.Config, error)

func (*Repo) GetPoolConfig added in v1.4.0

func (db *Repo) GetPoolConfig() (*pgxpool.Config, error)

func (*Repo) GracefulShutdown

func (db *Repo) GracefulShutdown()

func (*Repo) Migrate added in v1.4.0

func (db *Repo) Migrate(ctx context.Context) error

func (*Repo) PoolFromString

func (db *Repo) PoolFromString(ctx context.Context, connString string) (*pgxpool.Pool, error)

func (*Repo) SanitizeString

func (db *Repo) SanitizeString(str string) string

type SSL

type SSL struct {
	Enabled  bool   `json:"enabled" yaml:"enabled"`
	Verify   bool   `json:"verify" yaml:"verify"`
	CaPath   string `json:"ca" yaml:"ca"`
	KeyPath  string `json:"key" yaml:"key"`
	CertPath string `json:"cert" yaml:"cert"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL