提交 3a3ef000 authored 作者: mooncake9527's avatar mooncake9527

upd

上级 0ecf723d
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
"time" "time"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
alioss "gitlab.wanzhuangkj.com/tush/xpkg/third/oss" "gitlab.wanzhuangkj.com/tush/xpkg/third/oss"
) )
var Cfg = &Config{ var Cfg = &Config{
...@@ -58,8 +58,8 @@ func CronOpen() bool { ...@@ -58,8 +58,8 @@ func CronOpen() bool {
return enable return enable
} }
func GetOssConfig() *alioss.AliOssConfig { func GetOssConfig() *oss.AliOssConfig {
ossCfg := &alioss.AliOssConfig{} ossCfg := &oss.AliOssConfig{}
Read(func(c *Config) { Read(func(c *Config) {
ossCfg.Endpoint = c.Oss.Endpoint ossCfg.Endpoint = c.Oss.Endpoint
ossCfg.AccessKeyId = c.Oss.AccessKeyId ossCfg.AccessKeyId = c.Oss.AccessKeyId
...@@ -109,12 +109,10 @@ type Config struct { ...@@ -109,12 +109,10 @@ type Config struct {
HTTP HTTP `yaml:"http" json:"http"` HTTP HTTP `yaml:"http" json:"http"`
Jaeger Jaeger `yaml:"jaeger" json:"jaeger"` Jaeger Jaeger `yaml:"jaeger" json:"jaeger"`
Logger Logger `yaml:"logger" json:"logger"` Logger Logger `yaml:"logger" json:"logger"`
NacosRd NacosRd `yaml:"nacosRd" json:"nacosRd"`
Redis Redis `yaml:"redis" json:"redis"` Redis Redis `yaml:"redis" json:"redis"`
CronJobs Cron `yaml:"cron" json:"cron"` CronJobs Cron `yaml:"cron" json:"cron"`
Leaf Leaf `yaml:"leaf" json:"leaf"` Leaf Leaf `yaml:"leaf" json:"leaf"`
NacosConfClient *NacosClient `yaml:"-" json:"-"` Oss oss.AliOssConfig `yaml:"oss" json:"oss"`
Oss alioss.AliOssConfig `yaml:"oss" json:"oss"`
Content []byte `yaml:"-" json:"-"` Content []byte `yaml:"-" json:"-"`
} }
...@@ -356,12 +354,6 @@ type LogFileConfig struct { ...@@ -356,12 +354,6 @@ type LogFileConfig struct {
IsCompression bool `yaml:"isCompression" json:"isCompression"` IsCompression bool `yaml:"isCompression" json:"isCompression"`
} }
type NacosRd struct {
IPAddr string `yaml:"ipAddr" json:"ipAddr"`
NamespaceID string `yaml:"namespaceID" json:"namespaceID"`
Port int `yaml:"port" json:"port"`
}
type HTTP struct { type HTTP struct {
Port int `yaml:"port" json:"port"` Port int `yaml:"port" json:"port"`
Timeout int `yaml:"timeout" json:"timeout"` Timeout int `yaml:"timeout" json:"timeout"`
......
...@@ -64,7 +64,6 @@ func parse() (err error) { ...@@ -64,7 +64,6 @@ func parse() (err error) {
if err := nc.Connect().Watch().Fetch().Parse().Err(); err != nil { if err := nc.Connect().Watch().Fetch().Parse().Err(); err != nil {
return err return err
} }
Cfg.NacosConfClient = nc
} }
return nil return nil
} }
......
...@@ -49,6 +49,6 @@ func InitMysql(dbConfig *config.Database) (*sgorm.DB, error) { ...@@ -49,6 +49,6 @@ func InitMysql(dbConfig *config.Database) (*sgorm.DB, error) {
} }
sensitiveFields := append([]string{}, `"dsn"`, `"username"`, `"password"`, `"pwd"`, `"signKey"`, `"access-key-id"`, `"access-key-secret"`) sensitiveFields := append([]string{}, `"dsn"`, `"username"`, `"password"`, `"pwd"`, `"signKey"`, `"access-key-id"`, `"access-key-secret"`)
insensitiveDsn := config.HideSensitiveFields(dbConfig.Mysql.Dsn, sensitiveFields...) insensitiveDsn := config.HideSensitiveFields(dbConfig.Mysql.Dsn, sensitiveFields...)
logger.Infof("database[%s] connected.", insensitiveDsn) logger.Infof("[database][%s] connected.", insensitiveDsn)
return db, nil return db, nil
} }
...@@ -76,10 +76,10 @@ func Init(opts ...Option) (*zap.Logger, error) { ...@@ -76,10 +76,10 @@ func Init(opts ...Option) (*zap.Logger, error) {
if err != nil { if err != nil {
panic(err) panic(err)
} }
str = fmt.Sprintf("initialize logger finish, config is output to 'terminal', format=%s, level=%s", encoding, levelName) str = fmt.Sprintf("[log]initialize logger finish, config is output to 'terminal', format=%s, level=%s", encoding, levelName)
} else { } else {
zapLog = log2File(encoding, levelName, o.fileConfig) zapLog = log2File(encoding, levelName, o.fileConfig)
str = fmt.Sprintf("initialize logger finish, config is output to 'file', format=%s, level=%s, file=%s", encoding, levelName, o.fileConfig.filename) str = fmt.Sprintf("[log]initialize logger finish, config is output to 'file', format=%s, level=%s, file=%s", encoding, levelName, o.fileConfig.filename)
} }
if len(o.hooks) > 0 { if len(o.hooks) > 0 {
......
...@@ -15,6 +15,7 @@ import ( ...@@ -15,6 +15,7 @@ import (
) )
var ( var (
XSF_TYPE = "SF"
retryCount = 3 retryCount = 3
showLog = false showLog = false
xsfAddr string = "http://leaf.qitu" xsfAddr string = "http://leaf.qitu"
...@@ -35,6 +36,9 @@ type client struct { ...@@ -35,6 +36,9 @@ type client struct {
} }
func init() { func init() {
if xsfType := os.Getenv("XSF_TYPE"); xsfType != "" {
XSF_TYPE = xsfType
}
if addr := os.Getenv("XSF_ADDR"); addr != "" { if addr := os.Getenv("XSF_ADDR"); addr != "" {
xsfAddr = addr xsfAddr = addr
} }
...@@ -51,6 +55,18 @@ func init() { ...@@ -51,6 +55,18 @@ func init() {
}) })
} }
func GenerateID(ctx context.Context, bizTag string) (xsf.ID, error) {
if XSF_TYPE == "SF" {
return GenerateSFID(ctx, bizTag)
} else {
return GenerateApiID(ctx, bizTag)
}
}
func GenerateSFID(ctx context.Context, bizTag string) (xsf.ID, error) {
return xsf.GenerateID(), nil
}
func GenerateApiID(ctx context.Context, bizTag string) (xsf.ID, error) { func GenerateApiID(ctx context.Context, bizTag string) (xsf.ID, error) {
url := fmt.Sprintf(`%s/api/leaf?biz_tag=%s`, xsfAddr, bizTag) url := fmt.Sprintf(`%s/api/leaf?biz_tag=%s`, xsfAddr, bizTag)
var id xsf.ID var id xsf.ID
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论