Documentation ¶
Index ¶
- Variables
- func AcquireBuffer() *bytes.Buffer
- func AcquireStringsBuilder() *strings.Builder
- func CreatePool(f func() interface{}) func() *sync.Pool
- func DividesGenerate(prefix string, num int) string
- func NewDB(driver string, url string, c ConnConfiger) *sql.DB
- func ReleaseBuffer(b *bytes.Buffer)
- func ReleaseStringsBuilder(b *strings.Builder)
- type Cluster
- type ClusterConfig
- type ClusterConfiger
- type Config
- type Configer
- type ConnConfiger
- type DBHandler
- type DbConfiger
- type DbPartition
- type DbPartitionConfig
- type DbPartitionConfiger
- type DbPartitioner
- type Decoder
- type MasterNode
- type MasterNodeConfiger
- type NopDbPartition
- type NopReplication
- type NopTablePartition
- type Option
- type Partition
- type PreloadTablePartition
- type ReplicaNode
- type ReplicaNodeConfiger
- type ReplicaNodeOption
- type Replication
- type ReplicationConfig
- type ReplicationConfiger
- type Shard
- type ShardConfig
- func (s *ShardConfig) GetDbname() string
- func (s *ShardConfig) GetDriver() string
- func (s *ShardConfig) GetMasterUrl() string
- func (s *ShardConfig) GetMaxIdleConns() int
- func (s *ShardConfig) GetMaxLifetime() time.Duration
- func (s *ShardConfig) GetMaxOpenConns() int
- func (s *ShardConfig) GetReplicaUrls() []string
- func (s *ShardConfig) SetDbname(name string)
- type ShardConfiger
- type TablePartition
- type TablePartitionConfig
- type TablePartitionConfiger
- type TablePartitionSpecConfiger
- type TablePartitionSpecsConfig
- type YamlClusterConfig
- type YamlConfig
- type YamlConnConfig
- type YamlDBConfig
- type YamlDbPartitionConfig
- type YamlMasterConfig
- type YamlNodeConfig
- type YamlPartitionConfig
- type YamlReplicasConfig
- type YamlReplicationConfig
- type YamlShardConfig
- type YamlTablePartitionConfig
- type YamlTablePartitionSpecConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( GetBufferPool = CreatePool(func() interface{} { var b bytes.Buffer return &b }) )
View Source
var ( GetStringsBuilderPool = CreatePool(func() interface{} { var b bytes.Buffer return &b }) )
View Source
var (
NopDbPartitionError = errors.New("Empty DB Partition Config ")
)
Functions ¶
func AcquireBuffer ¶
func AcquireStringsBuilder ¶
func CreatePool ¶
func DividesGenerate ¶
func ReleaseBuffer ¶
func ReleaseStringsBuilder ¶
Types ¶
type ClusterConfig ¶
type ClusterConfig struct { ReplicationConfig ReplicationConfig DbPartitionConfig DbPartitionConfig TablePartitionConfig TablePartitionConfig }
func NewClusterConfig ¶
func NewClusterConfig(config *YamlClusterConfig) *ClusterConfig
func (*ClusterConfig) GetDbPartitionConfig ¶
func (c *ClusterConfig) GetDbPartitionConfig() *DbPartitionConfig
func (*ClusterConfig) GetReplicationConfig ¶
func (c *ClusterConfig) GetReplicationConfig() *ReplicationConfig
func (*ClusterConfig) GetTablePartitionConfig ¶
func (c *ClusterConfig) GetTablePartitionConfig() *TablePartitionConfig
type ClusterConfiger ¶
type ClusterConfiger interface { GetReplicationConfig() *ReplicationConfig GetDbPartitionConfig() *DbPartitionConfig GetTablePartitionConfig() *TablePartitionConfig }
type Config ¶
type Config struct { Cluster *ClusterConfig Shards []*ShardConfig }
func NewConfig ¶
func NewConfig(conf *YamlConfig) *Config
func (*Config) GetClusterConfig ¶
func (c *Config) GetClusterConfig() *ClusterConfig
func (*Config) GetShardsConfig ¶
func (c *Config) GetShardsConfig() []*ShardConfig
type Configer ¶
type Configer interface { GetClusterConfig() *ClusterConfig GetShardsConfig() []*ShardConfig }
type ConnConfiger ¶
type DbConfiger ¶
type DbConfiger interface { GetDriver() string GetDbname() string SetDbname(string) ConnConfiger }
type DbPartition ¶
func (*DbPartition) Select ¶
func (p *DbPartition) Select(key []byte) int
type DbPartitionConfig ¶
type DbPartitionConfig struct {
YamlDbPartitionConfig
}
func NewDbPartitionConfig ¶
func NewDbPartitionConfig(p *YamlPartitionConfig) *DbPartitionConfig
func (*DbPartitionConfig) GetTotal ¶
func (d *DbPartitionConfig) GetTotal() int
func (*DbPartitionConfig) GetType ¶
func (d *DbPartitionConfig) GetType() string
type DbPartitionConfiger ¶
type DbPartitioner ¶
func NewDbPartition ¶
func NewDbPartition(conf DbPartitionConfiger) (DbPartitioner, error)
type MasterNode ¶
type MasterNode struct {
// contains filtered or unexported fields
}
func NewMasterNode ¶
func NewMasterNode(driver string, c MasterNodeConfiger) *MasterNode
func (*MasterNode) GetDB ¶
func (m *MasterNode) GetDB() *sql.DB
type MasterNodeConfiger ¶
type MasterNodeConfiger interface { GetMasterUrl() string DbConfiger }
type NopDbPartition ¶
type NopDbPartition struct { }
func (*NopDbPartition) Select ¶
func (p *NopDbPartition) Select([]byte) int
type NopReplication ¶
type NopReplication struct { }
func (*NopReplication) Replicate ¶
func (lb *NopReplication) Replicate(int) int
type NopTablePartition ¶
type NopTablePartition struct { }
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func AddExecutor ¶
func AddExecutor(f func(*sql.DB, DBHandler, TablePartition)) Option
func AddMaster ¶
func AddMaster(conf ShardConfiger) Option
func AddReplica ¶
func AddReplica(conf ShardConfiger, opts ...ReplicaNodeOption) Option
func AddTablePartition ¶
func AddTablePartition(tp TablePartition) Option
type Partition ¶
type Partition = distributed.Partition
type PreloadTablePartition ¶
type PreloadTablePartition struct { Partition Partition // contains filtered or unexported fields }
type ReplicaNode ¶
type ReplicaNode struct {
// contains filtered or unexported fields
}
func NewReplicasNode ¶
func NewReplicasNode(driver string, c ReplicaNodeConfiger, opts ...ReplicaNodeOption) *ReplicaNode
func (*ReplicaNode) GetDB ¶
func (r *ReplicaNode) GetDB() *sql.DB
func (*ReplicaNode) SetReplication ¶
func (r *ReplicaNode) SetReplication(lb Replication)
func (*ReplicaNode) WithOptions ¶
func (r *ReplicaNode) WithOptions(opts ...ReplicaNodeOption) *ReplicaNode
type ReplicaNodeConfiger ¶
type ReplicaNodeConfiger interface { GetReplicaUrls() []string DbConfiger }
type ReplicaNodeOption ¶
type ReplicaNodeOption interface {
// contains filtered or unexported methods
}
func AddReplication ¶
func AddReplication(lb Replication) ReplicaNodeOption
type Replication ¶
type Replication = distributed.Replication
func NewReplication ¶
func NewReplication(conf ReplicationConfiger) Replication
type ReplicationConfig ¶
type ReplicationConfig struct {
YamlReplicationConfig
}
func NewReplicationConfig ¶
func NewReplicationConfig(conf *YamlReplicationConfig) *ReplicationConfig
func (*ReplicationConfig) GetType ¶
func (r *ReplicationConfig) GetType() string
type ReplicationConfiger ¶
type ReplicationConfiger interface {
GetType() string
}
type Shard ¶
type Shard struct { Master *MasterNode Replica *ReplicaNode Executor func(*sql.DB, DBHandler, TablePartition) // contains filtered or unexported fields }
func NewShard ¶
func NewShard(conf *ShardConfig, options ...Option) *Shard
func (*Shard) WithOptions ¶
type ShardConfig ¶
type ShardConfig struct { YamlDBConfig YamlShardConfig // contains filtered or unexported fields }
func NewShardConfig ¶
func NewShardConfig(shard *YamlShardConfig, db *YamlDBConfig, r *YamlReplicationConfig) *ShardConfig
func (*ShardConfig) GetDbname ¶
func (s *ShardConfig) GetDbname() string
func (*ShardConfig) GetDriver ¶
func (s *ShardConfig) GetDriver() string
func (*ShardConfig) GetMasterUrl ¶
func (s *ShardConfig) GetMasterUrl() string
func (*ShardConfig) GetMaxIdleConns ¶
func (s *ShardConfig) GetMaxIdleConns() int
func (*ShardConfig) GetMaxLifetime ¶
func (s *ShardConfig) GetMaxLifetime() time.Duration
func (*ShardConfig) GetMaxOpenConns ¶
func (s *ShardConfig) GetMaxOpenConns() int
func (*ShardConfig) GetReplicaUrls ¶
func (s *ShardConfig) GetReplicaUrls() []string
func (*ShardConfig) SetDbname ¶
func (s *ShardConfig) SetDbname(name string)
type ShardConfiger ¶
type ShardConfiger interface { MasterNodeConfiger ReplicaNodeConfiger ReplicationConfiger }
type TablePartition ¶
func NewTablePartition ¶
func NewTablePartition(conf TablePartitionConfiger, start int) TablePartition
type TablePartitionConfig ¶
type TablePartitionConfig struct {
YamlTablePartitionConfig
}
func NewTablePartitionConfig ¶
func NewTablePartitionConfig(p *YamlPartitionConfig) *TablePartitionConfig
func (*TablePartitionConfig) GetSpecs ¶
func (t *TablePartitionConfig) GetSpecs() []*TablePartitionSpecsConfig
func (*TablePartitionConfig) GetType ¶
func (t *TablePartitionConfig) GetType() string
type TablePartitionConfiger ¶
type TablePartitionConfiger interface { GetType() string GetSpecs() []*TablePartitionSpecsConfig }
type TablePartitionSpecsConfig ¶
type TablePartitionSpecsConfig = YamlTablePartitionSpecConfig
func (*TablePartitionSpecsConfig) GetName ¶
func (p *TablePartitionSpecsConfig) GetName() string
func (*TablePartitionSpecsConfig) GetTotal ¶
func (p *TablePartitionSpecsConfig) GetTotal() int
type YamlClusterConfig ¶
type YamlClusterConfig struct { Replication YamlReplicationConfig `yaml:"replication"` Partition YamlPartitionConfig `yaml:"partition"` }
type YamlConfig ¶
type YamlConfig struct { Cluster YamlClusterConfig `yaml:"cluster"` Db YamlDBConfig `yaml:"db"` Shards []*YamlShardConfig `yaml:"shards"` }
func ParseYamlConfig ¶
func ParseYamlConfig(d Decoder) (*YamlConfig, error)
func ParseYamlConfigFile ¶
func ParseYamlConfigFile(path string) (*YamlConfig, error)
type YamlConnConfig ¶
type YamlDBConfig ¶
type YamlDBConfig struct { Driver string `yaml:"driver"` Dbname string `yaml:"dbname"` Conn YamlConnConfig `yaml:"conn"` }
type YamlDbPartitionConfig ¶
type YamlMasterConfig ¶
type YamlMasterConfig struct { Host string `yaml:"host"` YamlNodeConfig `yaml:",inline"` }
type YamlNodeConfig ¶
type YamlPartitionConfig ¶
type YamlPartitionConfig struct { Db YamlDbPartitionConfig `yaml:"db"` Table YamlTablePartitionConfig `yaml:"table"` }
type YamlReplicasConfig ¶
type YamlReplicasConfig struct { Hosts []string `yaml:"hosts"` YamlNodeConfig `yaml:",inline"` }
type YamlReplicationConfig ¶
type YamlReplicationConfig struct {
Type string `yaml:"type"`
}
type YamlShardConfig ¶
type YamlShardConfig struct { Master YamlMasterConfig `yaml:"master"` Replicas YamlReplicasConfig `yaml:"replicas"` }
type YamlTablePartitionConfig ¶
type YamlTablePartitionConfig struct { Type string `yaml:"type"` Specs []*TablePartitionSpecsConfig `yaml:"specs"` }
Click to show internal directories.
Click to hide internal directories.