octillery: go.knocknote.io/octillery/algorithm Index | Files

package algorithm

import "go.knocknote.io/octillery/algorithm"

Index

Package Files

algorithm.go hashmap.go modulo.go

func Register Uses

func Register(name string, algorithmFactory func() ShardingAlgorithm)

Register register sharding algorithm with name

type ShardingAlgorithm Uses

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 Uses

func LoadShardingAlgorithm(name string) (ShardingAlgorithm, error)

LoadShardingAlgorithm load algorithm by name

Package algorithm imports 6 packages (graph) and is imported by 2 packages. Updated 2018-12-11. Refresh now. Tools for package owners.