Versions in this module Expand all Collapse all v0 v0.0.3 Aug 15, 2023 Changes in this version type Sharding + func NewSharding(config Config) *Sharding + func (s *Sharding) Register(config Config, tables ...interface{}) *Sharding + func (s *Sharding) RegisterDefault(tables ...interface{}) *Sharding + func (s *Sharding) RegisterOne(config Config, table interface{}) *Sharding v0.0.2 Aug 15, 2023 Changes in this version + const PKCustom + const PKPGSequence + const PKSnowflake + var ErrInsertDiffSuffix = errors.New("can not insert different suffix table in one query ") + var ErrInvalidID = errors.New("invalid id format") + var ErrMissingShardingKey = errors.New("sharding key or id required, and use operator =") + var ShardingIgnoreStoreKey = "sharding_ignore" + type Config struct + DoubleWrite bool + NumberOfShards uint + PrimaryKeyGenerator int + PrimaryKeyGeneratorFn func(tableIdx int64) int64 + ShardingAlgorithm func(columnValue interface{}) (suffix string, err error) + ShardingAlgorithmByPrimaryKey func(id int64) (suffix string) + ShardingKey string + ShardingSuffixs func() (suffixs []string) + type ConnPool struct + func (pool *ConnPool) BeginTx(ctx context.Context, opt *sql.TxOptions) (gorm.ConnPool, error) + func (pool *ConnPool) Commit() error + func (pool *ConnPool) Ping() error + func (pool *ConnPool) Rollback() error + func (pool *ConnPool) String() string + func (pool ConnPool) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) + func (pool ConnPool) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) + func (pool ConnPool) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) + func (pool ConnPool) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row + type Sharding struct + ConnPool *ConnPool + func Register(config Config, tables ...interface{}) *Sharding + func (s *Sharding) Initialize(db *gorm.DB) error + func (s *Sharding) LastQuery() string + func (s *Sharding) Name() string + type ShardingDialector struct + func NewShardingDialector(d gorm.Dialector, s *Sharding) ShardingDialector + func (d ShardingDialector) Migrator(db *gorm.DB) gorm.Migrator + type ShardingMigrator struct + func (m ShardingMigrator) AutoMigrate(dst ...interface{}) error + func (m ShardingMigrator) BuildIndexOptions(opts []schema.IndexOption, stmt *gorm.Statement) (results []interface{}) + func (m ShardingMigrator) DropTable(dst ...interface{}) error