reflector.go/store/store.go

44 lines
1.4 KiB
Go
Raw Normal View History

2018-01-29 20:37:26 +01:00
package store
import (
2021-07-20 02:09:14 +02:00
"github.com/lbryio/reflector.go/shared"
2019-11-14 01:11:35 +01:00
"github.com/lbryio/lbry.go/v2/extras/errors"
"github.com/lbryio/lbry.go/v2/stream"
)
2018-02-07 21:21:20 +01:00
// BlobStore is an interface for handling blob storage.
2018-01-29 20:37:26 +01:00
type BlobStore interface {
2020-10-22 19:49:02 +02:00
// Name of blob store (useful for metrics)
Name() string
2021-07-20 02:09:14 +02:00
// Has Does blob exist in the store.
2018-09-20 17:24:36 +02:00
Has(hash string) (bool, error)
2020-10-29 19:22:58 +01:00
// Get the blob from the store. Must return ErrBlobNotFound if blob is not in store.
2021-01-09 05:08:20 +01:00
Get(hash string) (stream.Blob, shared.BlobTrace, error)
2020-10-29 19:22:58 +01:00
// Put the blob into the store.
Put(hash string, blob stream.Blob) error
2021-07-20 02:09:14 +02:00
// PutSD an SD blob into the store.
PutSD(hash string, blob stream.Blob) error
2020-10-29 19:22:58 +01:00
// Delete the blob from the store.
2018-09-20 17:24:36 +02:00
Delete(hash string) error
// Shutdown the store gracefully
Shutdown()
2018-09-20 17:24:36 +02:00
}
2019-10-03 19:36:35 +02:00
// Blocklister is a store that supports blocking blobs to prevent their inclusion in the store.
2018-09-20 17:24:36 +02:00
type Blocklister interface {
// Block deletes the blob and prevents it from being uploaded in the future
Block(hash string) error
2019-10-03 19:36:35 +02:00
// Wants returns false if the hash exists in store or is blocked, true otherwise
2018-09-20 17:24:36 +02:00
Wants(hash string) (bool, error)
2018-01-29 20:37:26 +01:00
}
2018-02-07 21:21:20 +01:00
2020-10-22 18:18:31 +02:00
// lister is a store that can list cached blobs. This is helpful when an overlay
// cache needs to track blob existence.
type lister interface {
list() ([]string, error)
}
//ErrBlobNotFound is a standard error when a blob is not found in the store.
2018-02-07 21:21:20 +01:00
var ErrBlobNotFound = errors.Base("blob not found")