route

package
v0.0.0-...-a142604 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashShardAlgo

func HashShardAlgo(val string, dataNodeCount int, params ...interface{}) (int, error)

HashShardAlgo hash shard algorithm

func ModShardAlgo

func ModShardAlgo(val string, dataNodeCount int, params ...interface{}) (int, error)

ModShardAlgo mod shard algorithm

Types

type Hint

type Hint struct {
	OnMaster bool
	Nodes    []string
}

Hint to extra process. Nodes: /*!saashard nodes=node1,node2 */ OnMaster: /*!saashard master */

func ReadHint

func ReadHint(comments *sqlparser.Comments) *Hint

ReadHint read hint from comments

type Plan

type Plan interface {
	Route
	Execute(executor func(statements []sqlparser.Statement, results []*mysql.Result,
		dataNodes []string, isSlave bool,
		queryDataNodes map[sqlparser.Statement][]string) (backendConnAddrs []string, err error),
		clientAddr net.Addr, logSQLEnabled bool, slowLogTime int, counter *statistic.Counter) error

	ExecuteWithStmtPrepare(executor func(statements []sqlparser.Statement, results []*mysql.Result,
		dataNodes []string, isSlave bool,
		queryDataNodes map[sqlparser.Statement][]string) (*mysql.Stmt, error),
		clientAddr net.Addr, logSQLEnabled bool, slowLogTime int, counter *statistic.Counter) (*mysql.Stmt, error)
}

Plan to execute.

type Route

type Route interface {
	GetPlanSQL() string
	GetNodeNames() []string
	OnSlave() bool
}

Route info

type Router

type Router struct {
	SchemaName   string
	Schemas      map[string]*config.SchemaConfig
	Nodes        map[string]*config.NodeConfig
	ConnectionID uint32
	User         string
	InTrans      bool
}

Router used to build plan.

func NewRouter

func NewRouter(schemaName string, schemas map[string]*config.SchemaConfig, nodes map[string]*config.NodeConfig,
	connectionID uint32, user string, inTrans bool) *Router

NewRouter to create router.

func (*Router) BuildMergedPlan

func (r *Router) BuildMergedPlan(statements ...sqlparser.Statement) (plan Plan, err error)

BuildMergedPlan to merge from plan array.

func (*Router) BuildNormalPlan

func (r *Router) BuildNormalPlan(statement sqlparser.Statement) (plan Plan, err error)

BuildNormalPlan to build plan

type ShardAlgorithm

type ShardAlgorithm func(val string, dataNodeCount int, params ...interface{}) (int, error)

ShardAlgorithm shard algorithm

func ParseShardAlgorithm

func ParseShardAlgorithm(name string) ShardAlgorithm

ParseShardAlgorithm parse ShardAlgorithm

Jump to

Keyboard shortcuts

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