postgresenv

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BeforeConnectHook

type BeforeConnectHook func(ctx context.Context, cfg *pgxpool.Config) error

type CloseHook

type CloseHook func() error

type Connector

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

func NewConnector

func NewConnector(opts ...ConnectorOption) *Connector

func (*Connector) Close

func (c *Connector) Close() error

func (*Connector) Config

func (c *Connector) Config() (*pgxpool.Config, error)

func (*Connector) Connect

func (c *Connector) Connect(ctx context.Context, cfg *pgxpool.Config) (*pgxpool.Pool, error)

func (*Connector) ConnectToServicePool

func (c *Connector) ConnectToServicePool(
	ctx context.Context,
	env *Environment,
	cfg *pgxpool.Config,
) (*pgxpool.Pool, error)

type ConnectorOption

type ConnectorOption func(*Connector)

func WithBeforeConnectHook

func WithBeforeConnectHook(hook BeforeConnectHook) ConnectorOption

func WithCloseHook

func WithCloseHook(hook CloseHook) ConnectorOption

func WithDatabase

func WithDatabase(databaseName string) ConnectorOption

func WithHost

func WithHost(host string) ConnectorOption

func WithPassword

func WithPassword(password string) ConnectorOption

func WithPort

func WithPort(port uint16) ConnectorOption

func WithSchema

func WithSchema(schema string) ConnectorOption

func WithTLSConfig

func WithTLSConfig(tlsConfig *tls.Config) ConnectorOption

func WithUser

func WithUser(user string) ConnectorOption

type Environment

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

func New

func New(opts ...EnvironmentOption) *Environment

func (*Environment) Connect

func (e *Environment) Connect(ctx context.Context) (*Pool, error)

type EnvironmentOption

type EnvironmentOption func(*Environment)

func WithConnectorReuseOptions

func WithConnectorReuseOptions(
	createFunc func() (*Connector, error),
	opts ...reuse.Option[*Connector],
) EnvironmentOption

func WithMaxConnsPerConnect

func WithMaxConnsPerConnect(maxConnPerConnect int32) EnvironmentOption

func WithReuseStrategy

func WithReuseStrategy(strategy ReuseStrategy) EnvironmentOption

type Pool

type Pool struct {
	Pool *pgxpool.Pool
	// contains filtered or unexported fields
}

func (*Pool) Close

func (p *Pool) Close()

type ReuseStrategy

type ReuseStrategy interface {
	// contains filtered or unexported methods
}

type ReuseStrategyCreateNewDB

type ReuseStrategyCreateNewDB struct {
	NewDBName func() string
}

type ReuseStrategyCreateNewSchema

type ReuseStrategyCreateNewSchema struct {
	DB            string
	NewSchemaName func() string
}

type StdlibEnvironment

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

func NewStdlib

func NewStdlib(
	env *Environment,
	opts ...stdlib.OptionOpenDB,
) *StdlibEnvironment

func (*StdlibEnvironment) Connect

func (d *StdlibEnvironment) Connect(ctx context.Context) (*sql.DB, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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