Versions in this module Expand all Collapse all v2 v2.1.0 Jul 2, 2021 v2.0.0 Oct 13, 2020 Changes in this version + var GetBufferPool = CreatePool(func() interface{} { ... }) + var GetStringsBuilderPool = CreatePool(func() interface{} { ... }) + var NopDbPartitionError = errors.New("Empty DB Partition Config ") + 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 struct + DP DbPartitioner + Shards []*Shard + func NewCluster(conf Configer, exec func(*sql.DB, DBHandler, TablePartition)) (*Cluster, error) + func (p *Cluster) Map(f func(*Shard)) + func (p *Cluster) Pick() *Shard + func (p *Cluster) Read(handler DBHandler) + func (p *Cluster) Select(key []byte) *Shard + func (p *Cluster) Write(handler DBHandler) + type ClusterConfig struct + DbPartitionConfig DbPartitionConfig + ReplicationConfig ReplicationConfig + TablePartitionConfig TablePartitionConfig + func NewClusterConfig(config *YamlClusterConfig) *ClusterConfig + func (c *ClusterConfig) GetDbPartitionConfig() *DbPartitionConfig + func (c *ClusterConfig) GetReplicationConfig() *ReplicationConfig + func (c *ClusterConfig) GetTablePartitionConfig() *TablePartitionConfig + type ClusterConfiger interface + GetDbPartitionConfig func() *DbPartitionConfig + GetReplicationConfig func() *ReplicationConfig + GetTablePartitionConfig func() *TablePartitionConfig + type Config struct + Cluster *ClusterConfig + Shards []*ShardConfig + func NewConfig(conf *YamlConfig) *Config + func (c *Config) GetClusterConfig() *ClusterConfig + func (c *Config) GetShardsConfig() []*ShardConfig + type Configer interface + GetClusterConfig func() *ClusterConfig + GetShardsConfig func() []*ShardConfig + type ConnConfiger interface + GetMaxIdleConns func() int + GetMaxLifetime func() time.Duration + GetMaxOpenConns func() int + type DBHandler func(*sql.DB, TablePartition) error + type DbConfiger interface + GetDbname func() string + GetDriver func() string + SetDbname func(string) + type DbPartition struct + Partition Partition + Total int + func (p *DbPartition) Divide(prefix string, num int) string + func (p *DbPartition) Select(key []byte) int + type DbPartitionConfig struct + func NewDbPartitionConfig(p *YamlPartitionConfig) *DbPartitionConfig + func (d *DbPartitionConfig) GetTotal() int + func (d *DbPartitionConfig) GetType() string + type DbPartitionConfiger interface + GetTotal func() int + GetType func() string + type DbPartitioner interface + Divide func(prefix string, num int) string + Select func(key []byte) int + func NewDbPartition(conf DbPartitionConfiger) (DbPartitioner, error) + type Decoder interface + Decode func(interface{}) error + type MasterNode struct + func NewMasterNode(driver string, c MasterNodeConfiger) *MasterNode + func (m *MasterNode) GetDB() *sql.DB + type MasterNodeConfiger interface + GetMasterUrl func() string + type NopDbPartition struct + func (p *NopDbPartition) Divide(prefix string, num int) string + func (p *NopDbPartition) Select([]byte) int + type NopReplication struct + func (lb *NopReplication) Replicate(int) int + type NopTablePartition struct + func (p *NopTablePartition) Select(key []byte, prefix string) string + type Option interface + func AddExecutor(f func(*sql.DB, DBHandler, TablePartition)) Option + func AddMaster(conf ShardConfiger) Option + func AddReplica(conf ShardConfiger, opts ...ReplicaNodeOption) Option + func AddTablePartition(tp TablePartition) Option + type Partition = distributed.Partition + type PreloadTablePartition struct + Partition Partition + func (p *PreloadTablePartition) Select(key []byte, prefix string) string + type ReplicaNode struct + func NewReplicasNode(driver string, c ReplicaNodeConfiger, opts ...ReplicaNodeOption) *ReplicaNode + func (r *ReplicaNode) GetDB() *sql.DB + func (r *ReplicaNode) SetReplication(lb Replication) + func (r *ReplicaNode) WithOptions(opts ...ReplicaNodeOption) *ReplicaNode + type ReplicaNodeConfiger interface + GetReplicaUrls func() []string + type ReplicaNodeOption interface + func AddReplication(lb Replication) ReplicaNodeOption + type Replication = distributed.Replication + func NewReplication(conf ReplicationConfiger) Replication + type ReplicationConfig struct + func NewReplicationConfig(conf *YamlReplicationConfig) *ReplicationConfig + func (r *ReplicationConfig) GetType() string + type ReplicationConfiger interface + GetType func() string + type Shard struct + Executor func(*sql.DB, DBHandler, TablePartition) + Master *MasterNode + Replica *ReplicaNode + func NewShard(conf *ShardConfig, options ...Option) *Shard + func (s *Shard) Read(handler DBHandler) + func (s *Shard) WithOptions(opts ...Option) *Shard + func (s *Shard) Write(handler DBHandler) + type ShardConfig struct + func NewShardConfig(shard *YamlShardConfig, db *YamlDBConfig, r *YamlReplicationConfig) *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 interface + type TablePartition interface + Select func(key []byte, prefix string) string + func NewTablePartition(conf TablePartitionConfiger, start int) TablePartition + type TablePartitionConfig struct + func NewTablePartitionConfig(p *YamlPartitionConfig) *TablePartitionConfig + func (t *TablePartitionConfig) GetSpecs() []*TablePartitionSpecsConfig + func (t *TablePartitionConfig) GetType() string + type TablePartitionConfiger interface + GetSpecs func() []*TablePartitionSpecsConfig + GetType func() string + type TablePartitionSpecConfiger interface + GetName func() string + GetTotal func() int + type TablePartitionSpecsConfig = YamlTablePartitionSpecConfig + func (p *TablePartitionSpecsConfig) GetName() string + func (p *TablePartitionSpecsConfig) GetTotal() int + type YamlClusterConfig struct + Partition YamlPartitionConfig + Replication YamlReplicationConfig + type YamlConfig struct + Cluster YamlClusterConfig + Db YamlDBConfig + Shards []*YamlShardConfig + func ParseYamlConfig(d Decoder) (*YamlConfig, error) + func ParseYamlConfigFile(path string) (*YamlConfig, error) + type YamlConnConfig struct + MaxIdleConns int + MaxLifetime int + MaxOpenConns int + type YamlDBConfig struct + Conn YamlConnConfig + Dbname string + Driver string + type YamlDbPartitionConfig struct + Total int + Type string + type YamlMasterConfig struct + Host string + type YamlNodeConfig struct + Params map[string]string + Password string + Protocol string + User string + type YamlPartitionConfig struct + Db YamlDbPartitionConfig + Table YamlTablePartitionConfig + type YamlReplicasConfig struct + Hosts []string + type YamlReplicationConfig struct + Type string + type YamlShardConfig struct + Master YamlMasterConfig + Replicas YamlReplicasConfig + type YamlTablePartitionConfig struct + Specs []*TablePartitionSpecsConfig + Type string + type YamlTablePartitionSpecConfig struct + Name string + Total int Other modules containing this package github.com/jealone/gosql github.com/jealone/gosql/v3 github.com/jealone/gosql/v4