<commit_before>package config

import (
	"gopkg.in/yaml.v2"
	"io/ioutil"
	"runtime"
)

// ConfYaml is config structure.
type ConfYaml struct {
	Core    SectionCore    `yaml:"core"`
	API     SectionAPI     `yaml:"api"`
	Android SectionAndroid `yaml:"android"`
	Ios     SectionIos     `yaml:"ios"`
	Log     SectionLog     `yaml:"log"`
	Stat    SectionStat    `yaml:"stat"`
}

// SectionCore is sub seciont of config.
type SectionCore struct {
	Port            string     `yaml:"port"`
	MaxNotification int64      `yaml:"max_notification"`
	WorkerNum       int64      `yaml:"worker_num"`
	QueueNum        int64      `yaml:"queue_num"`
	Mode            string     `yaml:"mode"`
	SSL             bool       `yaml:"ssl"`
	CertPath        string     `yaml:"cert_path"`
	KeyPath         string     `yaml:"key_path"`
	HTTPProxy       string     `yaml:"http_proxy"`
	PID             SectionPID `yaml:"pid"`
}

// SectionAPI is sub seciont of config.
type SectionAPI struct {
	PushURI    string `yaml:"push_uri"`
	StatGoURI  string `yaml:"stat_go_uri"`
	StatAppURI string `yaml:"stat_app_uri"`
	ConfigURI  string `yaml:"config_uri"`
	SysStatURI string `yaml:"sys_stat_uri"`
}

// SectionAndroid is sub seciont of config.
type SectionAndroid struct {
	Enabled bool   `yaml:"enabled"`
	APIKey  string `yaml:"apikey"`
}

// SectionIos is sub seciont of config.
type SectionIos struct {
	Enabled    bool   `yaml:"enabled"`
	KeyPath    string `yaml:"key_path"`
	Password   string `yaml:"password"`
	Production bool   `yaml:"production"`
}

// SectionLog is sub seciont of config.
type SectionLog struct {
	Format      string `yaml:"format"`
	AccessLog   string `yaml:"access_log"`
	AccessLevel string `yaml:"access_level"`
	ErrorLog    string `yaml:"error_log"`
	ErrorLevel  string `yaml:"error_level"`
	HideToken   bool   `yaml:"hide_token"`
}

// SectionStat is sub seciont of config.
type SectionStat struct {
	Engine  string         `yaml:"engine"`
	Redis   SectionRedis   `yaml:"redis"`
	BoltDB  SectionBoltDB  `yaml:"boltdb"`
	BuntDB  SectionBuntDB  `yaml:"buntdb"`
	LevelDB SectionLevelDB `yaml:"leveldb"`
}

// SectionRedis is sub seciont of config.
type SectionRedis struct {
	Addr     string `yaml:"addr"`
	Password string `yaml:"password"`
	DB       int    `yaml:"db"`
}

// SectionBoltDB is sub seciont of config.
type SectionBoltDB struct {
	Path   string `yaml:"path"`
	Bucket string `yaml:"bucket"`
}

// SectionBuntDB is sub seciont of config.
type SectionBuntDB struct {
	Path string `yaml:"path"`
}

// SectionLevelDB is sub seciont of config.
type SectionLevelDB struct {
	Path string `yaml:"path"`
}

// SectionPID is sub seciont of config.
type SectionPID struct {
	Enabled  bool   `yaml:"enabled"`
	Path     string `yaml:"path"`
	Override bool   `yaml:"override"`
}

// BuildDefaultPushConf is default config setting.
func BuildDefaultPushConf() ConfYaml {
	var conf ConfYaml

	// Core
	conf.Core.Port = "8088"
	conf.Core.WorkerNum = int64(runtime.NumCPU())
	conf.Core.QueueNum = int64(8192)
	conf.Core.Mode = "release"
	conf.Core.SSL = false
	conf.Core.CertPath = "cert.pem"
	conf.Core.KeyPath = "key.pem"
	conf.Core.MaxNotification = int64(100)
	conf.Core.HTTPProxy = ""
	conf.Core.PID.Enabled = false
	conf.Core.PID.Path = "gorush.pid"
	conf.Core.PID.Override = false

	// Api
	conf.API.PushURI = "/api/push"<commit_msg>fix typo.<commit_after>package config

import (
	"gopkg.in/yaml.v2"
	"io/ioutil"
	"runtime"
)

// ConfYaml is config structure.
type ConfYaml struct {
	Core    SectionCore    `yaml:"core"`
	API     SectionAPI     `yaml:"api"`
	Android SectionAndroid `yaml:"android"`
	Ios     SectionIos     `yaml:"ios"`
	Log     SectionLog     `yaml:"log"`
	Stat    SectionStat    `yaml:"stat"`
}

// SectionCore is sub section of config.
type SectionCore struct {
	Port            string     `yaml:"port"`
	MaxNotification int64      `yaml:"max_notification"`
	WorkerNum       int64      `yaml:"worker_num"`
	QueueNum        int64      `yaml:"queue_num"`
	Mode            string     `yaml:"mode"`
	SSL             bool       `yaml:"ssl"`
	CertPath        string     `yaml:"cert_path"`
	KeyPath         string     `yaml:"key_path"`
	HTTPProxy       string     `yaml:"http_proxy"`
	PID             SectionPID `yaml:"pid"`
}

// SectionAPI is sub section of config.
type SectionAPI struct {
	PushURI    string `yaml:"push_uri"`
	StatGoURI  string `yaml:"stat_go_uri"`
	StatAppURI string `yaml:"stat_app_uri"`
	ConfigURI  string `yaml:"config_uri"`
	SysStatURI string `yaml:"sys_stat_uri"`
}

// SectionAndroid is sub section of config.
type SectionAndroid struct {
	Enabled bool   `yaml:"enabled"`
	APIKey  string `yaml:"apikey"`
}

// SectionIos is sub section of config.
type SectionIos struct {
	Enabled    bool   `yaml:"enabled"`
	KeyPath    string `yaml:"key_path"`
	Password   string `yaml:"password"`
	Production bool   `yaml:"production"`
}

// SectionLog is sub section of config.
type SectionLog struct {
	Format      string `yaml:"format"`
	AccessLog   string `yaml:"access_log"`
	AccessLevel string `yaml:"access_level"`
	ErrorLog    string `yaml:"error_log"`
	ErrorLevel  string `yaml:"error_level"`
	HideToken   bool   `yaml:"hide_token"`
}

// SectionStat is sub section of config.
type SectionStat struct {
	Engine  string         `yaml:"engine"`
	Redis   SectionRedis   `yaml:"redis"`
	BoltDB  SectionBoltDB  `yaml:"boltdb"`
	BuntDB  SectionBuntDB  `yaml:"buntdb"`
	LevelDB SectionLevelDB `yaml:"leveldb"`
}

// SectionRedis is sub section of config.
type SectionRedis struct {
	Addr     string `yaml:"addr"`
	Password string `yaml:"password"`
	DB       int    `yaml:"db"`
}

// SectionBoltDB is sub section of config.
type SectionBoltDB struct {
	Path   string `yaml:"path"`
	Bucket string `yaml:"bucket"`
}

// SectionBuntDB is sub section of config.
type SectionBuntDB struct {
	Path string `yaml:"path"`
}

// SectionLevelDB is sub section of config.
type SectionLevelDB struct {
	Path string `yaml:"path"`
}

// SectionPID is sub section of config.
type SectionPID struct {
	Enabled  bool   `yaml:"enabled"`
	Path     string `yaml:"path"`
	Override bool   `yaml:"override"`
}

// BuildDefaultPushConf is default config setting.
func BuildDefaultPushConf() ConfYaml {
	var conf ConfYaml

	// Core
	conf.Core.Port = "8088"
	conf.Core.WorkerNum = int64(runtime.NumCPU())
	conf.Core.QueueNum = int64(8192)
	conf.Core.Mode = "release"
	conf.Core.SSL = false
	conf.Core.CertPath = "cert.pem"
	conf.Core.KeyPath = "key.pem"
	conf.Core.MaxNotification = int64(100)
	conf.Core.HTTPProxy = ""
	conf.Core.PID.Enabled = false
	conf.Core.PID.Path = "gorush.pid"
	conf.Core.PID.Override = false

	// Api
	conf.API.PushURI = "/api/push"
{'fraction_non_alphanumeric': 0.11887586414186956, 'fraction_numerical': 0.007213706041478809, 'mean_word_length': 3.4455577822311287, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '60091', 'n_tokens_mistral': 2235, 'n_tokens_neox': 2190, 'n_words': 588}