Refactor golangci-lint configuration and improve error handling
- Updated .golangci.yml to enable default linters and refine suppression rules, enhancing code quality visibility. - Improved error handling in cmd/root.go by explicitly discarding low-value error messages during fatal exits for consistency with errcheck posture. - Added best-effort error handling in various locations across the codebase, ensuring that non-critical errors are logged without affecting overall functionality. - Introduced a new writeMetricsText function to streamline metrics output, improving code clarity and maintainability.
This commit is contained in:
Vendored
+5
-4
@@ -177,7 +177,7 @@ func (tc *TieredCache) Capacity() int64 {
|
||||
|
||||
// promoteToFast promotes a file from slow tier to fast tier
|
||||
func (tc *TieredCache) promoteToFast(key string, reader io.ReadCloser) {
|
||||
defer reader.Close()
|
||||
defer func() { _ = reader.Close() }() // best-effort close; error secondary to promotion attempt (async best-effort path)
|
||||
|
||||
// Get file info from slow tier to determine size
|
||||
var size int64
|
||||
@@ -217,9 +217,10 @@ func (tc *TieredCache) promoteToFast(key string, reader io.ReadCloser) {
|
||||
if vfs, ok := fast.(vfs.VFS); ok {
|
||||
writer, err := vfs.Create(key, size)
|
||||
if err == nil {
|
||||
// Write content to fast tier
|
||||
writer.Write(content)
|
||||
writer.Close()
|
||||
// Write/close errors intentionally discarded: promotion to fast tier is best-effort optimization only.
|
||||
// Failure (e.g. mem pressure, concurrent evict) is non-fatal and does not affect correctness of slow tier.
|
||||
_, _ = writer.Write(content)
|
||||
_ = writer.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user