Documentation
¶
Overview ¶
Package store puts and gets original document bytes in object storage.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("store: object not found")
ErrNotFound is returned by Get and Delete when no object exists at a URI. Delete implementations treat it as success — deleting an object that is already gone is the outcome the caller asked for — but it is exported so callers distinguishing "never stored" from "storage broke" can.
Functions ¶
This section is empty.
Types ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory Store, for tests. Not safe to use as a production backend — nothing is persisted.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore builds an empty MemoryStore.
func (*MemoryStore) Delete ¶
func (s *MemoryStore) Delete(_ context.Context, uri string) error
Delete removes the object, if present. Missing is not an error.
func (*MemoryStore) Get ¶
func (s *MemoryStore) Get(_ context.Context, uri string) (io.ReadCloser, error)
func (*MemoryStore) Len ¶
func (s *MemoryStore) Len() int
Len reports how many objects are held, for tests asserting that a delete actually purged the bytes rather than only the database row.
type MinIOConfig ¶
type MinIOConfig struct {
Endpoint string
AccessKey string
SecretKey string
Bucket string
UseSSL bool
}
MinIOConfig configures MinIOStore. Works against MinIO itself or any S3-compatible endpoint (AWS S3, R2, B2, ...).
type MinIOStore ¶
type MinIOStore struct {
// contains filtered or unexported fields
}
MinIOStore is an S3-compatible Store implementation.
func NewMinIOStore ¶
func NewMinIOStore(ctx context.Context, cfg MinIOConfig) (*MinIOStore, error)
NewMinIOStore builds a MinIOStore and ensures its bucket exists.
func (*MinIOStore) Delete ¶
func (s *MinIOStore) Delete(ctx context.Context, uri string) error
Delete removes the object at uri. S3 DELETE is already idempotent — it reports success for a key that does not exist — so this needs no special-casing to satisfy the interface's idempotency contract.
func (*MinIOStore) Get ¶
func (s *MinIOStore) Get(ctx context.Context, uri string) (io.ReadCloser, error)
Get retrieves the object at uri (as returned by Put).
type Store ¶
type Store interface {
// Put uploads data under a tenant-prefixed key and returns the URI it
// was stored at.
Put(ctx context.Context, tenantID uuid.UUID, filename string, data []byte, mimeType string) (uri string, err error)
// Get retrieves the object at uri. The caller must close the reader.
Get(ctx context.Context, uri string) (io.ReadCloser, error)
// Delete removes the object at uri. It is idempotent: deleting a URI
// that holds no object returns nil, so a retried cleanup does not fail
// on its second pass.
Delete(ctx context.Context, uri string) error
}
Store puts and gets raw document bytes, keyed by a tenant-scoped URI.