Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(name string, algorithmFactory func() ShardingAlgorithm)
Register register sharding algorithm with name
Types ¶
type ShardingAlgorithm ¶
type ShardingAlgorithm interface { // initialize structure by connection list. if returns true, no more call this. Init(conns []*sql.DB) bool // assign sharding target by connection list and shard_key Shard(conns []*sql.DB, lastInsertID int64) (*sql.DB, error) }
ShardingAlgorithm is a algorithm for assign sharding target.
octillery currently supports modulo and hashmap. If use the other new algorithm, implement the following interface as plugin ( new_algorithm.go ) and call algorithm.Register("algorithm_name", &NewAlgorithmStructure{}). Also, new_algorithm.go file should put inside github.com/aokabi/octillery/algorithm directory.
func LoadShardingAlgorithm ¶
func LoadShardingAlgorithm(name string) (ShardingAlgorithm, error)
LoadShardingAlgorithm load algorithm by name
Click to show internal directories.
Click to hide internal directories.