mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-06-08 11:23:53 +03:00
lib/fs: convert CreateFlockFile to MustCreateFlockFile
Callers of CreateFlockFile log the returned err and exit. It is better to log the error inside the MustCreateFlockFile together with the path to the specified directory and the call stack. This simplifies the code at the callers' side while leaving the debuggability at the same level.
This commit is contained in:
@@ -144,14 +144,6 @@ func mustOpenInternal(path, name string, chunkFileSize, maxBlockSize, maxPending
|
||||
return q
|
||||
}
|
||||
|
||||
func mustCreateFlockFile(path string) *os.File {
|
||||
f, err := fs.CreateFlockFile(path)
|
||||
if err != nil {
|
||||
logger.Panicf("FATAL: %s", err)
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
func tryOpeningQueue(path, name string, chunkFileSize, maxBlockSize, maxPendingBytes uint64) (*queue, error) {
|
||||
// Protect from concurrent opens.
|
||||
var q queue
|
||||
@@ -178,7 +170,7 @@ func tryOpeningQueue(path, name string, chunkFileSize, maxBlockSize, maxPendingB
|
||||
}
|
||||
|
||||
fs.MustMkdirIfNotExist(path)
|
||||
q.flockF = mustCreateFlockFile(path)
|
||||
q.flockF = fs.MustCreateFlockFile(path)
|
||||
mustCloseFlockF := true
|
||||
defer func() {
|
||||
if mustCloseFlockF {
|
||||
|
||||
Reference in New Issue
Block a user