package indexservice import ( "path" "strconv" "sync" "github.com/zilliztech/milvus-distributed/internal/log" "github.com/zilliztech/milvus-distributed/internal/util/paramtable" ) type ParamTable struct { paramtable.BaseTable Address string Port int MasterAddress string EtcdAddress string KvRootPath string MetaRootPath string MinIOAddress string MinIOAccessKeyID string MinIOSecretAccessKey string MinIOUseSSL bool MinioBucketName string Log log.Config } var Params ParamTable var once sync.Once func (pt *ParamTable) Init() { once.Do(func() { pt.BaseTable.Init() pt.initLogCfg() pt.initEtcdAddress() pt.initMasterAddress() pt.initMetaRootPath() pt.initKvRootPath() pt.initMinIOAddress() pt.initMinIOAccessKeyID() pt.initMinIOSecretAccessKey() pt.initMinIOUseSSL() pt.initMinioBucketName() }) } func (pt *ParamTable) initEtcdAddress() { addr, err := pt.Load("_EtcdAddress") if err != nil { panic(err) } pt.EtcdAddress = addr } func (pt *ParamTable) initMetaRootPath() { rootPath, err := pt.Load("etcd.rootPath") if err != nil { panic(err) } subPath, err := pt.Load("etcd.metaSubPath") if err != nil { panic(err) } pt.MetaRootPath = rootPath + "/" + subPath } func (pt *ParamTable) initKvRootPath() { rootPath, err := pt.Load("etcd.rootPath") if err != nil { panic(err) } subPath, err := pt.Load("etcd.kvSubPath") if err != nil { panic(err) } pt.KvRootPath = rootPath + "/" + subPath } func (pt *ParamTable) initMasterAddress() { ret, err := pt.Load("_MasterAddress") if err != nil { panic(err) } pt.MasterAddress = ret } func (pt *ParamTable) initMinIOAddress() { ret, err := pt.Load("_MinioAddress") if err != nil { panic(err) } pt.MinIOAddress = ret } func (pt *ParamTable) initMinIOAccessKeyID() { ret, err := pt.Load("minio.accessKeyID") if err != nil { panic(err) } pt.MinIOAccessKeyID = ret } func (pt *ParamTable) initMinIOSecretAccessKey() { ret, err := pt.Load("minio.secretAccessKey") if err != nil { panic(err) } pt.MinIOSecretAccessKey = ret } func (pt *ParamTable) initMinIOUseSSL() { ret, err := pt.Load("minio.useSSL") if err != nil { panic(err) } pt.MinIOUseSSL, err = strconv.ParseBool(ret) if err != nil { panic(err) } } func (pt *ParamTable) initMinioBucketName() { bucketName, err := pt.Load("minio.bucketName") if err != nil { panic(err) } pt.MinioBucketName = bucketName } func (pt *ParamTable) initLogCfg() { pt.Log = log.Config{} format, err := pt.Load("log.format") if err != nil { panic(err) } pt.Log.Format = format level, err := pt.Load("log.level") if err != nil { panic(err) } pt.Log.Level = level devStr, err := pt.Load("log.dev") if err != nil { panic(err) } dev, err := strconv.ParseBool(devStr) if err != nil { panic(err) } pt.Log.Development = dev pt.Log.File.MaxSize = pt.ParseInt("log.file.maxSize") pt.Log.File.MaxBackups = pt.ParseInt("log.file.maxBackups") pt.Log.File.MaxDays = pt.ParseInt("log.file.maxAge") rootPath, err := pt.Load("log.file.rootPath") if err != nil { panic(err) } if len(rootPath) != 0 { pt.Log.File.Filename = path.Join(rootPath, "indexservice.log") } else { pt.Log.File.Filename = "" } }