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 {
|
||||
Variables VariablesConfig `yaml:"variables"`
|
||||
Logging LoggingConfig `yaml:"logging"`
|
||||
Shutdown ShutdownConfig `yaml:"shutdown"`
|
||||
Servers []ServerConfig `yaml:"servers"`
|
||||
Stream []StreamConfig `yaml:"stream"`
|
||||
Monitoring MonitoringConfig `yaml:"monitoring"`
|
||||
@ -66,6 +65,7 @@ type Config struct {
|
||||
Resolver ResolverConfig `yaml:"resolver"`
|
||||
Server ServerConfig `yaml:"server"`
|
||||
Performance PerformanceConfig `yaml:"performance"`
|
||||
Shutdown ShutdownConfig `yaml:"shutdown"`
|
||||
}
|
||||
|
||||
// VariablesConfig 自定义变量配置。
|
||||
|
||||
@ -36,38 +36,17 @@ import (
|
||||
//
|
||||
// 包装 golang.org/x/net/http2 服务器,提供与 fasthttp handler 的集成。
|
||||
type Server struct {
|
||||
// stopChan 停止信号通道
|
||||
stopChan chan struct{}
|
||||
|
||||
// http2Server HTTP/2 服务器实例
|
||||
http2Server *http2.Server
|
||||
|
||||
// config HTTP/2 配置
|
||||
config *config.HTTP2Config
|
||||
|
||||
// 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 优雅关闭超时时间
|
||||
listener net.Listener
|
||||
http2Server *http2.Server
|
||||
config *config.HTTP2Config
|
||||
tlsConfig *tls.Config
|
||||
pool *connectionPool
|
||||
handler fasthttp.RequestHandler
|
||||
stopChan chan struct{}
|
||||
connWg sync.WaitGroup
|
||||
GracefulShutdownTimeout time.Duration
|
||||
mu sync.RWMutex
|
||||
running bool
|
||||
}
|
||||
|
||||
// NewServer 创建 HTTP/2 服务器。
|
||||
@ -607,7 +586,7 @@ func (p *connectionPool) count(key string) int {
|
||||
}
|
||||
|
||||
// closeAll 关闭所有连接。
|
||||
func (p *connectionPool) closeAll() { //nolint:unused // reserved for future use
|
||||
func (p *connectionPool) closeAll() {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
|
||||
|
||||
@ -5,8 +5,8 @@ import glua "github.com/yuin/gopher-lua"
|
||||
|
||||
// APIMethod 表示一个 Lua API 方法
|
||||
type APIMethod struct {
|
||||
Name string
|
||||
Func func(*glua.LState) int
|
||||
Name string
|
||||
}
|
||||
|
||||
// RegisterAPIMethods 批量注册 API 方法到 Lua 表
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user