aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/storer/object.go
diff options
context:
space:
mode:
authorJeremy Stribling <strib@alum.mit.edu>2017-11-29 14:15:32 -0800
committerJeremy Stribling <strib@alum.mit.edu>2017-11-29 14:29:19 -0800
commit4c1569511db5e1d26e42e9cd8dadb9e65ccafb20 (patch)
tree38e12de7c82d8c36d215775c13d17d3e566b2069 /plumbing/storer/object.go
parentb18457df6a1f75283d95999fde5c162ba1a19651 (diff)
downloadgo-git-4c1569511db5e1d26e42e9cd8dadb9e65ccafb20.tar.gz
storer: separate loose and packed object mgmt into optional ifaces
Suggested by mcuadros.
Diffstat (limited to 'plumbing/storer/object.go')
-rw-r--r--plumbing/storer/object.go40
1 files changed, 25 insertions, 15 deletions
diff --git a/plumbing/storer/object.go b/plumbing/storer/object.go
index e5f98d7..f1d19ef 100644
--- a/plumbing/storer/object.go
+++ b/plumbing/storer/object.go
@@ -40,6 +40,26 @@ type EncodedObjectStorer interface {
// HasEncodedObject returns ErrObjNotFound if the object doesn't
// exist. If the object does exist, it returns nil.
HasEncodedObject(plumbing.Hash) error
+}
+
+// DeltaObjectStorer is an EncodedObjectStorer that can return delta
+// objects.
+type DeltaObjectStorer interface {
+ // DeltaObject is the same as EncodedObject but without resolving deltas.
+ // Deltas will be returned as plumbing.DeltaObject instances.
+ DeltaObject(plumbing.ObjectType, plumbing.Hash) (plumbing.EncodedObject, error)
+}
+
+// Transactioner is a optional method for ObjectStorer, it enable transaction
+// base write and read operations in the storage
+type Transactioner interface {
+ // Begin starts a transaction.
+ Begin() Transaction
+}
+
+// LooseObjectStorer is an optional interface for managing "loose"
+// objects, i.e. those not in packfiles.
+type LooseObjectStorer interface {
// ForEachObjectHash iterates over all the (loose) object hashes
// in the repository without necessarily having to read those objects.
// Objects only inside pack files may be omitted.
@@ -52,6 +72,11 @@ type EncodedObjectStorer interface {
LooseObjectTime(plumbing.Hash) (time.Time, error)
// DeleteLooseObject deletes a loose object if it exists.
DeleteLooseObject(plumbing.Hash) error
+}
+
+// PackedObjectStorer is an optional interface for managing objects in
+// packfiles.
+type PackedObjectStorer interface {
// ObjectPacks returns hashes of object packs if the underlying
// implementation has pack files.
ObjectPacks() ([]plumbing.Hash, error)
@@ -60,21 +85,6 @@ type EncodedObjectStorer interface {
DeleteOldObjectPackAndIndex(plumbing.Hash, time.Time) error
}
-// DeltaObjectStorer is an EncodedObjectStorer that can return delta
-// objects.
-type DeltaObjectStorer interface {
- // DeltaObject is the same as EncodedObject but without resolving deltas.
- // Deltas will be returned as plumbing.DeltaObject instances.
- DeltaObject(plumbing.ObjectType, plumbing.Hash) (plumbing.EncodedObject, error)
-}
-
-// Transactioner is a optional method for ObjectStorer, it enable transaction
-// base write and read operations in the storage
-type Transactioner interface {
- // Begin starts a transaction.
- Begin() Transaction
-}
-
// PackfileWriter is a optional method for ObjectStorer, it enable direct write
// of packfile to the storage
type PackfileWriter interface {