2022-01-10 23:59:43 +08:00
|
|
|
|
// Licensed to the LF AI & Data foundation under one
|
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
|
// distributed with this work for additional information
|
|
|
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
|
|
|
// to you under the Apache License, Version 2.0 (the
|
|
|
|
|
// "License"); you may not use this file except in compliance
|
2021-06-18 15:20:08 +08:00
|
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
|
//
|
2022-01-10 23:59:43 +08:00
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2021-06-18 15:20:08 +08:00
|
|
|
|
//
|
2022-01-10 23:59:43 +08:00
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
2021-06-18 15:20:08 +08:00
|
|
|
|
|
|
|
|
|
package paramtable
|
|
|
|
|
|
|
|
|
|
import (
|
2022-11-11 10:55:05 +08:00
|
|
|
|
"encoding/json"
|
2022-08-01 10:04:33 +08:00
|
|
|
|
"net/url"
|
2021-08-24 09:45:51 +08:00
|
|
|
|
"os"
|
2021-12-21 15:53:51 +08:00
|
|
|
|
"path"
|
2022-02-07 10:09:45 +08:00
|
|
|
|
"strconv"
|
2021-08-24 09:45:51 +08:00
|
|
|
|
"strings"
|
2021-06-18 15:20:08 +08:00
|
|
|
|
|
2022-08-01 10:04:33 +08:00
|
|
|
|
"go.uber.org/zap"
|
2023-04-06 19:14:32 +08:00
|
|
|
|
|
|
|
|
|
"github.com/milvus-io/milvus/pkg/log"
|
|
|
|
|
"github.com/milvus-io/milvus/pkg/util"
|
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/metricsinfo"
|
2021-06-18 15:20:08 +08:00
|
|
|
|
)
|
|
|
|
|
|
2022-02-08 20:57:47 +08:00
|
|
|
|
const (
|
|
|
|
|
// SuggestPulsarMaxMessageSize defines the maximum size of Pulsar message.
|
|
|
|
|
SuggestPulsarMaxMessageSize = 5 * 1024 * 1024
|
2022-02-25 15:03:53 +08:00
|
|
|
|
defaultEtcdLogLevel = "info"
|
2022-03-10 10:35:59 +08:00
|
|
|
|
defaultEtcdLogPath = "stdout"
|
2022-08-25 11:02:53 +08:00
|
|
|
|
KafkaProducerConfigPrefix = "kafka.producer."
|
|
|
|
|
KafkaConsumerConfigPrefix = "kafka.consumer."
|
2022-02-08 20:57:47 +08:00
|
|
|
|
)
|
|
|
|
|
|
2022-02-09 14:41:45 +08:00
|
|
|
|
// ServiceParam is used to quickly and easily access all basic service configurations.
|
2022-02-08 20:57:47 +08:00
|
|
|
|
type ServiceParam struct {
|
2021-06-18 15:20:08 +08:00
|
|
|
|
BaseTable
|
|
|
|
|
|
2022-04-07 22:05:32 +08:00
|
|
|
|
LocalStorageCfg LocalStorageConfig
|
2022-08-11 12:12:38 +08:00
|
|
|
|
MetaStoreCfg MetaStoreConfig
|
2022-04-07 22:05:32 +08:00
|
|
|
|
EtcdCfg EtcdConfig
|
2022-08-11 12:12:38 +08:00
|
|
|
|
DBCfg MetaDBConfig
|
2023-06-07 10:00:37 +08:00
|
|
|
|
MQCfg MQConfig
|
2022-04-07 22:05:32 +08:00
|
|
|
|
PulsarCfg PulsarConfig
|
2022-04-12 19:47:33 +08:00
|
|
|
|
KafkaCfg KafkaConfig
|
2022-04-07 22:05:32 +08:00
|
|
|
|
RocksmqCfg RocksmqConfig
|
2023-06-07 10:00:37 +08:00
|
|
|
|
NatsmqCfg NatsmqConfig
|
2022-04-07 22:05:32 +08:00
|
|
|
|
MinioCfg MinioConfig
|
2021-06-18 15:20:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-19 14:53:44 +08:00
|
|
|
|
func (p *ServiceParam) init() {
|
2023-05-06 17:34:39 +08:00
|
|
|
|
p.BaseTable.init(2)
|
2022-02-07 10:09:45 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.LocalStorageCfg.Init(&p.BaseTable)
|
|
|
|
|
p.MetaStoreCfg.Init(&p.BaseTable)
|
|
|
|
|
p.EtcdCfg.Init(&p.BaseTable)
|
2022-12-16 15:59:23 +08:00
|
|
|
|
p.DBCfg.Init(&p.BaseTable)
|
2023-06-07 10:00:37 +08:00
|
|
|
|
p.MQCfg.Init(&p.BaseTable)
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.PulsarCfg.Init(&p.BaseTable)
|
|
|
|
|
p.KafkaCfg.Init(&p.BaseTable)
|
|
|
|
|
p.RocksmqCfg.Init(&p.BaseTable)
|
2023-06-07 10:00:37 +08:00
|
|
|
|
p.NatsmqCfg.Init(&p.BaseTable)
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.MinioCfg.Init(&p.BaseTable)
|
2021-06-18 15:20:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-13 15:31:41 +08:00
|
|
|
|
func (p *ServiceParam) RocksmqEnable() bool {
|
|
|
|
|
return p.RocksmqCfg.Path.GetValue() != ""
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-07 10:00:37 +08:00
|
|
|
|
// NatsmqEnable checks if NATS messaging queue is enabled.
|
|
|
|
|
func (p *ServiceParam) NatsmqEnable() bool {
|
|
|
|
|
return p.NatsmqCfg.ServerStoreDir.GetValue() != ""
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-13 15:31:41 +08:00
|
|
|
|
func (p *ServiceParam) PulsarEnable() bool {
|
|
|
|
|
return p.PulsarCfg.Address.GetValue() != ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *ServiceParam) KafkaEnable() bool {
|
|
|
|
|
return p.KafkaCfg.Address.GetValue() != ""
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-11 10:55:05 +08:00
|
|
|
|
// /////////////////////////////////////////////////////////////////////////////
|
2022-02-07 10:09:45 +08:00
|
|
|
|
// --- etcd ---
|
|
|
|
|
type EtcdConfig struct {
|
|
|
|
|
// --- ETCD ---
|
2022-12-16 15:59:23 +08:00
|
|
|
|
Endpoints ParamItem `refreshable:"false"`
|
|
|
|
|
RootPath ParamItem `refreshable:"false"`
|
|
|
|
|
MetaSubPath ParamItem `refreshable:"false"`
|
|
|
|
|
KvSubPath ParamItem `refreshable:"false"`
|
|
|
|
|
MetaRootPath CompositeParamItem `refreshable:"false"`
|
|
|
|
|
KvRootPath CompositeParamItem `refreshable:"false"`
|
|
|
|
|
EtcdLogLevel ParamItem `refreshable:"false"`
|
|
|
|
|
EtcdLogPath ParamItem `refreshable:"false"`
|
|
|
|
|
EtcdUseSSL ParamItem `refreshable:"false"`
|
|
|
|
|
EtcdTLSCert ParamItem `refreshable:"false"`
|
|
|
|
|
EtcdTLSKey ParamItem `refreshable:"false"`
|
|
|
|
|
EtcdTLSCACert ParamItem `refreshable:"false"`
|
|
|
|
|
EtcdTLSMinVersion ParamItem `refreshable:"false"`
|
2022-02-07 10:09:45 +08:00
|
|
|
|
|
|
|
|
|
// --- Embed ETCD ---
|
2022-12-16 15:59:23 +08:00
|
|
|
|
UseEmbedEtcd ParamItem `refreshable:"false"`
|
|
|
|
|
ConfigPath ParamItem `refreshable:"false"`
|
|
|
|
|
DataDir ParamItem `refreshable:"false"`
|
2021-08-24 09:45:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
func (p *EtcdConfig) Init(base *BaseTable) {
|
|
|
|
|
p.Endpoints = ParamItem{
|
|
|
|
|
Key: "etcd.endpoints",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
DefaultValue: "localhost:2379",
|
2022-11-17 18:59:09 +08:00
|
|
|
|
PanicIfEmpty: true,
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
p.Endpoints.Init(base.mgr)
|
2022-02-07 10:09:45 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.UseEmbedEtcd = ParamItem{
|
|
|
|
|
Key: "etcd.use.embed",
|
|
|
|
|
DefaultValue: "false",
|
|
|
|
|
Version: "2.1.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "Whether to enable embedded Etcd (an in-process EtcdServer).",
|
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
p.UseEmbedEtcd.Init(base.mgr)
|
2021-08-24 09:45:51 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
if p.UseEmbedEtcd.GetAsBool() && (os.Getenv(metricsinfo.DeployModeEnvKey) != metricsinfo.StandaloneDeployMode) {
|
2021-08-24 09:45:51 +08:00
|
|
|
|
panic("embedded etcd can not be used under distributed mode")
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-16 15:59:23 +08:00
|
|
|
|
p.ConfigPath = ParamItem{
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Key: "etcd.config.path",
|
|
|
|
|
Version: "2.1.0",
|
|
|
|
|
Export: false,
|
2022-12-16 15:59:23 +08:00
|
|
|
|
}
|
|
|
|
|
p.ConfigPath.Init(base.mgr)
|
|
|
|
|
|
|
|
|
|
p.DataDir = ParamItem{
|
|
|
|
|
Key: "etcd.data.dir",
|
|
|
|
|
DefaultValue: "default.etcd",
|
|
|
|
|
Version: "2.1.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: `Embedded Etcd only. please adjust in embedded Milvus: /tmp/milvus/etcdData/`,
|
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
2022-12-16 15:59:23 +08:00
|
|
|
|
p.DataDir.Init(base.mgr)
|
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.RootPath = ParamItem{
|
|
|
|
|
Key: "etcd.rootPath",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
DefaultValue: "by-dev",
|
2022-11-17 18:59:09 +08:00
|
|
|
|
PanicIfEmpty: true,
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "The root path where data is stored in etcd",
|
|
|
|
|
Export: true,
|
2021-08-24 09:45:51 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.RootPath.Init(base.mgr)
|
2021-08-24 09:45:51 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.MetaSubPath = ParamItem{
|
|
|
|
|
Key: "etcd.metaSubPath",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
DefaultValue: "meta",
|
2022-11-17 18:59:09 +08:00
|
|
|
|
PanicIfEmpty: true,
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "metaRootPath = rootPath + '/' + metaSubPath",
|
|
|
|
|
Export: true,
|
2021-08-24 09:45:51 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.MetaSubPath.Init(base.mgr)
|
|
|
|
|
|
|
|
|
|
p.MetaRootPath = CompositeParamItem{
|
|
|
|
|
Items: []*ParamItem{&p.RootPath, &p.MetaSubPath},
|
|
|
|
|
Format: func(kvs map[string]string) string {
|
2022-12-07 18:01:19 +08:00
|
|
|
|
return path.Join(kvs[p.RootPath.Key], kvs[p.MetaSubPath.Key])
|
2022-11-17 18:59:09 +08:00
|
|
|
|
},
|
2021-08-24 09:45:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.KvSubPath = ParamItem{
|
|
|
|
|
Key: "etcd.kvSubPath",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
DefaultValue: "kv",
|
2022-11-17 18:59:09 +08:00
|
|
|
|
PanicIfEmpty: true,
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "kvRootPath = rootPath + '/' + kvSubPath",
|
|
|
|
|
Export: true,
|
2021-08-24 09:45:51 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.KvSubPath.Init(base.mgr)
|
|
|
|
|
|
|
|
|
|
p.KvRootPath = CompositeParamItem{
|
|
|
|
|
Items: []*ParamItem{&p.RootPath, &p.KvSubPath},
|
|
|
|
|
Format: func(kvs map[string]string) string {
|
2022-12-07 18:01:19 +08:00
|
|
|
|
return path.Join(kvs[p.RootPath.Key], kvs[p.KvSubPath.Key])
|
2022-11-17 18:59:09 +08:00
|
|
|
|
},
|
2021-08-24 09:45:51 +08:00
|
|
|
|
}
|
2022-02-07 10:09:45 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.EtcdLogLevel = ParamItem{
|
|
|
|
|
Key: "etcd.log.level",
|
|
|
|
|
DefaultValue: defaultEtcdLogLevel,
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "Only supports debug, info, warn, error, panic, or fatal. Default 'info'.",
|
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
p.EtcdLogLevel.Init(base.mgr)
|
2022-02-25 15:03:53 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.EtcdLogPath = ParamItem{
|
|
|
|
|
Key: "etcd.log.path",
|
|
|
|
|
DefaultValue: defaultEtcdLogPath,
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: `path is one of:
|
|
|
|
|
- "default" as os.Stderr,
|
|
|
|
|
- "stderr" as os.Stderr,
|
|
|
|
|
- "stdout" as os.Stdout,
|
|
|
|
|
- file path to append server logs to.
|
|
|
|
|
please adjust in embedded Milvus: /tmp/milvus/logs/etcd.log`,
|
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
p.EtcdLogPath.Init(base.mgr)
|
2022-03-10 10:35:59 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.EtcdUseSSL = ParamItem{
|
|
|
|
|
Key: "etcd.ssl.enabled",
|
|
|
|
|
DefaultValue: "false",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "Whether to support ETCD secure connection mode",
|
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
p.EtcdUseSSL.Init(base.mgr)
|
2022-05-20 12:29:19 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.EtcdTLSCert = ParamItem{
|
|
|
|
|
Key: "etcd.ssl.tlsCert",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "path to your cert file",
|
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
p.EtcdTLSCert.Init(base.mgr)
|
2022-05-20 12:29:19 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.EtcdTLSKey = ParamItem{
|
|
|
|
|
Key: "etcd.ssl.tlsKey",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "path to your key file",
|
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
p.EtcdTLSKey.Init(base.mgr)
|
2022-05-20 12:29:19 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.EtcdTLSCACert = ParamItem{
|
|
|
|
|
Key: "etcd.ssl.tlsCACert",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "path to your CACert file",
|
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
p.EtcdTLSCACert.Init(base.mgr)
|
2022-05-20 12:29:19 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.EtcdTLSMinVersion = ParamItem{
|
|
|
|
|
Key: "etcd.ssl.tlsMinVersion",
|
|
|
|
|
DefaultValue: "1.3",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: `TLS min version
|
|
|
|
|
Optional values: 1.0, 1.1, 1.2, 1.3。
|
|
|
|
|
We recommend using version 1.2 and above.`,
|
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
p.EtcdTLSMinVersion.Init(base.mgr)
|
2022-05-20 12:29:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-07 22:05:32 +08:00
|
|
|
|
type LocalStorageConfig struct {
|
2022-12-16 15:59:23 +08:00
|
|
|
|
Path ParamItem `refreshable:"false"`
|
2022-04-07 22:05:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
func (p *LocalStorageConfig) Init(base *BaseTable) {
|
|
|
|
|
p.Path = ParamItem{
|
|
|
|
|
Key: "localStorage.path",
|
|
|
|
|
Version: "2.0.0",
|
|
|
|
|
DefaultValue: "/var/lib/milvus/data",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "please adjust in embedded Milvus: /tmp/milvus/data/",
|
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
p.Path.Init(base.mgr)
|
2022-04-07 22:05:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-11 12:12:38 +08:00
|
|
|
|
type MetaStoreConfig struct {
|
2022-12-16 15:59:23 +08:00
|
|
|
|
MetaStoreType ParamItem `refreshable:"false"`
|
2022-08-11 12:12:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
func (p *MetaStoreConfig) Init(base *BaseTable) {
|
2022-12-07 18:01:19 +08:00
|
|
|
|
p.MetaStoreType = ParamItem{
|
|
|
|
|
Key: "metastore.type",
|
|
|
|
|
Version: "2.2.0",
|
|
|
|
|
DefaultValue: util.MetaStoreTypeEtcd,
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: `Default value: etcd
|
|
|
|
|
Valid values: [etcd, mysql]`,
|
|
|
|
|
Export: true,
|
2022-12-07 18:01:19 +08:00
|
|
|
|
}
|
|
|
|
|
p.MetaStoreType.Init(base.mgr)
|
2022-08-11 12:12:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-11 10:55:05 +08:00
|
|
|
|
// /////////////////////////////////////////////////////////////////////////////
|
2022-08-11 12:12:38 +08:00
|
|
|
|
// --- meta db ---
|
|
|
|
|
type MetaDBConfig struct {
|
2022-12-16 15:59:23 +08:00
|
|
|
|
Username ParamItem `refreshable:"false"`
|
|
|
|
|
Password ParamItem `refreshable:"false"`
|
|
|
|
|
Address ParamItem `refreshable:"false"`
|
|
|
|
|
Port ParamItem `refreshable:"false"`
|
|
|
|
|
DBName ParamItem `refreshable:"false"`
|
|
|
|
|
MaxOpenConns ParamItem `refreshable:"false"`
|
|
|
|
|
MaxIdleConns ParamItem `refreshable:"false"`
|
2022-08-11 12:12:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
func (p *MetaDBConfig) Init(base *BaseTable) {
|
2022-12-07 18:01:19 +08:00
|
|
|
|
p.Username = ParamItem{
|
|
|
|
|
Key: "mysql.username",
|
|
|
|
|
Version: "2.2.0",
|
|
|
|
|
PanicIfEmpty: true,
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-12-07 18:01:19 +08:00
|
|
|
|
}
|
|
|
|
|
p.Username.Init(base.mgr)
|
2022-08-11 12:12:38 +08:00
|
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
|
p.Password = ParamItem{
|
|
|
|
|
Key: "mysql.password",
|
|
|
|
|
Version: "2.2.0",
|
|
|
|
|
PanicIfEmpty: true,
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-08-11 12:12:38 +08:00
|
|
|
|
}
|
2022-12-07 18:01:19 +08:00
|
|
|
|
p.Password.Init(base.mgr)
|
2022-08-11 12:12:38 +08:00
|
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
|
p.Address = ParamItem{
|
|
|
|
|
Key: "mysql.address",
|
|
|
|
|
Version: "2.2.0",
|
|
|
|
|
PanicIfEmpty: true,
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-08-11 12:12:38 +08:00
|
|
|
|
}
|
2022-12-07 18:01:19 +08:00
|
|
|
|
p.Address.Init(base.mgr)
|
2022-08-11 12:12:38 +08:00
|
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
|
p.Port = ParamItem{
|
|
|
|
|
Key: "mysql.port",
|
|
|
|
|
Version: "2.2.0",
|
|
|
|
|
DefaultValue: "3306",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-08-11 12:12:38 +08:00
|
|
|
|
}
|
2022-12-07 18:01:19 +08:00
|
|
|
|
p.Port.Init(base.mgr)
|
2022-08-11 12:12:38 +08:00
|
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
|
p.DBName = ParamItem{
|
|
|
|
|
Key: "mysql.dbName",
|
|
|
|
|
Version: "2.2.0",
|
|
|
|
|
PanicIfEmpty: true,
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-12-07 18:01:19 +08:00
|
|
|
|
}
|
|
|
|
|
p.DBName.Init(base.mgr)
|
2022-08-11 12:12:38 +08:00
|
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
|
p.MaxOpenConns = ParamItem{
|
|
|
|
|
Key: "mysql.maxOpenConns",
|
|
|
|
|
Version: "2.2.0",
|
|
|
|
|
DefaultValue: "20",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-08-11 12:12:38 +08:00
|
|
|
|
}
|
2022-12-07 18:01:19 +08:00
|
|
|
|
p.MaxOpenConns.Init(base.mgr)
|
2022-08-11 12:12:38 +08:00
|
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
|
p.MaxIdleConns = ParamItem{
|
|
|
|
|
Key: "mysql.maxIdleConns",
|
|
|
|
|
Version: "2.2.0",
|
|
|
|
|
DefaultValue: "5",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-12-07 18:01:19 +08:00
|
|
|
|
}
|
|
|
|
|
p.MaxIdleConns.Init(base.mgr)
|
2023-06-07 10:00:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// /////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// --- mq ---
|
2022-08-11 12:12:38 +08:00
|
|
|
|
|
2023-06-07 10:00:37 +08:00
|
|
|
|
// MQConfig represents the configuration settings for the message queue.
|
|
|
|
|
type MQConfig struct {
|
|
|
|
|
Type ParamItem `refreshable:"false"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Init initializes the MQConfig object with a BaseTable.
|
|
|
|
|
func (p *MQConfig) Init(base *BaseTable) {
|
|
|
|
|
p.Type = ParamItem{
|
|
|
|
|
Key: "mq.type",
|
|
|
|
|
Version: "2.3.0",
|
|
|
|
|
DefaultValue: "",
|
|
|
|
|
Doc: `Default value: "default"
|
|
|
|
|
Valid values: [default, pulsar, kafka, rocksmq, natsmq]`,
|
|
|
|
|
Export: true,
|
|
|
|
|
}
|
|
|
|
|
p.Type.Init(base.mgr)
|
2022-08-11 12:12:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-11 10:55:05 +08:00
|
|
|
|
// /////////////////////////////////////////////////////////////////////////////
|
2022-02-07 10:09:45 +08:00
|
|
|
|
// --- pulsar ---
|
|
|
|
|
type PulsarConfig struct {
|
2022-12-16 15:59:23 +08:00
|
|
|
|
Address ParamItem `refreshable:"false"`
|
|
|
|
|
Port ParamItem `refreshable:"false"`
|
|
|
|
|
WebAddress ParamItem `refreshable:"false"`
|
|
|
|
|
WebPort ParamItem `refreshable:"false"`
|
|
|
|
|
MaxMessageSize ParamItem `refreshable:"true"`
|
2022-11-11 10:55:05 +08:00
|
|
|
|
|
|
|
|
|
// support auth
|
2022-12-16 15:59:23 +08:00
|
|
|
|
AuthPlugin ParamItem `refreshable:"false"`
|
|
|
|
|
AuthParams ParamItem `refreshable:"false"`
|
2022-11-11 10:55:05 +08:00
|
|
|
|
|
|
|
|
|
// support tenant
|
2022-12-16 15:59:23 +08:00
|
|
|
|
Tenant ParamItem `refreshable:"false"`
|
|
|
|
|
Namespace ParamItem `refreshable:"false"`
|
2022-02-07 10:09:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
func (p *PulsarConfig) Init(base *BaseTable) {
|
|
|
|
|
p.Port = ParamItem{
|
|
|
|
|
Key: "pulsar.port",
|
|
|
|
|
Version: "2.0.0",
|
|
|
|
|
DefaultValue: "6650",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "Port of Pulsar",
|
|
|
|
|
Export: true,
|
2022-08-02 21:26:33 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.Port.Init(base.mgr)
|
|
|
|
|
|
2022-11-21 17:49:12 +08:00
|
|
|
|
// due to implicit rule of MQ priority,the default address should be empty
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.Address = ParamItem{
|
|
|
|
|
Key: "pulsar.address",
|
|
|
|
|
Version: "2.0.0",
|
2022-11-21 17:49:12 +08:00
|
|
|
|
DefaultValue: "",
|
2022-11-17 18:59:09 +08:00
|
|
|
|
Formatter: func(addr string) string {
|
|
|
|
|
if addr == "" {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
if strings.Contains(addr, ":") {
|
|
|
|
|
return addr
|
|
|
|
|
}
|
|
|
|
|
port, _ := p.Port.get()
|
|
|
|
|
return "pulsar://" + addr + ":" + port
|
|
|
|
|
},
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "Address of pulsar",
|
|
|
|
|
Export: true,
|
2022-02-07 10:09:45 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.Address.Init(base.mgr)
|
2022-02-07 10:09:45 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.WebPort = ParamItem{
|
|
|
|
|
Key: "pulsar.webport",
|
|
|
|
|
Version: "2.0.0",
|
|
|
|
|
DefaultValue: "80",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "Web port of pulsar, if you connect direcly without proxy, should use 8080",
|
|
|
|
|
Export: true,
|
2022-08-02 21:26:33 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.WebPort.Init(base.mgr)
|
|
|
|
|
|
|
|
|
|
p.WebAddress = ParamItem{
|
|
|
|
|
Key: "pulsar.webaddress",
|
|
|
|
|
Version: "2.0.0",
|
|
|
|
|
DefaultValue: "",
|
|
|
|
|
Formatter: func(add string) string {
|
|
|
|
|
pulsarURL, err := url.ParseRequestURI(p.Address.GetValue())
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Info("failed to parse pulsar config, assume pulsar not used", zap.Error(err))
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
return "http://" + pulsarURL.Hostname() + ":" + p.WebPort.GetValue()
|
|
|
|
|
},
|
2022-06-16 17:28:11 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.WebAddress.Init(base.mgr)
|
2022-06-16 17:28:11 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.MaxMessageSize = ParamItem{
|
|
|
|
|
Key: "pulsar.maxMessageSize",
|
|
|
|
|
Version: "2.0.0",
|
|
|
|
|
DefaultValue: strconv.Itoa(SuggestPulsarMaxMessageSize),
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "5 * 1024 * 1024 Bytes, Maximum size of each message in pulsar.",
|
|
|
|
|
Export: true,
|
2022-02-07 10:09:45 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.MaxMessageSize.Init(base.mgr)
|
2022-02-07 10:09:45 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.Tenant = ParamItem{
|
|
|
|
|
Key: "pulsar.tenant",
|
|
|
|
|
Version: "2.2.0",
|
|
|
|
|
DefaultValue: "public",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-11-11 10:55:05 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.Tenant.Init(base.mgr)
|
2022-11-11 10:55:05 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.Namespace = ParamItem{
|
|
|
|
|
Key: "pulsar.namespace",
|
|
|
|
|
Version: "2.2.0",
|
|
|
|
|
DefaultValue: "default",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-11-11 10:55:05 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.Namespace.Init(base.mgr)
|
2022-11-11 10:55:05 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.AuthPlugin = ParamItem{
|
|
|
|
|
Key: "pulsar.authPlugin",
|
|
|
|
|
Version: "2.2.0",
|
|
|
|
|
}
|
|
|
|
|
p.AuthPlugin.Init(base.mgr)
|
|
|
|
|
|
|
|
|
|
p.AuthParams = ParamItem{
|
|
|
|
|
Key: "pulsar.authParams",
|
|
|
|
|
Version: "2.2.0",
|
|
|
|
|
Formatter: func(authParams string) string {
|
|
|
|
|
jsonMap := make(map[string]string)
|
|
|
|
|
params := strings.Split(authParams, ",")
|
|
|
|
|
for _, param := range params {
|
|
|
|
|
kv := strings.Split(param, ":")
|
|
|
|
|
if len(kv) == 2 {
|
|
|
|
|
jsonMap[kv[0]] = kv[1]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
jsonData, _ := json.Marshal(&jsonMap)
|
|
|
|
|
return string(jsonData)
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
p.AuthParams.Init(base.mgr)
|
2022-11-11 10:55:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-12 19:47:33 +08:00
|
|
|
|
// --- kafka ---
|
|
|
|
|
type KafkaConfig struct {
|
2022-12-16 15:59:23 +08:00
|
|
|
|
Address ParamItem `refreshable:"false"`
|
|
|
|
|
SaslUsername ParamItem `refreshable:"false"`
|
|
|
|
|
SaslPassword ParamItem `refreshable:"false"`
|
|
|
|
|
SaslMechanisms ParamItem `refreshable:"false"`
|
|
|
|
|
SecurityProtocol ParamItem `refreshable:"false"`
|
|
|
|
|
ConsumerExtraConfig ParamGroup `refreshable:"false"`
|
|
|
|
|
ProducerExtraConfig ParamGroup `refreshable:"false"`
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (k *KafkaConfig) Init(base *BaseTable) {
|
2022-11-21 17:49:12 +08:00
|
|
|
|
// due to implicit rule of MQ priority,the default address should be empty
|
2022-11-17 18:59:09 +08:00
|
|
|
|
k.Address = ParamItem{
|
|
|
|
|
Key: "kafka.brokerList",
|
|
|
|
|
DefaultValue: "",
|
|
|
|
|
Version: "2.1.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
k.Address.Init(base.mgr)
|
2022-04-12 19:47:33 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
k.SaslUsername = ParamItem{
|
|
|
|
|
Key: "kafka.saslUsername",
|
|
|
|
|
DefaultValue: "",
|
|
|
|
|
Version: "2.1.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
k.SaslUsername.Init(base.mgr)
|
2022-04-12 19:47:33 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
k.SaslPassword = ParamItem{
|
|
|
|
|
Key: "kafka.saslPassword",
|
|
|
|
|
DefaultValue: "",
|
|
|
|
|
Version: "2.1.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
k.SaslPassword.Init(base.mgr)
|
2022-06-02 12:12:03 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
k.SaslMechanisms = ParamItem{
|
|
|
|
|
Key: "kafka.saslMechanisms",
|
|
|
|
|
DefaultValue: "PLAIN",
|
|
|
|
|
Version: "2.1.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
k.SaslMechanisms.Init(base.mgr)
|
2022-06-02 12:12:03 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
k.SecurityProtocol = ParamItem{
|
|
|
|
|
Key: "kafka.securityProtocol",
|
|
|
|
|
DefaultValue: "SASL_SSL",
|
|
|
|
|
Version: "2.1.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
k.SecurityProtocol.Init(base.mgr)
|
2022-06-29 10:32:17 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
k.ConsumerExtraConfig = ParamGroup{
|
|
|
|
|
KeyPrefix: "kafka.consumer.",
|
|
|
|
|
Version: "2.2.0",
|
|
|
|
|
}
|
|
|
|
|
k.ConsumerExtraConfig.Init(base.mgr)
|
2022-06-29 10:32:17 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
k.ProducerExtraConfig = ParamGroup{
|
|
|
|
|
KeyPrefix: "kafka.producer.",
|
|
|
|
|
Version: "2.2.0",
|
|
|
|
|
}
|
|
|
|
|
k.ProducerExtraConfig.Init(base.mgr)
|
2022-08-25 11:02:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-11 10:55:05 +08:00
|
|
|
|
// /////////////////////////////////////////////////////////////////////////////
|
2022-02-07 10:09:45 +08:00
|
|
|
|
// --- rocksmq ---
|
|
|
|
|
type RocksmqConfig struct {
|
2022-12-26 19:11:30 +08:00
|
|
|
|
Path ParamItem `refreshable:"false"`
|
|
|
|
|
LRUCacheRatio ParamItem `refreshable:"false"`
|
|
|
|
|
PageSize ParamItem `refreshable:"false"`
|
|
|
|
|
// RetentionTimeInMinutes is the time of retention
|
|
|
|
|
RetentionTimeInMinutes ParamItem `refreshable:"false"`
|
|
|
|
|
// RetentionSizeInMB is the size of retention
|
|
|
|
|
RetentionSizeInMB ParamItem `refreshable:"false"`
|
|
|
|
|
// CompactionInterval is the Interval we trigger compaction,
|
|
|
|
|
CompactionInterval ParamItem `refreshable:"false"`
|
|
|
|
|
// TickerTimeInSeconds is the time of expired check, default 10 minutes
|
|
|
|
|
TickerTimeInSeconds ParamItem `refreshable:"false"`
|
2023-07-18 20:18:57 +08:00
|
|
|
|
// CompressionTypes is compression type of each level
|
|
|
|
|
// len of CompressionTypes means num of rocksdb level.
|
|
|
|
|
// only support {0,7}, 0 means no compress, 7 means zstd
|
|
|
|
|
// default [0,7].
|
|
|
|
|
CompressionTypes ParamItem `refreshable:"false"`
|
2022-02-07 10:09:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
func (r *RocksmqConfig) Init(base *BaseTable) {
|
|
|
|
|
r.Path = ParamItem{
|
2022-12-26 19:11:30 +08:00
|
|
|
|
Key: "rocksmq.path",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: `The path where the message is stored in rocksmq
|
|
|
|
|
please adjust in embedded Milvus: /tmp/milvus/rdb_data`,
|
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
r.Path.Init(base.mgr)
|
2022-12-26 19:11:30 +08:00
|
|
|
|
|
|
|
|
|
r.LRUCacheRatio = ParamItem{
|
|
|
|
|
Key: "rocksmq.lrucacheratio",
|
|
|
|
|
DefaultValue: "0.0.6",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "rocksdb cache memory ratio",
|
|
|
|
|
Export: true,
|
2022-12-26 19:11:30 +08:00
|
|
|
|
}
|
|
|
|
|
r.LRUCacheRatio.Init(base.mgr)
|
|
|
|
|
|
|
|
|
|
r.PageSize = ParamItem{
|
|
|
|
|
Key: "rocksmq.rocksmqPageSize",
|
2023-03-29 17:08:04 +08:00
|
|
|
|
DefaultValue: strconv.FormatInt(64<<20, 10),
|
2022-12-26 19:11:30 +08:00
|
|
|
|
Version: "2.0.0",
|
2023-04-27 14:26:35 +08:00
|
|
|
|
Doc: "64 MB, 64 * 1024 * 1024 bytes, The size of each page of messages in rocksmq",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-12-26 19:11:30 +08:00
|
|
|
|
}
|
|
|
|
|
r.PageSize.Init(base.mgr)
|
|
|
|
|
|
|
|
|
|
r.RetentionTimeInMinutes = ParamItem{
|
|
|
|
|
Key: "rocksmq.retentionTimeInMinutes",
|
2023-04-27 14:26:35 +08:00
|
|
|
|
DefaultValue: "4320",
|
2022-12-26 19:11:30 +08:00
|
|
|
|
Version: "2.0.0",
|
2023-04-27 14:26:35 +08:00
|
|
|
|
Doc: "3 days, 3 * 24 * 60 minutes, The retention time of the message in rocksmq.",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-12-26 19:11:30 +08:00
|
|
|
|
}
|
|
|
|
|
r.RetentionTimeInMinutes.Init(base.mgr)
|
|
|
|
|
|
|
|
|
|
r.RetentionSizeInMB = ParamItem{
|
|
|
|
|
Key: "rocksmq.retentionSizeInMB",
|
|
|
|
|
DefaultValue: "7200",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "8 GB, 8 * 1024 MB, The retention size of the message in rocksmq.",
|
|
|
|
|
Export: true,
|
2022-12-26 19:11:30 +08:00
|
|
|
|
}
|
|
|
|
|
r.RetentionSizeInMB.Init(base.mgr)
|
|
|
|
|
|
|
|
|
|
r.CompactionInterval = ParamItem{
|
|
|
|
|
Key: "rocksmq.compactionInterval",
|
|
|
|
|
DefaultValue: "86400",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "1 day, trigger rocksdb compaction every day to remove deleted data",
|
|
|
|
|
Export: true,
|
2022-12-26 19:11:30 +08:00
|
|
|
|
}
|
|
|
|
|
r.CompactionInterval.Init(base.mgr)
|
|
|
|
|
|
|
|
|
|
r.TickerTimeInSeconds = ParamItem{
|
|
|
|
|
Key: "rocksmq.timtickerInterval",
|
|
|
|
|
DefaultValue: "600",
|
|
|
|
|
Version: "2.2.2",
|
|
|
|
|
}
|
|
|
|
|
r.TickerTimeInSeconds.Init(base.mgr)
|
2023-07-18 20:18:57 +08:00
|
|
|
|
|
|
|
|
|
r.CompressionTypes = ParamItem{
|
|
|
|
|
Key: "rocksmq.compressionTypes",
|
|
|
|
|
DefaultValue: "0,0,7,7,7",
|
|
|
|
|
Version: "2.2.12",
|
|
|
|
|
}
|
|
|
|
|
r.CompressionTypes.Init(base.mgr)
|
2022-02-07 10:09:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-07 10:00:37 +08:00
|
|
|
|
// NatsmqConfig describes the configuration options for the Nats message queue
|
|
|
|
|
type NatsmqConfig struct {
|
|
|
|
|
ServerPort ParamItem `refreshable:"false"`
|
|
|
|
|
ServerStoreDir ParamItem `refreshable:"false"`
|
|
|
|
|
ServerMaxFileStore ParamItem `refreshable:"false"`
|
|
|
|
|
ServerMaxPayload ParamItem `refreshable:"false"`
|
|
|
|
|
ServerMaxPending ParamItem `refreshable:"false"`
|
|
|
|
|
ServerInitializeTimeout ParamItem `refreshable:"false"`
|
|
|
|
|
ServerMonitorDebug ParamItem `refreshable:"false"`
|
|
|
|
|
ServerMonitorLogTime ParamItem `refreshable:"false"`
|
|
|
|
|
ServerMonitorLogFile ParamItem `refreshable:"false"`
|
|
|
|
|
ServerMonitorLogSizeLimit ParamItem `refreshable:"false"`
|
2023-07-25 19:33:01 +08:00
|
|
|
|
ServerRetentionMaxAge ParamItem `refreshable:"true"`
|
|
|
|
|
ServerRetentionMaxBytes ParamItem `refreshable:"true"`
|
|
|
|
|
ServerRetentionMaxMsgs ParamItem `refreshable:"true"`
|
2023-06-07 10:00:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Init sets up a new NatsmqConfig instance using the provided BaseTable
|
|
|
|
|
func (r *NatsmqConfig) Init(base *BaseTable) {
|
|
|
|
|
r.ServerPort = ParamItem{
|
|
|
|
|
Key: "natsmq.server.port",
|
|
|
|
|
Version: "2.3.0",
|
|
|
|
|
DefaultValue: "4222",
|
|
|
|
|
Doc: `Port for nats server listening`,
|
|
|
|
|
Export: true,
|
|
|
|
|
}
|
|
|
|
|
r.ServerPort.Init(base.mgr)
|
|
|
|
|
r.ServerStoreDir = ParamItem{
|
|
|
|
|
Key: "natsmq.server.storeDir",
|
|
|
|
|
Version: "2.3.0",
|
|
|
|
|
Doc: `Directory to use for JetStream storage of nats`,
|
|
|
|
|
Export: true,
|
|
|
|
|
}
|
|
|
|
|
r.ServerStoreDir.Init(base.mgr)
|
|
|
|
|
r.ServerMaxFileStore = ParamItem{
|
|
|
|
|
Key: "natsmq.server.maxFileStore",
|
|
|
|
|
Version: "2.3.0",
|
|
|
|
|
DefaultValue: "17179869184",
|
|
|
|
|
Doc: `Maximum size of the 'file' storage`,
|
|
|
|
|
Export: true,
|
|
|
|
|
}
|
|
|
|
|
r.ServerMaxFileStore.Init(base.mgr)
|
|
|
|
|
r.ServerMaxPayload = ParamItem{
|
|
|
|
|
Key: "natsmq.server.maxPayload",
|
|
|
|
|
Version: "2.3.0",
|
|
|
|
|
DefaultValue: "8388608",
|
|
|
|
|
Doc: `Maximum number of bytes in a message payload`,
|
|
|
|
|
Export: true,
|
|
|
|
|
}
|
|
|
|
|
r.ServerMaxPayload.Init(base.mgr)
|
|
|
|
|
r.ServerMaxPending = ParamItem{
|
|
|
|
|
Key: "natsmq.server.maxPending",
|
|
|
|
|
Version: "2.3.0",
|
|
|
|
|
DefaultValue: "67108864",
|
|
|
|
|
Doc: `Maximum number of bytes buffered for a connection Applies to client connections`,
|
|
|
|
|
Export: true,
|
|
|
|
|
}
|
|
|
|
|
r.ServerMaxPending.Init(base.mgr)
|
|
|
|
|
r.ServerInitializeTimeout = ParamItem{
|
|
|
|
|
Key: "natsmq.server.initializeTimeout",
|
|
|
|
|
Version: "2.3.0",
|
|
|
|
|
DefaultValue: "4000",
|
|
|
|
|
Doc: `waiting for initialization of natsmq finished`,
|
|
|
|
|
Export: true,
|
|
|
|
|
}
|
|
|
|
|
r.ServerInitializeTimeout.Init(base.mgr)
|
|
|
|
|
|
|
|
|
|
r.ServerMonitorDebug = ParamItem{
|
|
|
|
|
Key: "natsmq.server.monitor.debug",
|
|
|
|
|
Version: "2.3.0",
|
|
|
|
|
DefaultValue: "false",
|
|
|
|
|
Doc: `If true enable debug log messages`,
|
|
|
|
|
Export: true,
|
|
|
|
|
}
|
|
|
|
|
r.ServerMonitorDebug.Init(base.mgr)
|
|
|
|
|
r.ServerMonitorLogTime = ParamItem{
|
|
|
|
|
Key: "natsmq.server.monitor.logTime",
|
|
|
|
|
Version: "2.3.0",
|
|
|
|
|
DefaultValue: "true",
|
|
|
|
|
Doc: `If set to false, log without timestamps.`,
|
|
|
|
|
Export: true,
|
|
|
|
|
}
|
|
|
|
|
r.ServerMonitorLogTime.Init(base.mgr)
|
|
|
|
|
r.ServerMonitorLogFile = ParamItem{
|
|
|
|
|
Key: "natsmq.server.monitor.logFile",
|
|
|
|
|
Version: "2.3.0",
|
|
|
|
|
DefaultValue: "",
|
|
|
|
|
Doc: `Log file path relative to..`,
|
|
|
|
|
Export: true,
|
|
|
|
|
}
|
|
|
|
|
r.ServerMonitorLogFile.Init(base.mgr)
|
|
|
|
|
r.ServerMonitorLogSizeLimit = ParamItem{
|
|
|
|
|
Key: "natsmq.server.monitor.logSizeLimit",
|
|
|
|
|
Version: "2.3.0",
|
|
|
|
|
DefaultValue: "0",
|
|
|
|
|
Doc: `Size in bytes after the log file rolls over to a new one`,
|
|
|
|
|
Export: true,
|
|
|
|
|
}
|
|
|
|
|
r.ServerMonitorLogSizeLimit.Init(base.mgr)
|
2023-07-25 19:33:01 +08:00
|
|
|
|
|
|
|
|
|
r.ServerRetentionMaxAge = ParamItem{
|
|
|
|
|
Key: "natsmq.server.retention.maxAge",
|
|
|
|
|
Version: "2.3.0",
|
|
|
|
|
DefaultValue: "4320",
|
|
|
|
|
Doc: `Maximum age of any message in the P-channel`,
|
|
|
|
|
Export: true,
|
|
|
|
|
}
|
|
|
|
|
r.ServerRetentionMaxAge.Init(base.mgr)
|
|
|
|
|
r.ServerRetentionMaxBytes = ParamItem{
|
|
|
|
|
Key: "natsmq.server.retention.maxBytes",
|
|
|
|
|
Version: "2.3.0",
|
|
|
|
|
DefaultValue: "",
|
|
|
|
|
Doc: `How many bytes the single P-channel may contain. Removing oldest messages if the P-channel exceeds this size`,
|
|
|
|
|
Export: true,
|
|
|
|
|
}
|
|
|
|
|
r.ServerRetentionMaxBytes.Init(base.mgr)
|
|
|
|
|
r.ServerRetentionMaxMsgs = ParamItem{
|
|
|
|
|
Key: "natsmq.server.retention.maxMsgs",
|
|
|
|
|
Version: "2.3.0",
|
|
|
|
|
DefaultValue: "",
|
|
|
|
|
Doc: `How many message the single P-channel may contain. Removing oldest messages if the P-channel exceeds this limit`,
|
|
|
|
|
Export: true,
|
|
|
|
|
}
|
|
|
|
|
r.ServerRetentionMaxMsgs.Init(base.mgr)
|
2023-06-07 10:00:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-11 10:55:05 +08:00
|
|
|
|
// /////////////////////////////////////////////////////////////////////////////
|
2022-02-07 10:09:45 +08:00
|
|
|
|
// --- minio ---
|
|
|
|
|
type MinioConfig struct {
|
2022-12-16 15:59:23 +08:00
|
|
|
|
Address ParamItem `refreshable:"false"`
|
|
|
|
|
Port ParamItem `refreshable:"false"`
|
|
|
|
|
AccessKeyID ParamItem `refreshable:"false"`
|
|
|
|
|
SecretAccessKey ParamItem `refreshable:"false"`
|
|
|
|
|
UseSSL ParamItem `refreshable:"false"`
|
|
|
|
|
BucketName ParamItem `refreshable:"false"`
|
|
|
|
|
RootPath ParamItem `refreshable:"false"`
|
|
|
|
|
UseIAM ParamItem `refreshable:"false"`
|
|
|
|
|
CloudProvider ParamItem `refreshable:"false"`
|
|
|
|
|
IAMEndpoint ParamItem `refreshable:"false"`
|
2023-07-27 19:49:02 +08:00
|
|
|
|
LogLevel ParamItem `refreshable:"false"`
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *MinioConfig) Init(base *BaseTable) {
|
|
|
|
|
p.Port = ParamItem{
|
|
|
|
|
Key: "minio.port",
|
|
|
|
|
DefaultValue: "9000",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "Port of MinIO/S3",
|
|
|
|
|
Export: true,
|
2022-02-07 10:09:45 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.Port.Init(base.mgr)
|
|
|
|
|
|
|
|
|
|
p.Address = ParamItem{
|
|
|
|
|
Key: "minio.address",
|
|
|
|
|
DefaultValue: "",
|
|
|
|
|
Version: "2.0.0",
|
|
|
|
|
Formatter: func(addr string) string {
|
|
|
|
|
if addr == "" {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
if strings.Contains(addr, ":") {
|
|
|
|
|
return addr
|
|
|
|
|
}
|
|
|
|
|
port, _ := p.Port.get()
|
|
|
|
|
return addr + ":" + port
|
|
|
|
|
},
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "Address of MinIO/S3",
|
|
|
|
|
Export: true,
|
2022-08-01 10:04:33 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.Address.Init(base.mgr)
|
2022-02-07 10:09:45 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.AccessKeyID = ParamItem{
|
|
|
|
|
Key: "minio.accessKeyID",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
DefaultValue: "minioadmin",
|
2023-01-19 15:49:44 +08:00
|
|
|
|
PanicIfEmpty: false, // tmp fix, need to be conditional
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "accessKeyID of MinIO/S3",
|
|
|
|
|
Export: true,
|
2022-02-07 10:09:45 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.AccessKeyID.Init(base.mgr)
|
2022-02-07 10:09:45 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.SecretAccessKey = ParamItem{
|
|
|
|
|
Key: "minio.secretAccessKey",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
DefaultValue: "minioadmin",
|
2023-01-19 15:49:44 +08:00
|
|
|
|
PanicIfEmpty: false, // tmp fix, need to be conditional
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "MinIO/S3 encryption string",
|
|
|
|
|
Export: true,
|
2022-02-07 10:09:45 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.SecretAccessKey.Init(base.mgr)
|
2022-02-07 10:09:45 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.UseSSL = ParamItem{
|
|
|
|
|
Key: "minio.useSSL",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
DefaultValue: "false",
|
2022-11-17 18:59:09 +08:00
|
|
|
|
PanicIfEmpty: true,
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "Access to MinIO/S3 with SSL",
|
|
|
|
|
Export: true,
|
2022-02-07 10:09:45 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.UseSSL.Init(base.mgr)
|
2022-02-07 10:09:45 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.BucketName = ParamItem{
|
|
|
|
|
Key: "minio.bucketName",
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
DefaultValue: "a-bucket",
|
2022-11-17 18:59:09 +08:00
|
|
|
|
PanicIfEmpty: true,
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "Bucket name in MinIO/S3",
|
|
|
|
|
Export: true,
|
2022-02-07 10:09:45 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.BucketName.Init(base.mgr)
|
2022-02-07 10:09:45 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.RootPath = ParamItem{
|
|
|
|
|
Key: "minio.rootPath",
|
|
|
|
|
Version: "2.0.0",
|
2023-07-13 14:46:29 +08:00
|
|
|
|
PanicIfEmpty: false,
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: "The root path where the message is stored in MinIO/S3",
|
|
|
|
|
Export: true,
|
2022-02-07 10:09:45 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.RootPath.Init(base.mgr)
|
2022-06-02 19:42:03 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.UseIAM = ParamItem{
|
|
|
|
|
Key: "minio.useIAM",
|
|
|
|
|
DefaultValue: DefaultMinioUseIAM,
|
|
|
|
|
Version: "2.0.0",
|
2023-03-09 16:33:52 +08:00
|
|
|
|
Doc: `Whether to useIAM role to access S3/GCS instead of access/secret keys
|
2023-02-23 11:37:46 +08:00
|
|
|
|
For more information, refer to
|
|
|
|
|
aws: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use.html
|
2023-03-09 16:33:52 +08:00
|
|
|
|
gcp: https://cloud.google.com/storage/docs/access-control/iam
|
|
|
|
|
aliyun (ack): https://www.alibabacloud.com/help/en/container-service-for-kubernetes/latest/use-rrsa-to-enforce-access-control
|
|
|
|
|
aliyun (ecs): https://www.alibabacloud.com/help/en/elastic-compute-service/latest/attach-an-instance-ram-role`,
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-11-01 11:07:35 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.UseIAM.Init(base.mgr)
|
2022-11-01 11:07:35 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.CloudProvider = ParamItem{
|
|
|
|
|
Key: "minio.cloudProvider",
|
|
|
|
|
DefaultValue: DefaultMinioCloudProvider,
|
|
|
|
|
Version: "2.2.0",
|
2023-05-06 17:34:39 +08:00
|
|
|
|
Doc: `Cloud Provider of S3. Supports: "aws", "gcp", "aliyun".
|
2023-02-23 11:37:46 +08:00
|
|
|
|
You can use "aws" for other cloud provider supports S3 API with signature v4, e.g.: minio
|
|
|
|
|
You can use "gcp" for other cloud provider supports S3 API with signature v2
|
2023-05-06 17:34:39 +08:00
|
|
|
|
You can use "aliyun" for other cloud provider uses virtual host style bucket
|
2023-03-09 16:33:52 +08:00
|
|
|
|
When useIAM enabled, only "aws", "gcp", "aliyun" is supported for now`,
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Export: true,
|
2022-11-01 11:07:35 +08:00
|
|
|
|
}
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.CloudProvider.Init(base.mgr)
|
2022-06-02 19:42:03 +08:00
|
|
|
|
|
2022-11-17 18:59:09 +08:00
|
|
|
|
p.IAMEndpoint = ParamItem{
|
|
|
|
|
Key: "minio.iamEndpoint",
|
|
|
|
|
DefaultValue: DefaultMinioIAMEndpoint,
|
|
|
|
|
Version: "2.0.0",
|
2023-02-23 11:37:46 +08:00
|
|
|
|
Doc: `Custom endpoint for fetch IAM role credentials. when useIAM is true & cloudProvider is "aws".
|
|
|
|
|
Leave it empty if you want to use AWS default endpoint`,
|
|
|
|
|
Export: true,
|
2022-11-17 18:59:09 +08:00
|
|
|
|
}
|
|
|
|
|
p.IAMEndpoint.Init(base.mgr)
|
2023-07-27 19:49:02 +08:00
|
|
|
|
p.LogLevel = ParamItem{
|
|
|
|
|
Key: "minio.logLevel",
|
|
|
|
|
DefaultValue: DefaultMinioLogLevel,
|
|
|
|
|
Version: "2.3.0",
|
|
|
|
|
Doc: `Log level for aws sdk log. Supported level: off, fatal, error, warn, info, debug, trace`,
|
|
|
|
|
Export: true,
|
|
|
|
|
}
|
|
|
|
|
p.LogLevel.Init(base.mgr)
|
2022-06-02 19:42:03 +08:00
|
|
|
|
}
|