@@ -7,19 +7,28 @@ var ErrStop = errors.New("stop iter")
77
88// ObjectStorage generic storage of objects
99type ObjectStorage interface {
10+ // NewObject returns a new Object, the real type of the object can be a
11+ // custom implementation or the defaul one, MemoryObject
1012 NewObject () Object
13+ // Set save an object into the storage, the object shuld be create with
14+ // the NewObject, method, and file if the type is not supported.
1115 Set (Object ) (Hash , error )
12- // Get an object by hash with the given ObjectType.
13- //
14- // Implementors should return (nil, core.ErrObjectNotFound) if an object
15- // doesn't exist with both the given hash and object type.
16+ // Get an object by hash with the given ObjectType. Implementors should
17+ // return (nil, ErrObjectNotFound) if an object doesn't exist with both the
18+ // given hash and object type.
1619 //
1720 // Valid ObjectType values are CommitObject, BlobObject, TagObject, TreeObject
1821 // and AnyObject.
1922 //
2023 // If AnyObject is given, the object must be looked up regardless of its type.
2124 Get (ObjectType , Hash ) (Object , error )
25+ // Iter returns a custom ObjectIter over all the object on the storage.
26+ //
27+ // Valid ObjectType values are CommitObject, BlobObject, TagObject, TreeObject
28+ // and AnyObject.
2229 Iter (ObjectType ) (ObjectIter , error )
30+ // Begin starts a transaction.
31+ Begin () TxObjectStorage
2332}
2433
2534// ObjectIter is a generic closable interface for iterating over objects.
@@ -29,6 +38,14 @@ type ObjectIter interface {
2938 Close ()
3039}
3140
41+ // TxObjectStorage is an in-progress storage transaction.
42+ // A transaction must end with a call to Commit or Rollback.
43+ type TxObjectStorage interface {
44+ Set (Object ) (Hash , error )
45+ Commit () error
46+ Rollback () error
47+ }
48+
3249// ReferenceStorage generic storage of references
3350type ReferenceStorage interface {
3451 Set (* Reference ) error
0 commit comments