mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
tsdb: export CheckpointPrefix constant (#15636)
Exported the CheckpointPrefix constant to be used in other packages. Updated references to the constant in db.go and checkpoint.go files. This change improves code readability and maintainability. Signed-off-by: johncming <johncming@yahoo.com> Co-authored-by: johncming <conjohn668@gmail.com>
This commit is contained in:
parent
2c5502c114
commit
061400e31b
|
@ -2320,7 +2320,7 @@ func isTmpDir(fi fs.DirEntry) bool {
|
||||||
fn := fi.Name()
|
fn := fi.Name()
|
||||||
ext := filepath.Ext(fn)
|
ext := filepath.Ext(fn)
|
||||||
if ext == tmpForDeletionBlockDirSuffix || ext == tmpForCreationBlockDirSuffix || ext == tmpLegacy {
|
if ext == tmpForDeletionBlockDirSuffix || ext == tmpForCreationBlockDirSuffix || ext == tmpLegacy {
|
||||||
if strings.HasPrefix(fn, "checkpoint.") {
|
if strings.HasPrefix(fn, wlog.CheckpointPrefix) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(fn, chunkSnapshotPrefix) {
|
if strings.HasPrefix(fn, chunkSnapshotPrefix) {
|
||||||
|
|
|
@ -81,7 +81,8 @@ func DeleteCheckpoints(dir string, maxIndex int) error {
|
||||||
return errs.Err()
|
return errs.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkpointPrefix = "checkpoint."
|
// CheckpointPrefix is the prefix used for checkpoint files.
|
||||||
|
const CheckpointPrefix = "checkpoint."
|
||||||
|
|
||||||
// Checkpoint creates a compacted checkpoint of segments in range [from, to] in the given WAL.
|
// Checkpoint creates a compacted checkpoint of segments in range [from, to] in the given WAL.
|
||||||
// It includes the most recent checkpoint if it exists.
|
// It includes the most recent checkpoint if it exists.
|
||||||
|
@ -363,7 +364,7 @@ func Checkpoint(logger *slog.Logger, w *WL, from, to int, keep func(id chunks.He
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkpointDir(dir string, i int) string {
|
func checkpointDir(dir string, i int) string {
|
||||||
return filepath.Join(dir, fmt.Sprintf(checkpointPrefix+"%08d", i))
|
return filepath.Join(dir, fmt.Sprintf(CheckpointPrefix+"%08d", i))
|
||||||
}
|
}
|
||||||
|
|
||||||
type checkpointRef struct {
|
type checkpointRef struct {
|
||||||
|
@ -379,13 +380,13 @@ func listCheckpoints(dir string) (refs []checkpointRef, err error) {
|
||||||
|
|
||||||
for i := 0; i < len(files); i++ {
|
for i := 0; i < len(files); i++ {
|
||||||
fi := files[i]
|
fi := files[i]
|
||||||
if !strings.HasPrefix(fi.Name(), checkpointPrefix) {
|
if !strings.HasPrefix(fi.Name(), CheckpointPrefix) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !fi.IsDir() {
|
if !fi.IsDir() {
|
||||||
return nil, fmt.Errorf("checkpoint %s is not a directory", fi.Name())
|
return nil, fmt.Errorf("checkpoint %s is not a directory", fi.Name())
|
||||||
}
|
}
|
||||||
idx, err := strconv.Atoi(fi.Name()[len(checkpointPrefix):])
|
idx, err := strconv.Atoi(fi.Name()[len(CheckpointPrefix):])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue