maddy

Fork https://github.com/foxcpp/maddy

git clone git://git.lin.moe/go/maddy.git

 1package module
 2
 3import (
 4	"context"
 5	"errors"
 6	"io"
 7)
 8
 9type Blob interface {
10	Sync() error
11	io.Writer
12	io.Closer
13}
14
15var ErrNoSuchBlob = errors.New("blob_store: no such object")
16
17const UnknownBlobSize int64 = -1
18
19// BlobStore is the interface used by modules providing large binary object
20// storage.
21type BlobStore interface {
22	// Create creates a new blob for writing.
23	//
24	// Sync will be called on the returned Blob object after -all- data has
25	// been successfully written.
26	//
27	// Close without Sync can be assumed to happen due to an unrelated error
28	// and stored data can be discarded.
29	//
30	// blobSize indicates the exact amount of bytes that will be written
31	// If -1 is passed - it is unknown and implementation will not make
32	// any assumptions about the blob size. Error can be returned by any
33	// Blob method if more than than blobSize bytes get written.
34	//
35	// Passed context will cover the entire blob write operation.
36	Create(ctx context.Context, key string, blobSize int64) (Blob, error)
37
38	// Open returns the reader for the object specified by
39	// passed key.
40	//
41	// If no such object exists - ErrNoSuchBlob is returned.
42	Open(ctx context.Context, key string) (io.ReadCloser, error)
43
44	// Delete removes a set of keys from store. Non-existent keys are ignored.
45	Delete(ctx context.Context, keys []string) error
46}