db

package
v0.0.0-...-ab40c3c Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Master = iota
	Slave  = iota
)

Define connection types

Variables

This section is empty.

Functions

func Open

func Open(ci *Addr) (*sql.DB, error)

Open opens database connection by given address

func OpenService

func OpenService(dbl *Loc, substDB string) (*sql.DB, error)

OpenService resolves db information for database and connects to that db. substDB can be passed to db to different db on the host resolved by database locator

Types

type Addr

type Addr struct {
	Host string
	Port uint16
	User string
	Pwd  string
	Db   string
}

Addr contains information required to db to DB

func GetInfoForTest

func GetInfoForTest(dbl *Loc, tp int) *Addr

GetInfoForTest return address of local MySQL used by tests

func (*Addr) Log

func (a *Addr) Log() log.Logger

type GetInfoFunc

type GetInfoFunc func(*Loc, int) *Addr

GetInfoFunc is a type to implement db address resolver polymorhism

var GetInfo GetInfoFunc // No default resolver

GetInfo is database address resolving function

type Loc

type Loc struct {
	Cluster string
	Service string
	Name    string
}

Loc - database location

func (*Loc) LogFields

func (d *Loc) LogFields() log.Logger

LogFields return logger with Loc fields

Jump to

Keyboard shortcuts

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