feat(storage-minio): initial implementation — MinIO/S3 object storage with lifecycle (v1.0.0)

Introduces code.nochebuena.dev/einherjar/storage-minio — the object storage
starter for the Einherjar framework. Absorbs the minio package from micro-lib,
replacing fmt.Errorf wrapping with core/xerrors.

Interfaces (CT-6: one TypeSpec per file):
- Provider — PutObject, RemoveObject, GetObject, PresignedGetObject, HandleError
- Component — lifecycle.Component + observability.Checkable + Provider + Native()

Implementation:
- New(logger, cfg) Component — client not created until OnInit
- OnInit: minio.New with credentials and transport; bucket existence check
- OnStart: BucketExists PING; logs "minio: connected"
- OnStop: logs "minio: closing client" (minio-go is stateless; no explicit close)
- HealthCheck: BucketExists check; Priority LevelCritical
- Native() *miniogo.Client — escape hatch for operations not in Provider
- HandleError: maps minio-go errors to xerrors (NotFound, AlreadyExists, Internal)

Config (EINHERJAR_MINIO_* env vars):
  Endpoint(required), AccessKey(required), SecretKey(required),
  Bucket(required), UseSSL(false), Region(us-east-1)

- Component interface embeds observability.Identifiable; identifiable.go implements
  ModulePath and ModuleVersion via runtime/debug.ReadBuildInfo() — prints in launcher banner
This commit is contained in:
2026-05-29 16:03:52 +00:00
commit 1a34b84ee9
17 changed files with 1976 additions and 0 deletions

26
provider.go Normal file
View File

@@ -0,0 +1,26 @@
package minio
import (
"context"
"io"
"net/url"
"time"
miniogo "github.com/minio/minio-go/v7"
)
// Provider is the MinIO operation interface for the most common bucket operations.
// Inject it into repositories; call Native() on Component for SDK operations not covered here.
type Provider interface {
// PutObject uploads an object to the given bucket and key.
PutObject(ctx context.Context, bucket, key string, reader io.Reader, size int64, opts miniogo.PutObjectOptions) (miniogo.UploadInfo, error)
// RemoveObject deletes an object from the given bucket and key.
RemoveObject(ctx context.Context, bucket, key string, opts miniogo.RemoveObjectOptions) error
// GetObject downloads an object and returns it as a readable stream.
// The caller must close the returned object after reading.
GetObject(ctx context.Context, bucket, key string, opts miniogo.GetObjectOptions) (*miniogo.Object, error)
// PresignedGetObject returns a pre-signed URL for downloading an object.
PresignedGetObject(ctx context.Context, bucket, key string, expires time.Duration, reqParams url.Values) (*url.URL, error)
// HandleError maps a minio-go error to a typed xerrors value.
HandleError(err error) error
}