ref: e083331679dd2d58cfd3a0b9639a6ecd6220ba31
parent: 3d71db8702f58182f1f7eda3446a2c474443c7f2
author: Runxi Yu <me@runxiyu.org>
date: Sat Mar 7 14:30:18 EST 2026
refstore: Batch should also be staged
--- a/refstore/batch.go
+++ b/refstore/batch.go
@@ -2,37 +2,45 @@
import "codeberg.org/lindenii/furgit/objectid"
-// Batch applies reference operations immediately, one operation at a time.
+// Batch stages reference operations for one non-atomic apply.
//
-// Unlike Transaction, Batch does not stage changes for one atomic commit.
-// Each method attempts its update immediately and returns that operation's
-// error, if any.
+// Unlike Transaction, Batch may reject some queued operations while still
+// applying others successfully when Apply runs.
type Batch interface {// Create creates one detached reference, requiring that the logical
// reference does not already exist.
- Create(name string, newID objectid.ObjectID) error
+ Create(name string, newID objectid.ObjectID)
// Update updates one detached reference, requiring that the current logical
// reference value matches oldID.
- Update(name string, newID, oldID objectid.ObjectID) error
+ Update(name string, newID, oldID objectid.ObjectID)
// Delete deletes one detached reference, requiring that the current logical
// reference value matches oldID.
- Delete(name string, oldID objectid.ObjectID) error
+ Delete(name string, oldID objectid.ObjectID)
// Verify verifies that the current logical reference value matches oldID.
- Verify(name string, oldID objectid.ObjectID) error
+ Verify(name string, oldID objectid.ObjectID)
// CreateSymbolic creates one symbolic reference, requiring that the named
// reference does not already exist.
- CreateSymbolic(name, newTarget string) error
+ CreateSymbolic(name, newTarget string)
// UpdateSymbolic updates one symbolic reference directly, requiring that its
// current target matches oldTarget.
- UpdateSymbolic(name, newTarget, oldTarget string) error
+ UpdateSymbolic(name, newTarget, oldTarget string)
// DeleteSymbolic deletes one symbolic reference directly, requiring that its
// current target matches oldTarget.
- DeleteSymbolic(name, oldTarget string) error
+ DeleteSymbolic(name, oldTarget string)
// VerifySymbolic verifies that the named symbolic reference currently points
// at oldTarget.
- VerifySymbolic(name, oldTarget string) error
+ VerifySymbolic(name, oldTarget string)
- // Close releases any resources associated with the batch.
- Close() error
+ // Apply validates and applies queued operations, returning one result per
+ // queued operation in order. Fatal backend failures are returned separately.
+ Apply() ([]BatchResult, error)
+ // Abort abandons the batch and releases any resources it holds.
+ Abort() error
+}
+
+// BatchResult reports the outcome for one queued batch operation.
+type BatchResult struct {+ Name string
+ Error error
}
--- a/refstore/batch_store.go
+++ b/refstore/batch_store.go
@@ -2,6 +2,6 @@
// BatchStore begins non-atomic reference batches.
type BatchStore interface {- // BeginBatch creates one new immediate-apply batch.
+ // BeginBatch creates one new queued batch.
BeginBatch() (Batch, error)
}
--- a/refstore/read_write.go
+++ /dev/null
@@ -1,7 +1,0 @@
-package refstore
-
-// ReadWriteStore supports both reading and atomic transactional updates.
-type ReadWriteStore interface {- ReadingStore
- TransactionalStore
-}
--- a/refstore/read_write_store.go
+++ b/refstore/read_write_store.go
@@ -1,6 +1,6 @@
package refstore
-// ReadWriteStore supports reading, atomic transactions, and immediate batches.
+// ReadWriteStore supports reading, atomic transactions, and non-atomic batches.
type ReadWriteStore interface {ReadingStore
TransactionalStore
--
⑨