提交 56868fec authored 作者: mooncake9527's avatar mooncake9527

update

上级 55416191
abc123456 app:
\ No newline at end of file name: "operator-admin"
env: "dev"
version: "v0.0.1"
host: "0.0.0.0"
enableStat: false
enableMetrics: true
enableHTTPProfile: true
enableLimit: false
enableCircuitBreaker: false
enableTrace: false
tracingSamplingRate: 1.0
registryDiscoveryType: "consul"
cacheType: "memory"
rentServiceInfo:
ipRateLimiter:
enable: true
window: 1m
maxRequests: 600
sync: true
http:
port: 8080
timeout: 0
logger:
level: "debug"
format: "console"
isSave: true
logFileConfig:
filename: "/data/operator-admin.log"
maxSize: 100
maxBackups: 100000
maxAge: 360
isCompression: true
database:
- name: "wz_qitu"
driver: "mysql"
mysql:
dsn: "root:123456@tcp(mysql-svc.default)/wz_qitu?parseTime=true&loc=Local&charset=utf8,utf8mb4"
enableLog: true
maxIdleConns: 10
maxOpenConns: 100
connMaxLifetime: 30
redis:
dsn: "default:password123@redis-svc.default:6379/6" # local
dialTimeout: 10
readTimeout: 2
writeTimeout: 2
extend:
aliOss:
endpoint: https://oss-cn-hangzhou.aliyuncs.com
access-key-id: LTAI5tD3VA4pi1pcz48yYgXL
access-key-secret: sus17wfcbjB6J9hDeJXXFtJf9LPN0S
bucket-name: test-wz-main
base-path: fota/upgrade
region-id: oss-cn-hangzhou
bucket-url: https://test-wz-main.oss-cn-hangzhou.aliyuncs.com
third-party:
baofu:
bct-terminal-id: ""
bct-member-id: ""
bct-version: "1.0.0"
wx:
app-id: ""
app-secret: ""
\ No newline at end of file
...@@ -24,14 +24,13 @@ type NacosClient struct { ...@@ -24,14 +24,13 @@ type NacosClient struct {
e error e error
} }
func (x *NacosClient) SetCfg(cfg *NacosConfig) *NacosClient { type Parser func(content string) (err error)
x.cfg = cfg
return x
}
func (x *NacosClient) SetParseFn(fn func(content string) (err error)) *NacosClient { func New(cfg *NacosConfig, p Parser) *NacosClient {
x.parseFn = fn nc := NacosClient{}
return x nc.cfg = cfg
nc.parseFn = p
return &nc
} }
func (x *NacosClient) Err() error { func (x *NacosClient) Err() error {
...@@ -51,8 +50,8 @@ func (x *NacosClient) Connect() *NacosClient { ...@@ -51,8 +50,8 @@ func (x *NacosClient) Connect() *NacosClient {
NamespaceId: "", NamespaceId: "",
CacheDir: "cache", CacheDir: "cache",
NotLoadCacheAtStart: false, NotLoadCacheAtStart: false,
LogDir: "log", LogDir: "", // 禁用原生日志文件
LogLevel: "debug", LogLevel: "", // 禁用控制台日志
} }
serverConfigs := make([]constant.ServerConfig, 0, len(x.cfg.IPs)) serverConfigs := make([]constant.ServerConfig, 0, len(x.cfg.IPs))
for _, ip := range x.cfg.IPs { for _, ip := range x.cfg.IPs {
......
...@@ -12,8 +12,7 @@ func TestNacosClient_Parse(t *testing.T) { ...@@ -12,8 +12,7 @@ func TestNacosClient_Parse(t *testing.T) {
DataID: "pay-admin.yaml", DataID: "pay-admin.yaml",
Group: "qitu", Group: "qitu",
} }
nc := NacosClient{} if err := New(&ncfg, func(content string) (err error) {
if err := nc.SetCfg(&ncfg).SetParseFn(func(content string) (err error) {
fmt.Println(content) fmt.Println(content)
return nil return nil
}).Connect().Watch().Fetch().Parse().Err(); err != nil { }).Connect().Watch().Fetch().Parse().Err(); err != nil {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论