Documentation ¶
Index ¶
- Constants
- Variables
- func CloseDB() error
- func CloseTheDB(conf DBConfig) error
- func GetDB() *sqlx.DB
- func GetTheDB(conf DBConfig) (*sqlx.DB, error)
- type CompletedConfig
- type Config
- type ConfigOption
- type ConfigOptionFunc
- type DB
- type DBConfig
- type DBOption
- func WithConnMaxLifetime(connMaxLifetime time.Duration) DBOption
- func WithDialTimeout(dialTimeout time.Duration) DBOption
- func WithMaxConnections(maxConns int) DBOption
- func WithMaxIdleConnections(maxIdleConns int) DBOption
- func WithReadTimeout(readTimeout time.Duration) DBOption
- func WithWriteTimeout(writeTimeout time.Duration) DBOption
- type DBOptionFunc
- type EmptyConfigOption
- type EmptyDBOption
- type Mysql
- func (*Mysql) Descriptor() ([]byte, []int)deprecated
- func (x *Mysql) GetAddress() string
- func (x *Mysql) GetDbName() string
- func (x *Mysql) GetDialTimeout() *duration.Duration
- func (x *Mysql) GetEnabled() bool
- func (x *Mysql) GetFailAfterDuration() *duration.Duration
- func (x *Mysql) GetMaxConnections() int32
- func (x *Mysql) GetMaxIdleConnections() int32
- func (x *Mysql) GetMaxLifeTime() *duration.Duration
- func (x *Mysql) GetMaxWaitDuration() *duration.Duration
- func (x *Mysql) GetPassword() string
- func (x *Mysql) GetReadTimeout() *duration.Duration
- func (x *Mysql) GetUsername() string
- func (x *Mysql) GetWriteTimeout() *duration.Duration
- func (*Mysql) ProtoMessage()
- func (x *Mysql) ProtoReflect() protoreflect.Message
- func (x *Mysql) Reset()
- func (x *Mysql) String() string
- type SQLDB
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 CloseTheDB ¶ added in v0.0.14
Types ¶
type CompletedConfig ¶ added in v0.0.32
type CompletedConfig struct {
// contains filtered or unexported fields
}
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 (*DB) ApplyOptions ¶
type DBOption ¶
type DBOption interface {
// contains filtered or unexported methods
}
A DBOption sets options.
func WithConnMaxLifetime ¶ added in v0.0.32
func WithDialTimeout ¶ added in v0.0.32
func WithMaxConnections ¶ added in v0.0.32
func WithMaxIdleConnections ¶ added in v0.0.32
func WithReadTimeout ¶ added in v0.0.32
func WithWriteTimeout ¶ added in v0.0.32
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) GetAddress ¶ added in v0.0.32
func (*Mysql) GetDialTimeout ¶ added in v0.0.32
func (*Mysql) GetEnabled ¶ added in v0.0.32
func (*Mysql) GetFailAfterDuration ¶ added in v0.0.32
func (*Mysql) GetMaxConnections ¶ added in v0.0.32
func (*Mysql) GetMaxIdleConnections ¶ added in v0.0.32
func (*Mysql) GetMaxLifeTime ¶ added in v0.0.32
func (*Mysql) GetMaxWaitDuration ¶ added in v0.0.32
func (*Mysql) GetPassword ¶ added in v0.0.32
func (*Mysql) GetReadTimeout ¶ added in v0.0.32
func (*Mysql) GetUsername ¶ added in v0.0.32
func (*Mysql) GetWriteTimeout ¶ added in v0.0.32
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
Click to show internal directories.
Click to hide internal directories.