Internal state persistence #27

Merged
natercio merged 15 commits from internal-state-persistence into main 2026-08-03 00:33:07 +01:00
2 changed files with 30 additions and 3 deletions
Showing only changes of commit d2b2f934a0 - Show all commits
+29
View File
@@ -0,0 +1,29 @@
package internal
import (
"fmt"
"os"
)
// FileStore loads and saves the state into a file
type FileStore struct {
file *os.File
}
func NewFileStore(filename string) (*FileStore, error) {
f, err := os.Open(filename)
if err != nil {
return nil, err
}
return &FileStore{
file: f,
}, nil
}
func (fs *FileStore) Load() (map[string]*FillerQueue, error) {
return nil, fmt.Errorf("not implemented")
}
func (fs *FileStore) Save(map[string]*FillerQueue) error {
return fmt.Errorf("not implemented")
}
+1 -3
View File
@@ -148,8 +148,6 @@ func BuildReport(ctx context.Context, reader RecordReader, writer ReportWriter,
} }
} }
} }
return nil
} }
// processRecord either adds buys to the queue or consumes buys from the queue when processing a // processRecord either adds buys to the queue or consumes buys from the queue when processing a
@@ -186,7 +184,7 @@ func processRecord(ctx context.Context, q *FillerQueue, rec Record, sel Selector
return ErrInsufficientBoughtVolume return ErrInsufficientBoughtVolume
} }
// Since we don't apply selectors while processing buys we need to apply them here, befre we // Since we don't apply selectors while processing buys we need to apply them here, before we
// actually use them. // actually use them.
if !sel(buy) { if !sel(buy) {
continue continue