diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-09-05 07:59:20 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-09-05 07:59:20 +0200 |
commit | 65427f64599e9383ab926aed75fc02f2db32022d (patch) | |
tree | 5c81c00bc9dcfb54e0c6d0038ab2cbd8cddde389 /core/storage.go | |
parent | 440cfd96cf88ffc9d04bbd32ec8a3b1afb42144c (diff) | |
download | go-git-65427f64599e9383ab926aed75fc02f2db32022d.tar.gz |
core: ObjectStorage.Begin and TxObjectStorage
Diffstat (limited to 'core/storage.go')
-rw-r--r-- | core/storage.go | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/core/storage.go b/core/storage.go index 15d988a..09b2450 100644 --- a/core/storage.go +++ b/core/storage.go @@ -7,19 +7,28 @@ var ErrStop = errors.New("stop iter") // ObjectStorage generic storage of objects type ObjectStorage interface { + // NewObject returns a new Object, the real type of the object can be a + // custom implementation or the defaul one, MemoryObject NewObject() Object + // Set save an object into the storage, the object shuld be create with + // the NewObject, method, and file if the type is not supported. Set(Object) (Hash, error) - // Get an object by hash with the given ObjectType. - // - // Implementors should return (nil, core.ErrObjectNotFound) if an object - // doesn't exist with both the given hash and object type. + // Get an object by hash with the given ObjectType. Implementors should + // return (nil, ErrObjectNotFound) if an object doesn't exist with both the + // given hash and object type. // // Valid ObjectType values are CommitObject, BlobObject, TagObject, TreeObject // and AnyObject. // // If AnyObject is given, the object must be looked up regardless of its type. Get(ObjectType, Hash) (Object, error) + // Iter returns a custom ObjectIter over all the object on the storage. + // + // Valid ObjectType values are CommitObject, BlobObject, TagObject, TreeObject + // and AnyObject. Iter(ObjectType) (ObjectIter, error) + // Begin starts a transaction. + Begin() TxObjectStorage } // ObjectIter is a generic closable interface for iterating over objects. @@ -29,6 +38,14 @@ type ObjectIter interface { Close() } +// TxObjectStorage is an in-progress storage transaction. +// A transaction must end with a call to Commit or Rollback. +type TxObjectStorage interface { + Set(Object) (Hash, error) + Commit() error + Rollback() error +} + // ReferenceStorage generic storage of references type ReferenceStorage interface { Set(*Reference) error |