refactor(backend): standardize errors and simplify configuration and test setup
This commit is contained in:
1 parent
1535c19b8c
commit
138666a7bb
92 files changed
+3994
-210
No files matched your search
@@ -0,0 +1,31 @@
|
||||
package outbound
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrObjectNotFound = errors.New("object not found")
|
||||
ErrInvalidObject = errors.New("invalid object input")
|
||||
ErrObjectStorage = errors.New("object storage request failed")
|
||||
)
|
||||
|
||||
// Object contains a streaming response. The caller must close Body and keep the
|
||||
// request context alive until reading is complete.
|
||||
type Object struct {
|
||||
Body io.ReadCloser
|
||||
Size int64
|
||||
ContentType string
|
||||
}
|
||||
|
||||
type ObjectStorage interface {
|
||||
// Put streams exactly size bytes. The caller owns the source reader and must
|
||||
// ensure a blocking source can be canceled. An error may leave a completed
|
||||
// object when the server accepted the write before the response was lost.
|
||||
Put(ctx context.Context, key string, body io.Reader, size int64, contentType string) error
|
||||
Get(ctx context.Context, key string) (Object, error)
|
||||
// Delete succeeds when the object is already absent.
|
||||
Delete(ctx context.Context, key string) error
|
||||
}
|
||||
Reference in new issue
Block a user