参数化数据库复制并记录资源清理失败

This commit is contained in:
xuans committed 2026-09-21 00:47:38 +08:00
1 parent 3e135e2b7b
commit aa351dcb9d
10 files changed
+129 -38

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
package config
import (
"io"
log "github.com/sirupsen/logrus"
)
// 无返回值的租约释放接口记录关闭失败,不将路径或驱动错误中的敏感信息写入日志。
func releaseConfigLease(unlock func(), lease io.Closer) {
unlock()
closeConfigResource(lease)
}
func closeConfigResource(resource io.Closer) {
if err := resource.Close(); err != nil {
log.WithField("action", "释放配置资源").Error("关闭配置资源失败,请检查文件句柄和数据库连接状态")
}
}