db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCannotAppendCert = errors.New("/src/internal/db: AppendCertsFromPEM() failed")
	ErrIncompleteConf   = errors.New("/src/internal/db: configuration isn't complete")
	ErrMySQLNoConn      = errors.New("/src/internal/db: cannot establish mysql connection")
)

Functions

This section is empty.

Types

type DatabaseConfig

type DatabaseConfig struct {
	// Mandatory Connection Info
	Host     string `yaml:"host"` // For IPv6, use the format of [::]
	Port     uint16 `yaml:"port"`
	Database string `yaml:"database"`
	User     string `yaml:"user"`
	Passwd   string `yaml:"passwd"`

	// Optional Connection Info
	CA         string `yaml:"ca_cert"`     // Required by ClientKey & ClientCert
	ClientKey  string `yaml:"client_key"`  // Required by ClientCert
	ClientCert string `yaml:"client_cert"` // Required by ClientKey

	// Other MySQL Info
	MysqlAutoCommit bool `yaml:"auto_commit"`

	// Table Prefix
	TblPrefix string `yaml:"table_prefix"` // If unset, use default: "ulys_".
}

type MysqlConnector

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

MysqlConnect is a STATELESS struct used to generate new MySQL connections

func NewMysqlConnector

func NewMysqlConnector(conf DatabaseConfig) *MysqlConnector

NewMysqlConnector returns a valid pointer to a MysqlConnector struct when conf is valid (able to establish mysql connections)

func (*MysqlConnector) Conn

func (mc *MysqlConnector) Conn() (*sql.DB, error)

Conn() creates the *sql.DB using the DatabaseConfig stored in current MysqlConnector

Jump to

Keyboard shortcuts

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