fix(lint): 修复结构体字段对齐问题
调整 Config、Server、APIMethod 结构体字段顺序以优化内存布局, 解决 govet fieldalignment 检查警告。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
20518495b3
commit
6a08a6ab4a
@ -58,7 +58,6 @@ const (
|
|||||||
type Config struct {
|
type Config struct {
|
||||||
Variables VariablesConfig `yaml:"variables"`
|
Variables VariablesConfig `yaml:"variables"`
|
||||||
Logging LoggingConfig `yaml:"logging"`
|
Logging LoggingConfig `yaml:"logging"`
|
||||||
Shutdown ShutdownConfig `yaml:"shutdown"`
|
|
||||||
Servers []ServerConfig `yaml:"servers"`
|
Servers []ServerConfig `yaml:"servers"`
|
||||||
Stream []StreamConfig `yaml:"stream"`
|
Stream []StreamConfig `yaml:"stream"`
|
||||||
Monitoring MonitoringConfig `yaml:"monitoring"`
|
Monitoring MonitoringConfig `yaml:"monitoring"`
|
||||||
@ -66,6 +65,7 @@ type Config struct {
|
|||||||
Resolver ResolverConfig `yaml:"resolver"`
|
Resolver ResolverConfig `yaml:"resolver"`
|
||||||
Server ServerConfig `yaml:"server"`
|
Server ServerConfig `yaml:"server"`
|
||||||
Performance PerformanceConfig `yaml:"performance"`
|
Performance PerformanceConfig `yaml:"performance"`
|
||||||
|
Shutdown ShutdownConfig `yaml:"shutdown"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// VariablesConfig 自定义变量配置。
|
// VariablesConfig 自定义变量配置。
|
||||||
|
|||||||
@ -36,38 +36,17 @@ import (
|
|||||||
//
|
//
|
||||||
// 包装 golang.org/x/net/http2 服务器,提供与 fasthttp handler 的集成。
|
// 包装 golang.org/x/net/http2 服务器,提供与 fasthttp handler 的集成。
|
||||||
type Server struct {
|
type Server struct {
|
||||||
// stopChan 停止信号通道
|
listener net.Listener
|
||||||
stopChan chan struct{}
|
http2Server *http2.Server
|
||||||
|
config *config.HTTP2Config
|
||||||
// http2Server HTTP/2 服务器实例
|
tlsConfig *tls.Config
|
||||||
http2Server *http2.Server
|
pool *connectionPool
|
||||||
|
handler fasthttp.RequestHandler
|
||||||
// config HTTP/2 配置
|
stopChan chan struct{}
|
||||||
config *config.HTTP2Config
|
connWg sync.WaitGroup
|
||||||
|
|
||||||
// tlsConfig TLS 配置
|
|
||||||
tlsConfig *tls.Config
|
|
||||||
|
|
||||||
// listener TCP 监听器
|
|
||||||
listener net.Listener
|
|
||||||
|
|
||||||
// handler fasthttp 请求处理器
|
|
||||||
handler fasthttp.RequestHandler
|
|
||||||
|
|
||||||
// mu 读写锁
|
|
||||||
mu sync.RWMutex
|
|
||||||
|
|
||||||
// running 服务器运行状态
|
|
||||||
running bool
|
|
||||||
|
|
||||||
// pool 连接池
|
|
||||||
pool *connectionPool
|
|
||||||
|
|
||||||
// connWg 连接等待组,用于优雅关闭
|
|
||||||
connWg sync.WaitGroup
|
|
||||||
|
|
||||||
// GracefulShutdownTimeout 优雅关闭超时时间
|
|
||||||
GracefulShutdownTimeout time.Duration
|
GracefulShutdownTimeout time.Duration
|
||||||
|
mu sync.RWMutex
|
||||||
|
running bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServer 创建 HTTP/2 服务器。
|
// NewServer 创建 HTTP/2 服务器。
|
||||||
@ -607,7 +586,7 @@ func (p *connectionPool) count(key string) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// closeAll 关闭所有连接。
|
// closeAll 关闭所有连接。
|
||||||
func (p *connectionPool) closeAll() { //nolint:unused // reserved for future use
|
func (p *connectionPool) closeAll() {
|
||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
defer p.mu.Unlock()
|
defer p.mu.Unlock()
|
||||||
|
|
||||||
|
|||||||
@ -5,8 +5,8 @@ import glua "github.com/yuin/gopher-lua"
|
|||||||
|
|
||||||
// APIMethod 表示一个 Lua API 方法
|
// APIMethod 表示一个 Lua API 方法
|
||||||
type APIMethod struct {
|
type APIMethod struct {
|
||||||
Name string
|
|
||||||
Func func(*glua.LState) int
|
Func func(*glua.LState) int
|
||||||
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterAPIMethods 批量注册 API 方法到 Lua 表
|
// RegisterAPIMethods 批量注册 API 方法到 Lua 表
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user