Documentation ¶
Overview ¶
Package sharding NOTES
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRetryTransaction = errors.New("RETRY TRANSACTION ERROR")
ErrRetryTransaction defines errors that need to retry transaction, like deadlock error in upsert scenario
Functions ¶
func InitAuditorSharding ¶
InitAuditorSharding 审计表分库
func MustShardingAuditor ¶
MustShardingAuditor auditorDB 不存在,使用 adminDB
Types ¶
type One ¶
type One struct {
// contains filtered or unexported fields
}
One represent one mysql sharding instance. Note: You must call Err() to test the error BEFORE you use the 'One' to do anything.
func (*One) AutoTxn ¶
AutoTxn is a wrapper to do all the transaction operations as follows: 1. auto launch the transaction 2. process the logics, which is a callback run function 3. rollback the transaction if 'run' hit an error automatically. 4. commit the transaction if no error happens.
type Sharding ¶
type Sharding struct {
// contains filtered or unexported fields
}
Sharding is used to manage all the mysql instances which works for all the biz and admin resources.
func InitSharding ¶
InitSharding initialize a sharding management instance.
func (*Sharding) MustSharding ¶
MustSharding get a db instance with biz id. It does not check the biz's value, caller should to guarantee that biz is > 0; Otherwise, it will panic.
func (*Sharding) ShardingOne ¶
ShardingOne get a db instance with biz id.
type TxnOption ¶
type TxnOption struct { // ShardingUid is the unique id of a mysql sharding instance. // which means a same sharding instance have the same uid. // It is used to test if the mysql instance is the same instance // in a distributed transaction, such as create an app and save // its audit log. ShardingUid string }
TxnOption defines all the options to do distributed transaction in the AutoTxn processes.