refactor(backend): standardize errors and simplify configuration and test setup

This commit is contained in:
TakuyaYagam1 committed 2026-10-05 16:15:30 +03:00
1 parent 1535c19b8c
commit 138666a7bb
92 files changed
+3994 -210

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
package outbound
import (
"context"
"errors"
"time"
)
var (
ErrCacheMiss = errors.New("cache key not found")
ErrInvalidCacheKey = errors.New("cache key must not be empty")
ErrInvalidCacheTTL = errors.New("cache TTL must be positive")
)
// Cache stores serialized values with a mandatory expiration.
type Cache interface {
// Get returns ErrCacheMiss only when a key is absent, never on a service failure.
Get(ctx context.Context, key string) ([]byte, error)
Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
// Del succeeds when a key is already absent or no keys are supplied.
Del(ctx context.Context, keys ...string) error
}
@@ -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
}