algorithm

package
v1.1.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2021 License: MIT Imports: 6 Imported by: 0

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 go.knocknote.io/octillery/algorithm directory.

func LoadShardingAlgorithm

func LoadShardingAlgorithm(name string) (ShardingAlgorithm, error)

LoadShardingAlgorithm load algorithm by name

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL