mysql

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultMaxConns     = 100
	DefaultMaxIdleConns = 10
)

Default values for Mysql.

Variables

View Source
var File_pkg_database_mysql_mysql_proto protoreflect.FileDescriptor

Functions

func CloseDB added in v0.0.14

func CloseDB() error

func CloseTheDB added in v0.0.14

func CloseTheDB(conf DBConfig) error

func GetDB added in v0.0.14

func GetDB() *sqlx.DB

func GetTheDB added in v0.0.14

func GetTheDB(conf DBConfig) (*sqlx.DB, error)

Types

type CompletedConfig added in v0.0.32

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

func (CompletedConfig) New added in v0.0.32

func (c CompletedConfig) New() (*sqlx.DB, error)

type Config added in v0.0.32

type Config struct {
	Proto Mysql
	// contains filtered or unexported fields
}

func NewConfig added in v0.0.32

func NewConfig(options ...ConfigOption) *Config

func (*Config) ApplyOptions added in v0.0.32

func (o *Config) ApplyOptions(options ...ConfigOption) *Config

func (*Config) Complete added in v0.0.32

func (c *Config) Complete() CompletedConfig

Complete set default ServerRunOptions.

type ConfigOption added in v0.0.32

type ConfigOption interface {
	// contains filtered or unexported methods
}

A ConfigOption sets options.

func WithViper added in v0.0.32

func WithViper(v *viper.Viper) ConfigOption

type ConfigOptionFunc added in v0.0.32

type ConfigOptionFunc func(*Config)

ConfigOptionFunc wraps a function that modifies Client into an implementation of the ConfigOption interface.

type DB

type DB struct {
	//DSN        string
	Conf DBConfig
	// contains filtered or unexported fields
}

func NewDB

func NewDB(conf DBConfig, opts ...DBOption) *DB

func (*DB) ApplyOptions

func (o *DB) ApplyOptions(options ...DBOption) *DB

func (*DB) Close added in v0.0.14

func (d *DB) Close() error

func (*DB) GetDatabase

func (d *DB) GetDatabase() (*sqlx.DB, error)

func (*DB) GetDatabaseUntil

func (d *DB) GetDatabaseUntil(maxWaitInterval time.Duration, failAfter time.Duration) (*sqlx.DB, error)

type DBConfig

type DBConfig struct {
	Address  string
	DataName string
	UserName string
	Password string
}

type DBOption

type DBOption interface {
	// contains filtered or unexported methods
}

A DBOption sets options.

func WithConnMaxLifetime added in v0.0.32

func WithConnMaxLifetime(connMaxLifetime time.Duration) DBOption

func WithDialTimeout added in v0.0.32

func WithDialTimeout(dialTimeout time.Duration) DBOption

func WithMaxConnections added in v0.0.32

func WithMaxConnections(maxConns int) DBOption

func WithMaxIdleConnections added in v0.0.32

func WithMaxIdleConnections(maxIdleConns int) DBOption

func WithReadTimeout added in v0.0.32

func WithReadTimeout(readTimeout time.Duration) DBOption

func WithWriteTimeout added in v0.0.32

func WithWriteTimeout(writeTimeout time.Duration) DBOption

type DBOptionFunc

type DBOptionFunc func(*DB)

DBOptionFunc wraps a function that modifies DB into an implementation of the DBOption interface.

type EmptyConfigOption added in v0.0.32

type EmptyConfigOption struct{}

EmptyConfigOption does not alter the configuration. It can be embedded in another structure to build custom options.

This API is EXPERIMENTAL.

type EmptyDBOption

type EmptyDBOption struct{}

EmptyDBUrlOption does not alter the DBuration. It can be embedded in another structure to build custom options.

This API is EXPERIMENTAL.

type Mysql added in v0.0.32

type Mysql struct {
	Enabled            bool               `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"`
	Address            string             `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
	Username           string             `protobuf:"bytes,3,opt,name=username,proto3" json:"username,omitempty"`
	Password           string             `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"`
	DbName             string             `protobuf:"bytes,5,opt,name=db_name,json=dbName,proto3" json:"db_name,omitempty"`
	MaxConnections     int32              `protobuf:"varint,6,opt,name=max_connections,json=maxConnections,proto3" json:"max_connections,omitempty"`
	MaxIdleConnections int32              `protobuf:"varint,7,opt,name=max_idle_connections,json=maxIdleConnections,proto3" json:"max_idle_connections,omitempty"`
	DialTimeout        *duration.Duration `protobuf:"bytes,8,opt,name=dial_timeout,json=dialTimeout,proto3" json:"dial_timeout,omitempty"`
	ReadTimeout        *duration.Duration `protobuf:"bytes,9,opt,name=read_timeout,json=readTimeout,proto3" json:"read_timeout,omitempty"`
	// https://github.com/go-sql-driver/mysql#writetimeout
	WriteTimeout      *duration.Duration `protobuf:"bytes,10,opt,name=write_timeout,json=writeTimeout,proto3" json:"write_timeout,omitempty"`
	MaxLifeTime       *duration.Duration `protobuf:"bytes,11,opt,name=max_life_time,json=maxLifeTime,proto3" json:"max_life_time,omitempty"`
	MaxWaitDuration   *duration.Duration `protobuf:"bytes,12,opt,name=max_wait_duration,json=maxWaitDuration,proto3" json:"max_wait_duration,omitempty"`
	FailAfterDuration *duration.Duration `protobuf:"bytes,13,opt,name=fail_after_duration,json=failAfterDuration,proto3" json:"fail_after_duration,omitempty"`
	// contains filtered or unexported fields
}

func (*Mysql) Descriptor deprecated added in v0.0.32

func (*Mysql) Descriptor() ([]byte, []int)

Deprecated: Use Mysql.ProtoReflect.Descriptor instead.

func (*Mysql) GetAddress added in v0.0.32

func (x *Mysql) GetAddress() string

func (*Mysql) GetDbName added in v0.0.32

func (x *Mysql) GetDbName() string

func (*Mysql) GetDialTimeout added in v0.0.32

func (x *Mysql) GetDialTimeout() *duration.Duration

func (*Mysql) GetEnabled added in v0.0.32

func (x *Mysql) GetEnabled() bool

func (*Mysql) GetFailAfterDuration added in v0.0.32

func (x *Mysql) GetFailAfterDuration() *duration.Duration

func (*Mysql) GetMaxConnections added in v0.0.32

func (x *Mysql) GetMaxConnections() int32

func (*Mysql) GetMaxIdleConnections added in v0.0.32

func (x *Mysql) GetMaxIdleConnections() int32

func (*Mysql) GetMaxLifeTime added in v0.0.32

func (x *Mysql) GetMaxLifeTime() *duration.Duration

func (*Mysql) GetMaxWaitDuration added in v0.0.32

func (x *Mysql) GetMaxWaitDuration() *duration.Duration

func (*Mysql) GetPassword added in v0.0.32

func (x *Mysql) GetPassword() string

func (*Mysql) GetReadTimeout added in v0.0.32

func (x *Mysql) GetReadTimeout() *duration.Duration

func (*Mysql) GetUsername added in v0.0.32

func (x *Mysql) GetUsername() string

func (*Mysql) GetWriteTimeout added in v0.0.32

func (x *Mysql) GetWriteTimeout() *duration.Duration

func (*Mysql) ProtoMessage added in v0.0.32

func (*Mysql) ProtoMessage()

func (*Mysql) ProtoReflect added in v0.0.32

func (x *Mysql) ProtoReflect() protoreflect.Message

func (*Mysql) Reset added in v0.0.32

func (x *Mysql) Reset()

func (*Mysql) String added in v0.0.32

func (x *Mysql) String() string

type SQLDB added in v0.0.14

type SQLDB atomic.Value

func (*SQLDB) Load added in v0.0.14

func (m *SQLDB) Load() *sqlx.DB

func (*SQLDB) Store added in v0.0.14

func (m *SQLDB) Store(value *sqlx.DB)

Jump to

Keyboard shortcuts

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