Documentation
¶
Overview ¶
Package storage builds the StorageClient from config: the in-memory backend (the default) or an S3-compatible one (AWS S3 or MinIO), run through the client tier (Decorate). The concrete backends live in the memory/ and s3/ subpackages.
Index ¶
Constants ¶
const ( // KindMemory keeps objects in process (the default; no presigning). KindMemory client.Kind = "memory" // KindS3 uses an S3-compatible service; S3.Kind picks AWS S3 or MinIO. KindS3 client.Kind = "s3" )
Variables ¶
This section is empty.
Functions ¶
func Decorate ¶ added in v0.0.7
func Decorate( base interfaces.StorageClient, decs decorate.Decorations, name string, opts ...client.Option, ) (interfaces.StorageClient, error)
Decorate runs every operation of base through the client tier as the client named name. The AWS SDK owns wire-level retry, so retry stays off unless deps enables it; operations that consume a body or stream or are not idempotent (Upload, Download, Create/CompleteMultipartUpload) are never replayed. Each operation is one method of interfaces.StorageClient.
func NewFromConfig ¶
func NewFromConfig( ctx context.Context, cfg Config, deps Deps, ) (interfaces.StorageClient, error)
NewFromConfig builds the storage client cfg.Kind selects and runs it through the client tier. ctx bounds the S3 kind's AWS config load. An unknown kind or an invalid S3 config is CodeInvalidInput.
Types ¶
type Config ¶
type Config struct {
// Kind selects the backend; empty means KindMemory.
Kind client.Kind `yaml:"kind" mapstructure:"kind"`
// Name labels the client in decoration overrides, metrics, spans and logs; empty
// uses the family name ("storage").
Name string `yaml:"name" mapstructure:"name"`
// S3 configures KindS3: the flavor (AWS S3 or MinIO), endpoint and credentials.
S3 infra.S3Config `yaml:"s3" mapstructure:"s3"`
// MultipartThreshold is the object size (bytes) above which Upload switches to
// multipart; 0 uses the default (5 MiB).
MultipartThreshold int64 `yaml:"multipart_threshold" mapstructure:"multipart_threshold"`
}
Config selects and tunes the storage client.
func DefaultConfig ¶ added in v0.0.7
func DefaultConfig() Config
DefaultConfig returns the memory kind.
type Deps ¶ added in v0.0.7
type Deps struct {
// Decorations decorates the client from the decoration config (decoration.clients)
// and supplies its observability.
decorate.Decorations
// API replaces the S3 SDK client KindS3 builds from Config.S3 (presigning is
// unavailable through it).
API s3.S3API
}
Deps carries the storage runtime collaborators.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package memory provides an in-memory StorageClient backend for no-infra builds and tests.
|
Package memory provides an in-memory StorageClient backend for no-infra builds and tests. |
|
Package s3 implements the StorageClient against S3-compatible object stores (AWS S3 and MinIO), selected by configuration.
|
Package s3 implements the StorageClient against S3-compatible object stores (AWS S3 and MinIO), selected by configuration. |