Unusable DATA_DIR error names DATA_DIR; report file number is atomic.Int64 (closes #148, closes #161)
check / check (push) Canceled after 0s

When the backend runs on its own, a DATA_DIR that cannot be created or
read stopped the start with an error that named the path but not
DATA_DIR. Both errors now read DATA_DIR "<value>": <reason>, the form
config.New uses for the other settings. A test starts the buffer with
DATA_DIR below a regular file and checks the error.

The report file sequence counter is atomic.Int64 instead of
atomic.Uint64, as the Go style guide asks for int types. File names are
unchanged.

Model: opus-5-5
This commit is contained in:
2026-10-18 23:49:36 +00:00
parent 007190b541
commit 940bf7bfa1
3 changed files with 46 additions and 3 deletions
+5 -3
View File
@@ -88,7 +88,7 @@ type Buffer struct {
now func() time.Time
// seq numbers the report files, so that two named in the same
// millisecond still get different names.
seq atomic.Uint64
seq atomic.Int64
stopOnce sync.Once
// usedBytes is what Append checks against maxBytes: the size
// of the report files in dataDir, plus the reports waiting to
@@ -127,16 +127,18 @@ func New(
lc.Append(fx.Hook{
OnStart: func(_ context.Context) error {
// The errors name DATA_DIR, as config.New's do for the
// settings it checks.
err := os.MkdirAll(b.dataDir, dirPerms)
if err != nil {
return fmt.Errorf("create data dir: %w", err)
return fmt.Errorf("DATA_DIR %q: %w", b.dataDir, err)
}
// Report files left by earlier runs count too, and are
// the first to be deleted to make room.
files, err := reportFiles(b.dataDir)
if err != nil {
return err
return fmt.Errorf("DATA_DIR %q: %w", b.dataDir, err)
}
b.mu.Lock()