Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/component/common/loki/positions/write_positions_unix.go
4096 views
1
//go:build !windows
2
3
package positions
4
5
// This code is copied from Promtail. The positions package allows logging
6
// components to keep track of read file offsets on disk and continue from the
7
// same place in case of a restart.
8
9
import (
10
"os"
11
"path/filepath"
12
13
renameio "github.com/google/renameio/v2"
14
yaml "gopkg.in/yaml.v2"
15
)
16
17
func writePositionFile(filename string, positions map[Entry]string) error {
18
buf, err := yaml.Marshal(File{
19
Positions: positions,
20
})
21
if err != nil {
22
return err
23
}
24
25
target := filepath.Clean(filename)
26
27
return renameio.WriteFile(target, buf, os.FileMode(positionFileMode))
28
}
29
30