Skip to content

Commit

Permalink
publish🚀: 3.7.15
Browse files Browse the repository at this point in the history
  • Loading branch information
abulo committed Apr 24, 2024
1 parent 524af44 commit 2238e74
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 36 deletions.
2 changes: 1 addition & 1 deletion core/env/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

const (
ratelVersion = "v3.7.14"
ratelVersion = "v3.7.15"
)

var (
Expand Down
26 changes: 13 additions & 13 deletions server/xgin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ const ModName = "server.gin"

// Config HTTP config
type Config struct {
Host string
Port int
Deployment string
Mode string
DisableMetric bool
DisableTrace bool
DisableSlowQuery bool
ServiceAddress string // ServiceAddress service address in registry info, default to 'Host:Port'
SlowQueryThresholdInMilli int64
Host string
Port int
Deployment string
Mode string
DisableMetric bool
DisableTrace bool
DisableSlowQuery bool
ServiceAddress string // ServiceAddress service address in registry info, default to 'Host:Port'
SlowQueryThresholdInMill int64
}

// New ...
func New() *Config {
return &Config{
Mode: gin.ReleaseMode,
SlowQueryThresholdInMilli: 500, // 500ms
Mode: gin.ReleaseMode,
SlowQueryThresholdInMill: 500, // 500ms
}
}

Expand Down Expand Up @@ -80,7 +80,7 @@ func (config *Config) WithServiceAddress(serviceAddress string) *Config {

// WithSlowQueryThresholdInMilli WithPort ...
func (config *Config) WithSlowQueryThresholdInMilli(milli int64) *Config {
config.SlowQueryThresholdInMilli = milli
config.SlowQueryThresholdInMill = milli
return config
}

Expand All @@ -93,7 +93,7 @@ func (config *Config) Build() *Server {
server.Use(gin.Recovery())
if !config.DisableSlowQuery {
//慢日志查询
server.Use(recoverMiddleware(config.SlowQueryThresholdInMilli))
server.Use(recoverMiddleware(config.SlowQueryThresholdInMill))
}
if !config.DisableMetric {
server.Use(metricServerInterceptor())
Expand Down
22 changes: 11 additions & 11 deletions server/xgrpc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type Config struct {
DisableTrace bool
// DisableMetric disable Metric Interceptor, false by default
DisableMetric bool
// SlowQueryThresholdInMilli, request will be colored if cost over this threshold value
SlowQueryThresholdInMilli int64
// SlowQueryThresholdInMill, request will be colored if cost over this threshold value
SlowQueryThresholdInMill int64
// ServiceAddress service address in registry info, default to 'Host:Port'
ServiceAddress string
// EnableTLS
Expand All @@ -41,15 +41,15 @@ type Config struct {
// New ...
func New() *Config {
return &Config{
Network: "tcp4",
Deployment: constant.DefaultDeployment,
DisableMetric: false,
DisableTrace: false,
EnableTLS: false,
SlowQueryThresholdInMilli: 500,
serverOptions: []grpc.ServerOption{},
streamInterceptors: []grpc.StreamServerInterceptor{},
unaryInterceptors: []grpc.UnaryServerInterceptor{},
Network: "tcp4",
Deployment: constant.DefaultDeployment,
DisableMetric: false,
DisableTrace: false,
EnableTLS: false,
SlowQueryThresholdInMill: 500,
serverOptions: []grpc.ServerOption{},
streamInterceptors: []grpc.StreamServerInterceptor{},
unaryInterceptors: []grpc.UnaryServerInterceptor{},
}
}

Expand Down
39 changes: 28 additions & 11 deletions server/xhertz/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,33 @@ import (
// ModName ..
const ModName = "server.hertz"

const (
// DebugMode indicates gin mode is debug.
DebugMode = "debug"
// ReleaseMode indicates gin mode is release.
ReleaseMode = "release"
// TestMode indicates gin mode is test.
TestMode = "test"
)

// Config HTTP config
type Config struct {
Host string
Port int
Deployment string
DisableMetric bool
DisableTrace bool
DisableSlowQuery bool
ServiceAddress string
SlowQueryThresholdInMilli int64
Host string
Port int
Mode string
Deployment string
DisableMetric bool
DisableTrace bool
DisableSlowQuery bool
ServiceAddress string
SlowQueryThresholdInMill int64
}

// New ...
func New() *Config {
return &Config{
SlowQueryThresholdInMilli: 500, // 500ms
SlowQueryThresholdInMill: 500, // 500ms
Mode: DebugMode,
}
}

Expand Down Expand Up @@ -70,7 +81,13 @@ func (config *Config) WithServiceAddress(serviceAddress string) *Config {

// WithSlowQueryThresholdInMilli WithPort ...
func (config *Config) WithSlowQueryThresholdInMilli(milli int64) *Config {
config.SlowQueryThresholdInMilli = milli
config.SlowQueryThresholdInMill = milli
return config
}

// WithMode ...
func (config *Config) WithMode(mode string) *Config {
config.Mode = mode
return config
}

Expand All @@ -79,7 +96,7 @@ func (config *Config) Build() *Server {
serverInstance := newServer(config)
if !config.DisableSlowQuery {
//慢日志查询
serverInstance.Use(recoverMiddleware(config.SlowQueryThresholdInMilli))
serverInstance.Use(recoverMiddleware(config.SlowQueryThresholdInMill))
}
if !config.DisableMetric {
serverInstance.Use(metricServerInterceptor())
Expand Down
1 change: 1 addition & 0 deletions server/xhertz/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func newServer(config *Config) *Server {
return &Server{
Hertz: hserver.New(
hserver.WithHostPorts(config.Address()),
hserver.WithDisablePrintRoute(config.Mode == ReleaseMode),
),
config: config,
}
Expand Down

0 comments on commit 2238e74

Please sign in to comment.