2020-09-12 08:57:37 +00:00
|
|
|
package conf
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
2020-09-18 07:44:09 +00:00
|
|
|
"path"
|
|
|
|
"runtime"
|
2020-09-22 07:26:38 +00:00
|
|
|
|
2020-11-04 09:58:43 +00:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
|
|
|
|
|
2020-10-19 10:31:00 +00:00
|
|
|
storagetype "github.com/zilliztech/milvus-distributed/internal/storage/type"
|
2020-09-22 07:26:38 +00:00
|
|
|
yaml "gopkg.in/yaml.v2"
|
2020-09-12 08:57:37 +00:00
|
|
|
)
|
|
|
|
|
2020-11-04 09:58:43 +00:00
|
|
|
type UniqueID = typeutil.UniqueID
|
|
|
|
|
2020-09-12 08:57:37 +00:00
|
|
|
// yaml.MapSlice
|
|
|
|
|
|
|
|
type MasterConfig struct {
|
2020-09-22 13:10:51 +00:00
|
|
|
Address string
|
|
|
|
Port int32
|
2020-11-18 11:46:18 +00:00
|
|
|
PulsarMonitorInterval int32
|
2020-09-22 07:26:38 +00:00
|
|
|
PulsarTopic string
|
2020-11-18 11:46:18 +00:00
|
|
|
SegmentThreshold float32
|
|
|
|
SegmentExpireDuration int64
|
2020-11-12 04:04:12 +00:00
|
|
|
ProxyIDList []UniqueID
|
2020-09-23 11:51:14 +00:00
|
|
|
QueryNodeNum int
|
|
|
|
WriteNodeNum int
|
2020-09-12 08:57:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type EtcdConfig struct {
|
|
|
|
Address string
|
|
|
|
Port int32
|
|
|
|
Rootpath string
|
|
|
|
Segthreshold int64
|
|
|
|
}
|
|
|
|
|
|
|
|
type TimeSyncConfig struct {
|
|
|
|
Interval int32
|
|
|
|
}
|
|
|
|
|
|
|
|
type StorageConfig struct {
|
2020-10-15 13:31:50 +00:00
|
|
|
Driver storagetype.DriverType
|
2020-09-12 08:57:37 +00:00
|
|
|
Address string
|
|
|
|
Port int32
|
|
|
|
Accesskey string
|
|
|
|
Secretkey string
|
|
|
|
}
|
|
|
|
|
|
|
|
type PulsarConfig struct {
|
2020-10-15 13:31:50 +00:00
|
|
|
Authentication bool
|
|
|
|
User string
|
|
|
|
Token string
|
|
|
|
Address string
|
|
|
|
Port int32
|
|
|
|
TopicNum int
|
2020-09-12 08:57:37 +00:00
|
|
|
}
|
|
|
|
|
2020-10-15 08:32:22 +00:00
|
|
|
type ProxyConfig struct {
|
|
|
|
Timezone string `yaml:"timezone"`
|
2020-11-12 04:04:12 +00:00
|
|
|
ProxyID int `yaml:"proxy_id"`
|
2020-10-15 08:32:22 +00:00
|
|
|
NumReaderNodes int `yaml:"numReaderNodes"`
|
|
|
|
TosSaveInterval int `yaml:"tsoSaveInterval"`
|
|
|
|
TimeTickInterval int `yaml:"timeTickInterval"`
|
|
|
|
PulsarTopics struct {
|
|
|
|
ReaderTopicPrefix string `yaml:"readerTopicPrefix"`
|
|
|
|
NumReaderTopics int `yaml:"numReaderTopics"`
|
|
|
|
DeleteTopic string `yaml:"deleteTopic"`
|
|
|
|
QueryTopic string `yaml:"queryTopic"`
|
|
|
|
ResultTopic string `yaml:"resultTopic"`
|
|
|
|
ResultGroup string `yaml:"resultGroup"`
|
|
|
|
TimeTickTopic string `yaml:"timeTickTopic"`
|
|
|
|
} `yaml:"pulsarTopics"`
|
|
|
|
Network struct {
|
|
|
|
Address string `yaml:"address"`
|
|
|
|
Port int `yaml:"port"`
|
|
|
|
} `yaml:"network"`
|
|
|
|
Logs struct {
|
|
|
|
Level string `yaml:"level"`
|
|
|
|
TraceEnable bool `yaml:"trace.enable"`
|
|
|
|
Path string `yaml:"path"`
|
|
|
|
MaxLogFileSize string `yaml:"max_log_file_size"`
|
|
|
|
LogRotateNum int `yaml:"log_rotate_num"`
|
|
|
|
} `yaml:"logs"`
|
|
|
|
Storage struct {
|
|
|
|
Path string `yaml:"path"`
|
|
|
|
AutoFlushInterval int `yaml:"auto_flush_interval"`
|
|
|
|
} `yaml:"storage"`
|
|
|
|
}
|
2020-09-12 08:57:37 +00:00
|
|
|
|
2020-09-22 13:10:51 +00:00
|
|
|
type Reader struct {
|
2020-11-12 04:04:12 +00:00
|
|
|
ClientID int
|
2020-09-23 11:51:14 +00:00
|
|
|
StopFlag int64
|
|
|
|
ReaderQueueSize int
|
|
|
|
SearchChanSize int
|
|
|
|
Key2SegChanSize int
|
|
|
|
TopicStart int
|
|
|
|
TopicEnd int
|
2020-09-22 13:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Writer struct {
|
2020-11-12 04:04:12 +00:00
|
|
|
ClientID int
|
2020-09-22 13:10:51 +00:00
|
|
|
StopFlag int64
|
|
|
|
ReaderQueueSize int
|
2020-11-12 04:04:12 +00:00
|
|
|
SearchByIDChanSize int
|
2020-10-15 13:31:50 +00:00
|
|
|
Parallelism int
|
2020-09-23 11:51:14 +00:00
|
|
|
TopicStart int
|
|
|
|
TopicEnd int
|
2020-10-15 13:31:50 +00:00
|
|
|
Bucket string
|
2020-09-22 13:10:51 +00:00
|
|
|
}
|
|
|
|
|
2020-09-12 08:57:37 +00:00
|
|
|
type ServerConfig struct {
|
|
|
|
Master MasterConfig
|
|
|
|
Etcd EtcdConfig
|
|
|
|
Timesync TimeSyncConfig
|
|
|
|
Storage StorageConfig
|
|
|
|
Pulsar PulsarConfig
|
2020-09-22 13:10:51 +00:00
|
|
|
Writer Writer
|
|
|
|
Reader Reader
|
2020-10-15 08:32:22 +00:00
|
|
|
Proxy ProxyConfig
|
2020-09-12 08:57:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var Config ServerConfig
|
|
|
|
|
2020-10-15 13:31:50 +00:00
|
|
|
// func init() {
|
|
|
|
// load_config()
|
|
|
|
// }
|
2020-09-12 08:57:37 +00:00
|
|
|
|
2020-10-19 10:31:00 +00:00
|
|
|
func getConfigsDir() string {
|
2020-09-22 07:26:38 +00:00
|
|
|
_, fpath, _, _ := runtime.Caller(0)
|
2020-10-19 10:31:00 +00:00
|
|
|
configPath := path.Dir(fpath) + "/../../configs/"
|
|
|
|
configPath = path.Dir(configPath)
|
|
|
|
return configPath
|
2020-09-18 07:44:09 +00:00
|
|
|
}
|
|
|
|
|
2020-10-19 10:31:00 +00:00
|
|
|
func LoadConfigWithPath(yamlFilePath string) {
|
|
|
|
source, err := ioutil.ReadFile(yamlFilePath)
|
2020-09-12 08:57:37 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
err = yaml.Unmarshal(source, &Config)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
//fmt.Printf("Result: %v\n", Config)
|
|
|
|
}
|
2020-10-15 13:31:50 +00:00
|
|
|
|
|
|
|
func LoadConfig(yamlFile string) {
|
2020-10-19 10:31:00 +00:00
|
|
|
filePath := path.Join(getConfigsDir(), yamlFile)
|
|
|
|
LoadConfigWithPath(filePath)
|
2020-10-15 13:31:50 +00:00
|
|
|
}
|