conn

package
v0.0.0-...-7b00875 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionManager

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

func CreateConnectionManager

func CreateConnectionManager(
	dsnManager DSNManager,
	ctx context.Context,
) (*ConnectionManager, error)

func (*ConnectionManager) Destroy

func (connManager *ConnectionManager) Destroy()

func (*ConnectionManager) GetConnection

func (connManager *ConnectionManager) GetConnection() (*sqlx.Conn, error)

We try to use a single connection, instantiated when DBClient is instantiated This will either return that existing connection, or create a new one if that got dropped

func (*ConnectionManager) GetFlavor

func (connManager *ConnectionManager) GetFlavor() DBFlavor

func (*ConnectionManager) UseDatabase

func (connManager *ConnectionManager) UseDatabase(databaseName string) error

type DBFlavor

type DBFlavor string

What type of SQL database is connected

const (
	MySQL      DBFlavor = "mysql"
	PostgreSQL DBFlavor = "pgx"
)

type DSNManager

type DSNManager interface {
	GetDSN() (string, error)
	IsSafeMode() bool
	GetFlavor() DBFlavor
	SetDatabase(databaseName string)
}

type DSNOptions

type DSNOptions struct {
	Flavor       DBFlavor
	Host         string
	DatabaseName string
	User         string
	Password     string
	Port         uint
	// Only works in MySQL
	SafeMode          bool
	AdditionalOptions map[string]string
}

func (*DSNOptions) GetDSN

func (connOptions *DSNOptions) GetDSN() (string, error)

func (*DSNOptions) GetFlavor

func (connOptions *DSNOptions) GetFlavor() DBFlavor

func (*DSNOptions) IsSafeMode

func (connOptions *DSNOptions) IsSafeMode() bool

func (*DSNOptions) SetDatabase

func (connOptions *DSNOptions) SetDatabase(databaseName string)

func (*DSNOptions) Validate

func (connOptions *DSNOptions) Validate() error

Jump to

Keyboard shortcuts

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