clmysql

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package clmysql provides modules for interacting with MySQL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(mycfg *mysql.Config, _ Migrater, trp trace.TracerProvider,
	mtp metric.MeterProvider,
) (*sql.DB, error)

New inits a standard sql.DB with optional OTEL tracing and metrics. Any other dependency can optionally be provided as migrated to force it's lifecycle to be run before the database is connected. This is mostly useful to run migration logic (such as initializing the database).

func NewReadOnlyConfig

func NewReadOnlyConfig(cfg Config, logs *zap.Logger) (*mysql.Config, error)

NewReadOnlyConfig constructs a config for a read-only database connecion. The aws config is optional and is only used when IamAuth option is set.

func NewReadWriteConfig

func NewReadWriteConfig(cfg Config, logs *zap.Logger) (*mysql.Config, error)

NewReadWriteConfig constructs a config for a read-write database connecion. The aws config is optional and only used when the IamAuth option is set.

func Provide

func Provide() fx.Option

Provide configures the DI for providng database connectivity.

func TestProvide

func TestProvide() fx.Option

TestProvide configures the DI for a test environment.

Types

type Config

type Config struct {
	// ReadWriteHostname endpoint allows configuration of a endpoint that can read and write
	ReadOnlyDataSourceName string `env:"READ_ONLY_DATA_SOURCE_NAME" envDefault:"root:mysql@tcp(localhost:3306)/mysql"`
	// ReadWriteDataSourceName describes the data-source-name (DSN) for the read-write connection
	ReadWriteDataSourceName string `env:"READ_WRITE_DATA_SOURCE_NAME" envDefault:"root:mysql@tcp(localhost:3306)/mysql"`
}

Config configures the package.

type Migrater

type Migrater interface {
	Migrate(ctx context.Context) error
	Reset(ctx context.Context) error
}

Migrater implements a migtration strategy that can be run before the database connection (pool) is setup.

Directories

Path Synopsis
Package clmymigrate implements the postgres migration logic.
Package clmymigrate implements the postgres migration logic.

Jump to

Keyboard shortcuts

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