Documentation
¶
Index ¶
- Constants
- func Aggregate(driver *Driver, query string, args ...interface{}) (result interface{}, err error, closeErr error)
- func AggregateFloat(driver *Driver, query string, args ...interface{}) (result float64, err error, closeErr error)
- func AggregateInt(driver *Driver, query string, args ...interface{}) (result int64, err error, closeErr error)
- func CheckMode(num int) error
- func DsnJoiner(s *Schema) string
- func DsnPath(s *Schema) string
- func DsnQuery(s *Schema) string
- func Exec(driver *Driver, query string, args ...interface{}) (sql.Result, error)
- func Find(driver *Driver, query string, args ...interface{}) (result []map[string]interface{}, err error, closeErr error)
- func First(driver *Driver, query string, args ...interface{}) (result map[string]interface{}, err error, closeErr error)
- func IsBackup(mode int) bool
- func IsEmptyResult(err error) bool
- func IsMode(num int) bool
- func IsRead(mode int) bool
- func IsWrite(mode int) bool
- func NewEmptyResult() error
- func Scan(rows *sql.Rows) ([]map[string]interface{}, error)
- func ScanFirst(rows *sql.Rows) (map[string]interface{}, error)
- func ShardingJoiner(database string, num int) string
- type Driver
- type DriverBuilder
- type Drivers
- func (x *Drivers) Close() []error
- func (x *Drivers) GetBackup() (*Driver, error)
- func (x *Drivers) GetBackups() []*Driver
- func (x *Drivers) GetId() string
- func (x *Drivers) GetReader() (*Driver, error)
- func (x *Drivers) GetReaders() []*Driver
- func (x *Drivers) GetWriter() (*Driver, error)
- func (x *Drivers) GetWriters() []*Driver
- type DriversBuilder
- func (x *DriversBuilder) AddBackup(s *Schema) error
- func (x *DriversBuilder) AddProfile(p *Profile) error
- func (x *DriversBuilder) AddReader(s *Schema) error
- func (x *DriversBuilder) AddSchema(s *Schema, write bool, read bool, backup bool) error
- func (x *DriversBuilder) AddWriter(s *Schema) error
- func (x *DriversBuilder) Build() (*Drivers, error)
- func (x *DriversBuilder) SetDsnJoiner(f func(s *Schema) string) *DriversBuilder
- func (x *DriversBuilder) SetId(s string) error
- func (x *DriversBuilder) SetName(s string) error
- type Profile
- func (x *Profile) GetBackup() bool
- func (x *Profile) GetCharset() string
- func (x *Profile) GetCollation() string
- func (x *Profile) GetDatabase() string
- func (x *Profile) GetDriver() string
- func (x *Profile) GetDsn() string
- func (x *Profile) GetHost() string
- func (x *Profile) GetId() string
- func (x *Profile) GetMaxIdle() int
- func (x *Profile) GetMaxLifetime() time.Duration
- func (x *Profile) GetMaxOpen() int
- func (x *Profile) GetPassword() string
- func (x *Profile) GetPort() int
- func (x *Profile) GetProto() string
- func (x *Profile) GetRead() bool
- func (x *Profile) GetShardingFirst() int
- func (x *Profile) GetShardingLast() int
- func (x *Profile) GetShardingSeparator() string
- func (x *Profile) GetTimeout() string
- func (x *Profile) GetUsername() string
- func (x *Profile) GetWrite() bool
- type Schema
- func (x *Schema) GetCharset() string
- func (x *Schema) GetCollation() string
- func (x *Schema) GetDatabase() string
- func (x *Schema) GetDsn() string
- func (x *Schema) GetHost() string
- func (x *Schema) GetMaxIdle() int
- func (x *Schema) GetMaxLifetime() time.Duration
- func (x *Schema) GetMaxOpen() int
- func (x *Schema) GetPassword() string
- func (x *Schema) GetPort() int
- func (x *Schema) GetProto() string
- func (x *Schema) GetTimeout() string
- func (x *Schema) GetUsername() string
- func (x *Schema) ToString() string
- type SchemaBuilder
- func (x *SchemaBuilder) Build() (*Schema, error)
- func (x *SchemaBuilder) SetCharset(s string) *SchemaBuilder
- func (x *SchemaBuilder) SetCollation(s string) *SchemaBuilder
- func (x *SchemaBuilder) SetDatabase(s string) *SchemaBuilder
- func (x *SchemaBuilder) SetDsn(s string) *SchemaBuilder
- func (x *SchemaBuilder) SetHost(s string) *SchemaBuilder
- func (x *SchemaBuilder) SetMaxIdle(n int) *SchemaBuilder
- func (x *SchemaBuilder) SetMaxLifetime(d time.Duration) *SchemaBuilder
- func (x *SchemaBuilder) SetMaxOpen(n int) *SchemaBuilder
- func (x *SchemaBuilder) SetPassword(s string) *SchemaBuilder
- func (x *SchemaBuilder) SetPort(p int) *SchemaBuilder
- func (x *SchemaBuilder) SetProto(s string) *SchemaBuilder
- func (x *SchemaBuilder) SetTimeout(s string) *SchemaBuilder
- func (x *SchemaBuilder) SetUsername(s string) *SchemaBuilder
- type Sharding
- type ShardingBuilder
- func (x *ShardingBuilder) AddProfile(p *Profile) error
- func (x *ShardingBuilder) Build() (*Sharding, error)
- func (x *ShardingBuilder) SetDsnJoiner(f func(s *Schema) string) *ShardingBuilder
- func (x *ShardingBuilder) SetId(s string) error
- func (x *ShardingBuilder) SetName(s string) error
- func (x *ShardingBuilder) SetSchema(num int, s *Schema) error
- func (x *ShardingBuilder) SetShardingJoiner(f func(database string, num int) string) *ShardingBuilder
Constants ¶
View Source
const ( Charset = "utf8mb4" Collation = "utf8mb4_general_ci" Proto = "tcp" Port = 3306 Write = 1 // 主库,写库 Read = 2 // 从库,只读库 Backup = 4 // 备库,复杂查询 EmptyResult = "empty result" // 查询结果空 AggregateAlias = "aggregate" // 统计字段别名 ShardingSeparator = "_" // 拼接库名和分库数 )
View Source
const ( ProfileId = "id" ProfileShardingFirst = "sharding_first" ProfileShardingLast = "sharding_last" ProfileShardingSeparator = "sharding_separator" ProfileWrite = "write" ProfileRead = "read" ProfileBackup = "backup" ProfileHost = "host" ProfileUsername = "username" ProfilePassword = "password" ProfileDriver = "driver" ProfileProto = "proto" ProfilePort = "port" ProfileDatabase = "database" ProfileCharset = "charset" ProfileCollation = "collation" ProfileTimeout = "timeout" ProfileMaxOpen = "max_open" ProfileMaxIdle = "max_idle" ProfileMaxLifetime = "max_lifetime" ProfileDsn = "dsn" )
Variables ¶
This section is empty.
Functions ¶
func Aggregate ¶
func Aggregate(driver *Driver, query string, args ...interface{}) (result interface{}, err error, closeErr error)
"AS 'aggregate'" must be contained in Query
func AggregateFloat ¶
func AggregateFloat(driver *Driver, query string, args ...interface{}) (result float64, err error, closeErr error)
"AS 'aggregate'" must be contained in Query
func AggregateInt ¶
func AggregateInt(driver *Driver, query string, args ...interface{}) (result int64, err error, closeErr error)
"AS 'aggregate'" must be contained in Query
func IsEmptyResult ¶
func NewEmptyResult ¶
func NewEmptyResult() error
func ShardingJoiner ¶
Types ¶
type DriverBuilder ¶
type DriverBuilder struct {
// contains filtered or unexported fields
}
func (*DriverBuilder) Build ¶
func (x *DriverBuilder) Build() (*Driver, error)
func (*DriverBuilder) SetJoiner ¶
func (x *DriverBuilder) SetJoiner(f func(s *Schema) string) *DriverBuilder
func (*DriverBuilder) SetName ¶
func (x *DriverBuilder) SetName(s string) *DriverBuilder
func (*DriverBuilder) SetSchema ¶
func (x *DriverBuilder) SetSchema(s *Schema) *DriverBuilder
type Drivers ¶
type Drivers struct {
// contains filtered or unexported fields
}
func (*Drivers) GetBackups ¶
func (*Drivers) GetReaders ¶
func (*Drivers) GetWriters ¶
type DriversBuilder ¶
type DriversBuilder struct {
// contains filtered or unexported fields
}
func (*DriversBuilder) AddBackup ¶
func (x *DriversBuilder) AddBackup(s *Schema) error
func (*DriversBuilder) AddProfile ¶
func (x *DriversBuilder) AddProfile(p *Profile) error
func (*DriversBuilder) AddReader ¶
func (x *DriversBuilder) AddReader(s *Schema) error
func (*DriversBuilder) AddWriter ¶
func (x *DriversBuilder) AddWriter(s *Schema) error
func (*DriversBuilder) Build ¶
func (x *DriversBuilder) Build() (*Drivers, error)
func (*DriversBuilder) SetDsnJoiner ¶
func (x *DriversBuilder) SetDsnJoiner(f func(s *Schema) string) *DriversBuilder
func (*DriversBuilder) SetId ¶
func (x *DriversBuilder) SetId(s string) error
func (*DriversBuilder) SetName ¶
func (x *DriversBuilder) SetName(s string) error
type Profile ¶
type Profile struct {
// contains filtered or unexported fields
}
func (*Profile) GetCharset ¶
func (*Profile) GetCollation ¶
func (*Profile) GetDatabase ¶
func (*Profile) GetMaxIdle ¶
func (*Profile) GetMaxLifetime ¶
func (*Profile) GetMaxOpen ¶
func (*Profile) GetPassword ¶
func (*Profile) GetShardingFirst ¶
func (*Profile) GetShardingLast ¶
func (*Profile) GetShardingSeparator ¶
func (*Profile) GetTimeout ¶
func (*Profile) GetUsername ¶
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
func (*Schema) GetCharset ¶
func (*Schema) GetCollation ¶
func (*Schema) GetDatabase ¶
func (*Schema) GetMaxIdle ¶
func (*Schema) GetMaxLifetime ¶
func (*Schema) GetMaxOpen ¶
func (*Schema) GetPassword ¶
func (*Schema) GetTimeout ¶
func (*Schema) GetUsername ¶
type SchemaBuilder ¶
type SchemaBuilder struct {
// contains filtered or unexported fields
}
func (*SchemaBuilder) Build ¶
func (x *SchemaBuilder) Build() (*Schema, error)
func (*SchemaBuilder) SetCharset ¶
func (x *SchemaBuilder) SetCharset(s string) *SchemaBuilder
func (*SchemaBuilder) SetCollation ¶
func (x *SchemaBuilder) SetCollation(s string) *SchemaBuilder
func (*SchemaBuilder) SetDatabase ¶
func (x *SchemaBuilder) SetDatabase(s string) *SchemaBuilder
func (*SchemaBuilder) SetDsn ¶
func (x *SchemaBuilder) SetDsn(s string) *SchemaBuilder
func (*SchemaBuilder) SetHost ¶
func (x *SchemaBuilder) SetHost(s string) *SchemaBuilder
func (*SchemaBuilder) SetMaxIdle ¶
func (x *SchemaBuilder) SetMaxIdle(n int) *SchemaBuilder
func (*SchemaBuilder) SetMaxLifetime ¶
func (x *SchemaBuilder) SetMaxLifetime(d time.Duration) *SchemaBuilder
func (*SchemaBuilder) SetMaxOpen ¶
func (x *SchemaBuilder) SetMaxOpen(n int) *SchemaBuilder
func (*SchemaBuilder) SetPassword ¶
func (x *SchemaBuilder) SetPassword(s string) *SchemaBuilder
func (*SchemaBuilder) SetPort ¶
func (x *SchemaBuilder) SetPort(p int) *SchemaBuilder
func (*SchemaBuilder) SetProto ¶
func (x *SchemaBuilder) SetProto(s string) *SchemaBuilder
func (*SchemaBuilder) SetTimeout ¶
func (x *SchemaBuilder) SetTimeout(s string) *SchemaBuilder
func (*SchemaBuilder) SetUsername ¶
func (x *SchemaBuilder) SetUsername(s string) *SchemaBuilder
type Sharding ¶
type Sharding struct {
// contains filtered or unexported fields
}
func (*Sharding) GetDrivers ¶
type ShardingBuilder ¶
type ShardingBuilder struct {
// contains filtered or unexported fields
}
func (*ShardingBuilder) AddProfile ¶
func (x *ShardingBuilder) AddProfile(p *Profile) error
func (*ShardingBuilder) Build ¶
func (x *ShardingBuilder) Build() (*Sharding, error)
func (*ShardingBuilder) SetDsnJoiner ¶
func (x *ShardingBuilder) SetDsnJoiner(f func(s *Schema) string) *ShardingBuilder
func (*ShardingBuilder) SetId ¶
func (x *ShardingBuilder) SetId(s string) error
func (*ShardingBuilder) SetName ¶
func (x *ShardingBuilder) SetName(s string) error
func (*ShardingBuilder) SetShardingJoiner ¶
func (x *ShardingBuilder) SetShardingJoiner(f func(database string, num int) string) *ShardingBuilder
Click to show internal directories.
Click to hide internal directories.