config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2018 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MockSchemaConfig config.
	MockSchemaConfig = &SchemaConfig{
		DB:     "sbtest",
		Tables: MockTablesConfig,
	}

	// MockTablesConfig config.
	MockTablesConfig = []*TableConfig{
		&TableConfig{
			Name:       "A",
			ShardKey:   "id",
			Partitions: MockPartitionAConfig,
		},
		&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",
		},
	}

	// MockBackends config.
	MockBackends = []*BackendConfig{
		&BackendConfig{
			Name:           "backend1",
			Address:        "127.0.0.1:3304",
			User:           "root",
			Password:       "",
			MaxConnections: 1024,
		},
	}

	// MockBackup config.
	MockBackup = &BackendConfig{
		Name:           "backupnode",
		Address:        "127.0.0.1:3304",
		User:           "root",
		Password:       "",
		MaxConnections: 1024,
	}

	// MockProxyConfig config.
	MockProxyConfig = &ProxyConfig{
		Endpoint:            ":5566",
		MaxConnections:      1024,
		MetaDir:             "/tmp/radonmeta",
		PeerAddress:         ":8080",
		BackupDefaultEngine: "TokuDB",
	}

	// MockLogConfig config.
	MockLogConfig = &LogConfig{
		Level: "DEBUG",
	}
)

Functions

func ReadVersion

func ReadVersion(metadir string) int64

ReadVersion used to read the config version from the file.

func UpdateVersion

func UpdateVersion(metadir string) error

UpdateVersion used to update the config version of the file.

func WriteConfig

func WriteConfig(path string, conf interface{}) error

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 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 {
	Backup   *BackendConfig   `json:"backup"`
	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 BinlogConfig

type BinlogConfig struct {
	LogDir       string `json:"binlog-dir"`
	MaxSize      int    `json:"max-size"`
	RelayWorkers int    `json:"relay-workers"`
	RelayWaitMs  int    `json:"relay-wait-ms"`
	EnableBinlog bool   `json:"enable-binlog"`
	EnableRelay  bool   `json:"enable-relay"`
	// type=0, turn off the parallel.
	// type=1, same events type can parallel(default).
	// type=2, all events type can parallel.
	ParallelType int `json:"parallel-type"`
}

BinlogConfig tuple.

func DefaultBinlogConfig

func DefaultBinlogConfig() *BinlogConfig

DefaultBinlogConfig returns default binlog config.

func (*BinlogConfig) UnmarshalJSON

func (c *BinlogConfig) UnmarshalJSON(b []byte) error

UnmarshalJSON interface on BinlogConfig.

type Config

type Config struct {
	Proxy   *ProxyConfig   `json:"proxy"`
	Audit   *AuditConfig   `json:"audit"`
	Router  *RouterConfig  `json:"router"`
	Binlog  *BinlogConfig  `json:"binlog"`
	Log     *LogConfig     `json:"log"`
	Monitor *MonitorConfig `json:"monitor"`
}

Config tuple.

func LoadConfig

func LoadConfig(path string) (*Config, error)

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

func (c *LogConfig) UnmarshalJSON(b []byte) error

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"`
	BackupDefaultEngine string `json:"backup-default-engine"`
	LongQueryTime       int    `json:"long-query-time"`
}

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

type RouterConfig struct {
	Slots  int `json:"slots-readonly"`
	Blocks int `json:"blocks-readonly"`
}

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 SchemaConfig

type SchemaConfig struct {
	DB     string         `json:"database"`
	Tables []*TableConfig `json:"tables"`
}

SchemaConfig tuple.

type TableConfig

type TableConfig struct {
	Name       string             `json:"name"`
	ShardType  string             `json:"shardtype"`
	ShardKey   string             `json:"shardkey"`
	Partitions []*PartitionConfig `json:"partitions"`
}

TableConfig tuple.

func ReadTableConfig

func ReadTableConfig(data string) (*TableConfig, error)

ReadTableConfig used to read the table config from the data.

type Version

type Version struct {
	Ts int64 `json:"version"`
}

Version tuple.

Jump to

Keyboard shortcuts

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