mrpostgres

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnAdapter added in v0.3.1

type ConnAdapter struct {
	// contains filtered or unexported fields
}

ConnAdapter - адаптер для работы с Postgres клиентом.

func New

func New() *ConnAdapter

New - создаёт объект ConnAdapter.

func (*ConnAdapter) Cli added in v0.3.1

func (c *ConnAdapter) Cli() (*pgxpool.Pool, error)

Cli - возвращается нативный объект, с которым работает данный адаптер.

func (*ConnAdapter) Close added in v0.3.1

func (c *ConnAdapter) Close() error

Close - закрывает пул соединений.

func (*ConnAdapter) Connect added in v0.3.1

func (c *ConnAdapter) Connect(ctx context.Context, opts Options) error

Connect - создаёт пул соединений с указанными опциями.

func (*ConnAdapter) Exec added in v0.3.1

func (c *ConnAdapter) Exec(ctx context.Context, sql string, args ...any) error

Exec - отправляет SQL запрос к БД и исполняет его.

func (*ConnAdapter) HijackConn added in v0.17.0

func (c *ConnAdapter) HijackConn(ctx context.Context) (*pgx.Conn, error)

HijackConn - извлекает соединение из пула, которое будет использоваться независимо от него и должно быть закрыто тем, кто вызвал данный метод.

func (*ConnAdapter) Ping added in v0.3.1

func (c *ConnAdapter) Ping(ctx context.Context) error

Ping - проверяет работоспособность пула соединений.

func (*ConnAdapter) Query added in v0.3.1

func (c *ConnAdapter) Query(ctx context.Context, sql string, args ...any) (mrstorage.DBQueryRows, error)

Query - отправляет SQL запрос к БД и возвращает результат в виде списка записей.

func (*ConnAdapter) QueryRow added in v0.3.1

func (c *ConnAdapter) QueryRow(ctx context.Context, sql string, args ...any) mrstorage.DBQueryRow

QueryRow - отправляет SQL запрос к БД и возвращает результат в виде одной записи.

type ConnManager added in v0.11.0

type ConnManager struct {
	// contains filtered or unexported fields
}

ConnManager - менеджер транзакций.

func NewConnManager added in v0.11.0

func NewConnManager(conn *ConnAdapter, logger mrlog.Logger) *ConnManager

NewConnManager - создаёт объект ConnManager.

func (*ConnManager) Conn added in v0.11.0

Conn - возвращает соединение с PostgreSQL или транзакцию, если она была открыта.

func (*ConnManager) ConnAdapter added in v0.13.0

func (m *ConnManager) ConnAdapter() *ConnAdapter

ConnAdapter - возвращает соединение с PostgreSQL.

func (*ConnManager) Do added in v0.11.0

func (m *ConnManager) Do(ctx context.Context, job func(ctx context.Context) error) error

Do - запускает задачу с запросом в транзакции. Пытается запустить в текущей транзакции, если ее нет, создает новую транзакцию.

type Options

type Options struct {
	DSN             string // если указано, то Host, Port, Database, Username не используются, но Password более приоритетен если явно указан
	Host            string
	Port            string
	Database        string
	Username        string
	Password        string
	MaxPoolSize     int
	MaxConnLifetime time.Duration
	MaxConnIdleTime time.Duration
	ConnTimeout     time.Duration
	QueryTracer     pgx.QueryTracer
	AfterConnect    func(ctx context.Context, conn *pgx.Conn) error
}

Options - опции для создания соединения для ConnAdapter.

type ProcessWaitForNotification added in v0.17.0

type ProcessWaitForNotification struct {
	ReceiverChannels ReceiverChannels
	// contains filtered or unexported fields
}

ProcessWaitForNotification - объект для прослушивания и обработки событий присылаемых БД.

func NewProcessWaitForNotification added in v0.17.0

func NewProcessWaitForNotification(
	conn *ConnAdapter,
	logger mrlog.Logger,
	channels []string,
) *ProcessWaitForNotification

NewProcessWaitForNotification - создаёт объект ProcessWaitForNotification.

func (*ProcessWaitForNotification) Caption added in v0.17.0

func (p *ProcessWaitForNotification) Caption() string

Caption - comment struct.

func (*ProcessWaitForNotification) ReadyTimeout added in v0.17.0

func (p *ProcessWaitForNotification) ReadyTimeout() time.Duration

ReadyTimeout - comment struct.

func (*ProcessWaitForNotification) Shutdown added in v0.17.0

Shutdown - comment struct.

func (*ProcessWaitForNotification) Start added in v0.17.0

func (p *ProcessWaitForNotification) Start(ctx context.Context, ready func()) error

Start - comment struct.

type ReceiverChannel added in v0.17.0

type ReceiverChannel struct {
	Name    string
	Channel <-chan struct{}
}

ReceiverChannel - comment struct.

type ReceiverChannels added in v0.17.0

type ReceiverChannels []ReceiverChannel

ReceiverChannels - comment array.

func (*ReceiverChannels) Find added in v0.17.0

func (rc *ReceiverChannels) Find(name string) (<-chan struct{}, error)

Find - comment method.

func (*ReceiverChannels) MustFind added in v0.17.0

func (rc *ReceiverChannels) MustFind(name string) <-chan struct{}

MustFind - comment method.

type TxManagerStub added in v0.11.0

type TxManagerStub struct{}

TxManagerStub - фиктивный менеджер транзакций, который запускает только переданную работу без открытия транзакции.

func NewTxManagerStub added in v0.11.0

func NewTxManagerStub() *TxManagerStub

NewTxManagerStub - создаёт объект TxManagerStub.

func (*TxManagerStub) Do added in v0.11.0

func (m *TxManagerStub) Do(ctx context.Context, job func(ctx context.Context) error) error

Do - запускает работу без использования транзакции.

Directories

Path Synopsis
stream

Jump to

Keyboard shortcuts

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