feat: order processing

feat: order commands result save/load
This commit is contained in:
Ilia Denisov
2026-02-20 17:44:41 +02:00
committed by GitHub
parent 0c0df976bd
commit 233c9ebc2a
26 changed files with 2028 additions and 385 deletions
+10 -6
View File
@@ -79,15 +79,11 @@ func (f *fs) Exists(path string) (bool, error) {
return fileExists(filepath.Join(f.root, path))
}
func (f *fs) Write(path string, v encoding.BinaryMarshaler) error {
func (f *fs) WriteSafe(path string, v encoding.BinaryMarshaler) error {
if v == nil {
return errors.New("cant't marshal from nil object")
}
if f.lock == nil {
return errors.New("lock must be acquired before write")
}
targetFilePath := filepath.Join(f.root, path)
if targetFilePath == f.lockFilePath() {
return errors.New("can't write to the lock file")
@@ -160,6 +156,14 @@ func (f *fs) Write(path string, v encoding.BinaryMarshaler) error {
return nil
}
func (f *fs) Write(path string, v encoding.BinaryMarshaler) error {
if f.lock == nil {
return errors.New("lock must be acquired before write")
}
return f.WriteSafe(path, v)
}
func (f *fs) Read(path string, v encoding.BinaryUnmarshaler) error {
if f.lock == nil {
return errors.New("lock must be acquired before read")
@@ -183,7 +187,7 @@ func (f *fs) ReadSafe(path string, v encoding.BinaryUnmarshaler) error {
}
case <-timeout.C:
checker.Stop()
return errors.New("lock acquired, timeout waiting for release")
return errors.New("timeout waiting for lock release")
}
}
}