Browse Source

fix dtmsvr/config golangci lint error

pull/163/head
liulei 4 years ago
parent
commit
cd929d8db8
  1. 18
      dtmsvr/config/config.go
  2. 4
      dtmsvr/svr.go

18
dtmsvr/config/config.go

@ -10,11 +10,16 @@ import (
)
const (
// DtmMetricsPort is metric port
DtmMetricsPort = 8889
Mysql = "mysql"
Redis = "redis"
BoltDb = "boltdb"
Postgres = "postgres"
// Mysql is mysql driver
Mysql = "mysql"
// Redis is redis driver
Redis = "redis"
// BoltDb is boltdb driver
BoltDb = "boltdb"
// Postgres is postgres driver
Postgres = "postgres"
)
// MicroService config type for micro service
@ -24,6 +29,7 @@ type MicroService struct {
EndPoint string `yaml:"EndPoint"`
}
// Store defines storage relevant info
type Store struct {
Driver string `yaml:"Driver" default:"boltdb"`
Host string `yaml:"Host"`
@ -39,10 +45,12 @@ type Store struct {
TransBranchOpTable string `yaml:"BranchTransOpTable" default:"dtm.trans_branch_op"`
}
// IsDB checks config driver is mysql or postgres
func (s *Store) IsDB() bool {
return s.Driver == dtmcli.DBTypeMysql || s.Driver == dtmcli.DBTypePostgres
}
// GetDBConf returns db conf info
func (s *Store) GetDBConf() dtmcli.DBConf {
return dtmcli.DBConf{
Driver: s.Driver,
@ -58,7 +66,7 @@ type configType struct {
TransCronInterval int64 `yaml:"TransCronInterval" default:"3"`
TimeoutToFail int64 `yaml:"TimeoutToFail" default:"35"`
RetryInterval int64 `yaml:"RetryInterval" default:"10"`
HttpPort int64 `yaml:"HttpPort" default:"36789"`
HTTPPort int64 `yaml:"HTTPPort" default:"36789"`
GrpcPort int64 `yaml:"GrpcPort" default:"36790"`
MicroService MicroService `yaml:"MicroService"`
UpdateBranchSync int64 `yaml:"UpdateBranchSync"`

4
dtmsvr/svr.go

@ -26,9 +26,9 @@ func StartSvr() {
app := dtmutil.GetGinApp()
app = httpMetrics(app)
addRoute(app)
logger.Infof("dtmsvr listen at: %d", conf.HttpPort)
logger.Infof("dtmsvr listen at: %d", conf.HTTPPort)
go func() {
err := app.Run(fmt.Sprintf(":%d", conf.HttpPort))
err := app.Run(fmt.Sprintf(":%d", conf.HTTPPort))
if err != nil {
logger.Errorf("start server err: %v", err)
}

Loading…
Cancel
Save