mysql

package
v0.0.0-...-660a5ed Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoEnv           error = errors.New("no env variable provided -- ensure that the environment variables for MYSQL_USER and MYSQL_PASSWORD are set")
	ErrMissingUser     error = errors.New("unset MySQL user variable: please export the MYSQL_USER variable")
	ErrMissingPassword error = errors.New("unset MySQL password variable: please export the MYSQL_PASSWORD variable")
	ErrMissingDatabase error = errors.New("unset MySQL database variable: please export the MYSQL_DATABASE variable")
)

Functions

func New

func New(address, database string) (sqldb io.WriteCloser, err error)

New function will take in a mysql DB address and database name; and create a new instance of a MySQL object; returning an io.WriteCloser and an error.

func WithMySQL

func WithMySQL(addr, database string) log.LoggerConfig

WithMySQL function takes in an address to a MySQL server, and a database name; and returns a LoggerConfig so that this type of writer is defined in a Logger

Types

type MySQL

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

func (*MySQL) Close

func (d *MySQL) Close() error

Close method is implemented for compatibility with the Database interface.

While this ORM doesn't force users to close the connection, MongoDB does, and the method should be available for use

func (*MySQL) Create

func (d *MySQL) Create(msg ...*event.Event) error

Create method will register any number of event.Event in the MySQL database, returning an error

func (*MySQL) Write

func (s *MySQL) Write(p []byte) (n int, err error)

Write method implements the io.Writer interface, for MySQL DBs to be used with Logger, as its writer.

The input message is expected to be a protobuf-marshalled event.Event, which is decoded

Jump to

Keyboard shortcuts

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