aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--objectstore/chain/chain.go (renamed from objectdb/chain/chain.go)38
-rw-r--r--objectstore/objectstore.go (renamed from objectdb/objectdb.go)10
2 files changed, 24 insertions, 24 deletions
diff --git a/objectdb/chain/chain.go b/objectstore/chain/chain.go
index 1b4678d4..f11e3f67 100644
--- a/objectdb/chain/chain.go
+++ b/objectstore/chain/chain.go
@@ -6,20 +6,20 @@ import (
"fmt"
"io"
- "codeberg.org/lindenii/furgit/objectdb"
"codeberg.org/lindenii/furgit/objectid"
+ "codeberg.org/lindenii/furgit/objectstore"
"codeberg.org/lindenii/furgit/objecttype"
)
// Chain queries multiple object databases in order.
type Chain struct {
- backends []objectdb.ObjectDB
+ backends []objectstore.ObjectStore
}
// New creates an ordered object database chain.
-func New(backends ...objectdb.ObjectDB) *Chain {
+func New(backends ...objectstore.ObjectStore) *Chain {
return &Chain{
- backends: append([]objectdb.ObjectDB(nil), backends...),
+ backends: append([]objectstore.ObjectStore(nil), backends...),
}
}
@@ -33,12 +33,12 @@ func (chain *Chain) ReadBytesFull(id objectid.ObjectID) ([]byte, error) {
if err == nil {
return full, nil
}
- if errors.Is(err, objectdb.ErrObjectNotFound) {
+ if errors.Is(err, objectstore.ErrObjectNotFound) {
continue
}
- return nil, fmt.Errorf("objectdb: backend %d read bytes full: %w", i, err)
+ return nil, fmt.Errorf("objectstore: backend %d read bytes full: %w", i, err)
}
- return nil, objectdb.ErrObjectNotFound
+ return nil, objectstore.ErrObjectNotFound
}
// ReadBytesContent reads an object's type and content bytes from the first backend that has it.
@@ -51,12 +51,12 @@ func (chain *Chain) ReadBytesContent(id objectid.ObjectID) (objecttype.Type, []b
if err == nil {
return ty, content, nil
}
- if errors.Is(err, objectdb.ErrObjectNotFound) {
+ if errors.Is(err, objectstore.ErrObjectNotFound) {
continue
}
- return objecttype.TypeInvalid, nil, fmt.Errorf("objectdb: backend %d read bytes content: %w", i, err)
+ return objecttype.TypeInvalid, nil, fmt.Errorf("objectstore: backend %d read bytes content: %w", i, err)
}
- return objecttype.TypeInvalid, nil, objectdb.ErrObjectNotFound
+ return objecttype.TypeInvalid, nil, objectstore.ErrObjectNotFound
}
// ReadReaderFull reads a full serialized object stream from the first backend that has it.
@@ -69,12 +69,12 @@ func (chain *Chain) ReadReaderFull(id objectid.ObjectID) (io.ReadCloser, error)
if err == nil {
return reader, nil
}
- if errors.Is(err, objectdb.ErrObjectNotFound) {
+ if errors.Is(err, objectstore.ErrObjectNotFound) {
continue
}
- return nil, fmt.Errorf("objectdb: backend %d read reader full: %w", i, err)
+ return nil, fmt.Errorf("objectstore: backend %d read reader full: %w", i, err)
}
- return nil, objectdb.ErrObjectNotFound
+ return nil, objectstore.ErrObjectNotFound
}
// ReadReaderContent reads an object's type and content stream from the first backend that has it.
@@ -87,12 +87,12 @@ func (chain *Chain) ReadReaderContent(id objectid.ObjectID) (objecttype.Type, io
if err == nil {
return ty, reader, nil
}
- if errors.Is(err, objectdb.ErrObjectNotFound) {
+ if errors.Is(err, objectstore.ErrObjectNotFound) {
continue
}
- return objecttype.TypeInvalid, nil, fmt.Errorf("objectdb: backend %d read reader content: %w", i, err)
+ return objecttype.TypeInvalid, nil, fmt.Errorf("objectstore: backend %d read reader content: %w", i, err)
}
- return objecttype.TypeInvalid, nil, objectdb.ErrObjectNotFound
+ return objecttype.TypeInvalid, nil, objectstore.ErrObjectNotFound
}
// ReadHeader reads object header data from the first backend that has it.
@@ -105,12 +105,12 @@ func (chain *Chain) ReadHeader(id objectid.ObjectID) (objecttype.Type, int64, er
if err == nil {
return ty, size, nil
}
- if errors.Is(err, objectdb.ErrObjectNotFound) {
+ if errors.Is(err, objectstore.ErrObjectNotFound) {
continue
}
- return objecttype.TypeInvalid, 0, fmt.Errorf("objectdb: backend %d read header: %w", i, err)
+ return objecttype.TypeInvalid, 0, fmt.Errorf("objectstore: backend %d read header: %w", i, err)
}
- return objecttype.TypeInvalid, 0, objectdb.ErrObjectNotFound
+ return objecttype.TypeInvalid, 0, objectstore.ErrObjectNotFound
}
// Close closes all backends and joins close errors.
diff --git a/objectdb/objectdb.go b/objectstore/objectstore.go
index 6e1fbded..ea906c70 100644
--- a/objectdb/objectdb.go
+++ b/objectstore/objectstore.go
@@ -1,5 +1,5 @@
-// Package objectdb provides storage interfaces for Git objects.
-package objectdb
+// Package objectstore provides storage interfaces for Git objects.
+package objectstore
import (
"errors"
@@ -11,10 +11,10 @@ import (
// ErrObjectNotFound indicates that an object does not exist in a backend.
// TODO: This might need to be an interface or otherwise be able to encapsulate multiple concrete backends'
-var ErrObjectNotFound = errors.New("objectdb: object not found")
+var ErrObjectNotFound = errors.New("objectstore: object not found")
-// ObjectDB reads Git objects by object ID.
-type ObjectDB interface {
+// ObjectStore reads Git objects by object ID.
+type ObjectStore interface {
// ReadBytesFull reads a full serialized object as "type size\\x00content".
// If hashed with the same algorithm it MUST match the object ID.
ReadBytesFull(id objectid.ObjectID) ([]byte, error)