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,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
|
||||
}
|
||||
Reference in new issue
Block a user