pgsqlrepository

package
v0.64.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host            string        `fig:"host"`
	User            string        `fig:"user"`
	Password        string        `fig:"password"`
	Database        string        `fig:"database"`
	SSLMode         string        `fig:"ssl_mode" default:"disable"`
	MaxOpenConns    int           `fig:"max_open_conns"`
	MaxIdleConns    int           `fig:"max_idle_conns"`
	ConnMaxLifetime time.Duration `fig:"conn_max_lifetime"`
	ConnMaxIdleTime time.Duration `fig:"conn_max_idle_time"`
}

Config contains PgSQL configuration value.

type Repository

Repository represents a PgSQL repository implementation.

func New

func New(cfg Config, logger kitlog.Logger) *Repository

New creates and returns an initialized PgSQL Repository instance.

func (*Repository) InTransaction

func (r *Repository) InTransaction(ctx context.Context, f func(ctx context.Context, tx repository.Transaction) error) error

InTransaction generates a PgSQL transaction and completes it after it's being used by f function.

func (*Repository) Start

func (r *Repository) Start(ctx context.Context) error

Start implements Start interface method.

func (*Repository) Stop

func (r *Repository) Stop(_ context.Context) error

Stop closes PgSQL database and prevents new queries from starting.

Jump to

Keyboard shortcuts

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