Documentation
¶
Index ¶
- Variables
- func MockTable64Config() *config.TableConfig
- func MockTableAConfig() *config.TableConfig
- func MockTableBConfig() *config.TableConfig
- func MockTableE1Config() *config.TableConfig
- func MockTableGreaterThanConfig() *config.TableConfig
- func MockTableInvalidConfig() *config.TableConfig
- func MockTableMConfig() *config.TableConfig
- func MockTableNULLConfig() *config.TableConfig
- func MockTableOverlapConfig() *config.TableConfig
- func MockTableSegmentEndErrConfig() *config.TableConfig
- func MockTableSegmentErr1Config() *config.TableConfig
- func MockTableSegmentStartErrConfig() *config.TableConfig
- type DatabaseACL
- type Hash
- type HashRange
- type KeyRange
- type MethodType
- type Partition
- type RDatabase
- type Router
- func (r *Router) AddForTest(db string, confs ...*config.TableConfig) error
- func (r *Router) CreateTable(db, table, shardKey string, backends []string) error
- func (r *Router) DatabaseACL(database string) error
- func (r *Router) DropDatabase(db string) error
- func (r *Router) DropTable(db, table string) error
- func (r *Router) HashUniform(table, shardkey string, backends []string) (*config.TableConfig, error)
- func (r *Router) JSON() string
- func (r *Router) LoadConfig() error
- func (r *Router) Lookup(database string, tableName string, startKey *sqlparser.SQLVal, ...) ([]Segment, error)
- func (r *Router) PartitionRuleShift(fromBackend string, toBackend string, database string, partitionTable string) error
- func (r *Router) ReLoad() error
- func (r *Router) RefreshTable(db, table string) error
- func (r *Router) Rules() *Rule
- func (r *Router) ShardKey(database string, tableName string) (string, error)
- func (r *Router) TableConfig(database string, tableName string) (*config.TableConfig, error)
- func (r *Router) Tables() map[string][]string
- type Rule
- type Schema
- type Segment
- type Segments
- type Table
Constants ¶
This section is empty.
Variables ¶
var ( // MockDefaultConfig config. MockDefaultConfig = []*config.PartitionConfig{ &config.PartitionConfig{ Table: "A2", Segment: "2-4", Backend: "backend2", }, &config.PartitionConfig{ Table: "A4", Segment: "4-8", Backend: "backend4", }, } )
Functions ¶
func MockTableE1Config ¶
func MockTableE1Config() *config.TableConfig
MockTableE1Config config, unsupport shardtype.
func MockTableGreaterThanConfig ¶
func MockTableGreaterThanConfig() *config.TableConfig
MockTableGreaterThanConfig config.
func MockTableInvalidConfig ¶
func MockTableInvalidConfig() *config.TableConfig
MockTableInvalidConfig config.
func MockTableNULLConfig ¶
func MockTableNULLConfig() *config.TableConfig
MockTableNULLConfig config.
func MockTableOverlapConfig ¶
func MockTableOverlapConfig() *config.TableConfig
MockTableOverlapConfig config.
func MockTableSegmentEndErrConfig ¶
func MockTableSegmentEndErrConfig() *config.TableConfig
MockTableSegmentEndErrConfig config.
func MockTableSegmentErr1Config ¶
func MockTableSegmentErr1Config() *config.TableConfig
MockTableSegmentErr1Config config.
func MockTableSegmentStartErrConfig ¶
func MockTableSegmentStartErrConfig() *config.TableConfig
MockTableSegmentStartErrConfig config.
Types ¶
type DatabaseACL ¶
type DatabaseACL struct {
// contains filtered or unexported fields
}
DatabaseACL tuple.
func (*DatabaseACL) Allow ¶
func (acl *DatabaseACL) Allow(db string) bool
Allow used to check to see if the db is system database.
type Hash ¶
type Hash struct { Segments []Segment `json:",omitempty"` // contains filtered or unexported fields }
Hash tuple.
func NewHash ¶
NewHash creates new hash.
func (*Hash) Build ¶
Build used to build hash bitmap from schema config
func (*Hash) Lookup ¶
Lookup used to lookup partition(s) through the sharding-key range Hash.Lookup only supports the type uint64/string
type HashRange ¶
HashRange tuple. [Start, End)
type Partition ¶
type Partition interface { Build() error Lookup(start *sqlparser.SQLVal, end *sqlparser.SQLVal) ([]Segment, error) }
Partition interface.
type Router ¶
type Router struct { // schemas map, key is database name Schemas map[string]*Schema `json:",omitempty"` // contains filtered or unexported fields }
Router tuple.
func MockNewRouter ¶
MockNewRouter mocks router.
func NewRouter ¶
NewRouter creates the new router.
func (*Router) AddForTest ¶
func (r *Router) AddForTest(db string, confs ...*config.TableConfig) error
AddForTest used to add table config for test.
func (*Router) CreateTable ¶
CreateTable used to add a table to router and flush the schema to disk. Lock.
func (*Router) DatabaseACL ¶
DatabaseACL used to check wheather the database is a system database.
func (*Router) DropDatabase ¶
DropDatabase used to remove a database-schema from the schemas and remove all the table-schema files who belongs to this database.
func (*Router) DropTable ¶
DropTable used to remove a table from router and remove the schema file from disk.
func (*Router) HashUniform ¶
func (r *Router) HashUniform(table, shardkey string, backends []string) (*config.TableConfig, error)
HashUniform used to uniform the hash slots to backends.
func (*Router) LoadConfig ¶
LoadConfig used to load all schemas stored in metadir. When an IO error occurs during the file reading, panic me.
func (*Router) Lookup ¶
func (r *Router) Lookup(database string, tableName string, startKey *sqlparser.SQLVal, endKey *sqlparser.SQLVal) ([]Segment, error)
Lookup used to lookup a router(partition table name and backend) through db&table
func (*Router) PartitionRuleShift ¶
func (r *Router) PartitionRuleShift(fromBackend string, toBackend string, database string, partitionTable string) error
PartitionRuleShift used to shift a rule from backend to another. The processes as: 1. change the backend in memory. 2. flush the table config to disk. 3. reload the config to memory. Note: If the reload fails, panic it since the config is in chaos.
func (*Router) ReLoad ¶
ReLoad used to re-load the config files from disk to cache.
func (*Router) RefreshTable ¶
RefreshTable used to re-update the table from file. Lock.
func (*Router) ShardKey ¶
ShardKey used to lookup shardkey from given database and table name
func (*Router) TableConfig ¶
TableConfig returns the config by database and tableName.
type Schema ¶
type Schema struct { // database name DB string `json:",omitempty"` // tables map, key is table name Tables map[string]*Table `json:",omitempty"` }
Schema tuple.
type Segment ¶
type Segment struct { // Segment table name. Table string `json:",omitempty"` // Segment backend name. Backend string `json:",omitempty"` // key range of this segment. Range KeyRange `json:",omitempty"` }
Segment tuple.