Documentation
¶
Index ¶
- Variables
- func ReadVersion(metadir string) int64
- func UpdateVersion(metadir string) error
- func WriteConfig(path string, conf interface{}) error
- type AuditConfig
- type AutoIncrement
- type BackendConfig
- type BackendsConfig
- type Config
- type LogConfig
- type MonitorConfig
- type PartitionConfig
- type ProxyConfig
- type RouterConfig
- type ScatterConfig
- type SchemaConfig
- type TableConfig
- type Version
Constants ¶
This section is empty.
Variables ¶
var ( // MockSchemaConfig config. MockSchemaConfig = &SchemaConfig{ DB: "sbtest", Tables: MockTablesConfig, } // MockTablesConfig config. MockTablesConfig = []*TableConfig{ &TableConfig{ Name: "A", ShardKey: "id", Partitions: MockPartitionAConfig, AutoIncrement: MockAutoIncrment, }, &TableConfig{ Name: "B", ShardKey: "id", Partitions: MockPartitionBConfig, }, } // MockPartitionAConfig config. MockPartitionAConfig = []*PartitionConfig{ &PartitionConfig{ Table: "A1", Segment: "0-2", Backend: "backend1", }, &PartitionConfig{ Table: "A2", Segment: "2-4", Backend: "backend1", }, &PartitionConfig{ Table: "A3", Segment: "4-8", Backend: "backend2", }, &PartitionConfig{ Table: "A4", Segment: "8-16", Backend: "backend2", }, } // MockPartitionBConfig config. MockPartitionBConfig = []*PartitionConfig{ &PartitionConfig{ Table: "B1", Segment: "0-4", Backend: "backend2", }, &PartitionConfig{ Table: "B2", Segment: "4-8", Backend: "backend1", }, &PartitionConfig{ Table: "B3", Segment: "8-16", Backend: "backend2", }, } // MockAutoIncrment. MockAutoIncrment = &AutoIncrement{ Column: "autoincrement", } // MockBackends config. MockBackends = []*BackendConfig{ &BackendConfig{ Name: "backend1", Address: "127.0.0.1:3304", User: "root", Password: "", MaxConnections: 1024, }, } // MockProxyConfig config. MockProxyConfig = &ProxyConfig{ Endpoint: ":5566", MaxConnections: 1024, MetaDir: "/tmp/radonmeta", PeerAddress: ":8080", } // MockLogConfig config. MockLogConfig = &LogConfig{ Level: "DEBUG", } )
Functions ¶
func ReadVersion ¶
ReadVersion used to read the config version from the file.
func UpdateVersion ¶
UpdateVersion used to update the config version of the file.
func WriteConfig ¶
WriteConfig used to write the conf to file.
Types ¶
type AuditConfig ¶
type AuditConfig struct { Mode string `json:"mode"` LogDir string `json:"audit-dir"` MaxSize int `json:"max-size"` ExpireHours int `json:"expire-hours"` }
AuditConfig tuple.
func DefaultAuditConfig ¶
func DefaultAuditConfig() *AuditConfig
DefaultAuditConfig returns default audit config.
func (*AuditConfig) UnmarshalJSON ¶
func (c *AuditConfig) UnmarshalJSON(b []byte) error
UnmarshalJSON interface on AuditConfig.
type AutoIncrement ¶ added in v1.0.6
type AutoIncrement struct {
Column string `json:"column"`
}
AutoIncrement tuple.
type BackendConfig ¶
type BackendConfig struct { Name string `json:"name"` Address string `json:"address"` User string `json:"user"` Password string `json:"password"` DBName string `json:"database"` Charset string `json:"charset"` MaxConnections int `json:"max-connections"` }
BackendConfig tuple.
type BackendsConfig ¶
type BackendsConfig struct {
Backends []*BackendConfig `json:"backends"`
}
BackendsConfig tuple.
func ReadBackendsConfig ¶
func ReadBackendsConfig(data string) (*BackendsConfig, error)
ReadBackendsConfig used to read the backend config from the data.
type Config ¶
type Config struct { Proxy *ProxyConfig `json:"proxy"` Audit *AuditConfig `json:"audit"` Router *RouterConfig `json:"router"` Log *LogConfig `json:"log"` Monitor *MonitorConfig `json:"monitor"` Scatter *ScatterConfig `json:"scatter"` }
Config tuple.
func LoadConfig ¶
LoadConfig used to load the config from file.
type LogConfig ¶
type LogConfig struct {
Level string `json:"level"`
}
LogConfig tuple.
func DefaultLogConfig ¶
func DefaultLogConfig() *LogConfig
DefaultLogConfig returns default log config.
func (*LogConfig) UnmarshalJSON ¶
UnmarshalJSON interface on LogConfig.
type MonitorConfig ¶ added in v1.0.1
type MonitorConfig struct {
MonitorAddress string `json:"monitor-address"`
}
MonitorConfig tuple
func DefaultMonitorConfig ¶ added in v1.0.1
func DefaultMonitorConfig() *MonitorConfig
DefaultMonitorConfig returns default monitor config.
func (*MonitorConfig) UnmarshalJSON ¶ added in v1.0.1
func (c *MonitorConfig) UnmarshalJSON(b []byte) error
UnmarshalJSON interface on MonitorConfig.
type PartitionConfig ¶
type PartitionConfig struct { Table string `json:"table"` Segment string `json:"segment"` Backend string `json:"backend"` }
PartitionConfig tuple.
type ProxyConfig ¶
type ProxyConfig struct { IPS []string `json:"allowip,omitempty"` MetaDir string `json:"meta-dir"` Endpoint string `json:"endpoint"` TwopcEnable bool `json:"twopc-enable"` MaxConnections int `json:"max-connections"` MaxResultSize int `json:"max-result-size"` DDLTimeout int `json:"ddl-timeout"` QueryTimeout int `json:"query-timeout"` PeerAddress string `json:"peer-address,omitempty"` LongQueryTime int `json:"long-query-time"` StreamBufferSize int `json:"stream-buffer-size"` IdleTxnTimeout uint32 `json:"kill-idle-transaction"` //is consistent with the official 8.0 kill_idle_transaction }
ProxyConfig tuple.
func DefaultProxyConfig ¶
func DefaultProxyConfig() *ProxyConfig
DefaultProxyConfig returns default proxy config.
func (*ProxyConfig) UnmarshalJSON ¶
func (c *ProxyConfig) UnmarshalJSON(b []byte) error
UnmarshalJSON interface on ProxyConfig.
type RouterConfig ¶
RouterConfig tuple.
func DefaultRouterConfig ¶
func DefaultRouterConfig() *RouterConfig
DefaultRouterConfig returns the default router config.
func (*RouterConfig) UnmarshalJSON ¶
func (c *RouterConfig) UnmarshalJSON(b []byte) error
UnmarshalJSON interface on RouterConfig.
type ScatterConfig ¶ added in v1.0.2
type ScatterConfig struct { XaCheckInterval int `json:"xa-check-interval"` XaCheckDir string `json:"xa-check-dir"` XaCheckRetrys int `json:"xa-check-retrys` }
ScatterConfig tuple.
func DefaultScatterConfig ¶ added in v1.0.2
func DefaultScatterConfig() *ScatterConfig
DefaultScatterConfig returns default ScatterConfig config.
func (*ScatterConfig) UnmarshalJSON ¶ added in v1.0.2
func (c *ScatterConfig) UnmarshalJSON(b []byte) error
UnmarshalJSON interface on XaCheckConfig.
type SchemaConfig ¶
type SchemaConfig struct { DB string `json:"database"` Tables []*TableConfig `json:"tables"` }
SchemaConfig tuple.
type TableConfig ¶
type TableConfig struct { Name string `json:"name"` Slots int `json:"slots-readonly"` Blocks int `json:"blocks-readonly"` ShardType string `json:"shardtype"` ShardKey string `json:"shardkey"` Partitions []*PartitionConfig `json:"partitions"` AutoIncrement *AutoIncrement `json:"auto-increment,omitempty"` }
TableConfig tuple.
func ReadTableConfig ¶
func ReadTableConfig(data string) (*TableConfig, error)
ReadTableConfig used to read the table config from the data.