config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Mysql          = "mysql"
	PG             = "postgresql"
	DefaultHe3User = "he3proxy"
)

Variables

View Source
var CacheConnsMap sync.Map
View Source
var CancelReq bool

if false will not store client connection Id, means cancel request send cmd will invalidate, default true

View Source
var ConnPool bool

Used to save connection pool switch

View Source
var DbType string

Used to save connection mode, mysql or pg

View Source
var He3Proxy bool
View Source
var IdleConnsMap sync.Map
View Source
var KeepConn bool
View Source
var Metrics bool

if false will close metrics collection, default true

View Source
var Opentracing bool
View Source
var ReadOnly bool
View Source
var ServerVersion string
View Source
var SimpleParse bool

if true, change crdb parse to kingshard lex analysis

View Source
var SingleSession bool
View Source
var TracerProviderUrl string

Functions

func WriteConfigFile

func WriteConfigFile(cfg *Config) error

Types

type Config

type Config struct {
	Addr           string       `yaml:"addr"`
	PrometheusAddr string       `yaml:"prometheus_addr"`
	UserList       []UserConfig `yaml:"user_list"`

	WebAddr     string `yaml:"web_addr"`
	WebUser     string `yaml:"web_user"`
	WebPassword string `yaml:"web_password"`

	LogPath     string       `yaml:"log_path"`
	LogLevel    string       `yaml:"log_level"`
	LogSql      string       `yaml:"log_sql"`
	SlowLogTime int          `yaml:"slow_log_time"`
	AllowIps    string       `yaml:"allow_ips"`
	BlsFile     string       `yaml:"blacklist_sql_file"`
	Charset     string       `yaml:"proxy_charset"`
	Nodes       []NodeConfig `yaml:"nodes"`

	SchemaList []SchemaConfig `yaml:"schema_list"`
}

Structure corresponding to the entire config file

func ParseConfigData

func ParseConfigData(data []byte) (*Config, error)

func ParseConfigFile

func ParseConfigFile(fileName string) (*Config, error)

type NodeConfig

type NodeConfig struct {
	Name             string `yaml:"name"`
	DownAfterNoAlive int    `yaml:"down_after_noalive"`
	MaxConnNum       int    `yaml:"max_conns_limit"`

	User     string `yaml:"user"`
	Password string `yaml:"password"`

	Master string `yaml:"master"`
	Slave  string `yaml:"slave"`
	// pg connect pool max idle time. unit: min
	ConnMaxIdleTime int `yaml:"max_conns_idle_time"`
	// The maximum number of link pools can support several dB library pairs of link pools at the same time
	MaxPoolNum int32 `yaml:"max_pool_num"`
	// Number of cached links per DB link pool
	InitConnCount int `yaml:"init_conn_count"`
	// Load balancing mode (weight mode, metric): obtain high-quality nodes according to Prometheus index evaluation
	LoadBalanceMode          string `yaml:"load_balance_mode"`
	ReadConsistenceLevel     string `yaml:"read_consistence_level"`
	ConsistenceTimeout       int    `yaml:"consistence_timeout"`
	ConsistenceTimeoutAction int    `yaml:"consistence_timeout_action"`

	// pg prometheus configuration, help to choose perfect exec node
	PgPrometheusAddr    string   `yaml:"pg_prometheus_addr"`
	MonitorPgNodes      []string `yaml:"monitor_pg_node"`
	PgExporterName      string   `yaml:"pg_exporter_name"`
	NodeExporterName    string   `yaml:"node_exporter_name"`
	NodeCpuMode         string   `yaml:"node_cpu_mode"`
	TimeInterval        string   `yaml:"statistics_time_interval"`
	PgDataDiskName      string   `yaml:"pg_data_disk_device_name"`
	MetricsReqInterval  int      `yaml:"metrics_req_interval"`
	LsnCacheReqInterval int      `yaml:"lsn_cache_req_interval"`
}

node

type SchemaConfig

type SchemaConfig struct {
	User      string        `yaml:"user"`
	Nodes     []string      `yaml:"nodes"`
	Default   string        `yaml:"default"` //default node
	ShardRule []ShardConfig `yaml:"shard"`   //route rule
}

schema

type ShardConfig

type ShardConfig struct {
	DB            string   `yaml:"db"`
	Table         string   `yaml:"table"`
	Key           string   `yaml:"key"`
	Nodes         []string `yaml:"nodes"`
	Locations     []int    `yaml:"locations"`
	Type          string   `yaml:"type"`
	TableRowLimit int      `yaml:"table_row_limit"`
	DateRange     []string `yaml:"date_range"`
}

range,hash or date

type UserConfig

type UserConfig struct {
	User     string `yaml:"user"`
	Password string `yaml:"password"`
}

user_list

Jump to

Keyboard shortcuts

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