feat(storage): define FileStore interface abstraction #126
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Extract the current MinIO-specific code in
internal/storage/storage.gointo aFileStoreinterface, enabling pluggable storage backends.Context
Currently
internal/storage/storage.godefines a concreteStoragestruct wrapping*minio.Clientwith no interface abstraction. TheServerstruct ininternal/api/server.goholds a*storage.Storagepointer directly, and all handlers (file_handlers.go,handlers.go) call methods on this concrete type. Nil-checks (if s.storage == nil) gate file operations when storage is unconfigured.Requirements
Define a
FileStoreinterface ininternal/storage/:Implementation steps
FileStoreinterface in a new fileinternal/storage/interface.goStoragestruct satisfies the interface (it already has all these methods)Existsmethod toStorage(currently missing — implement viaminio.StatObject)Serverstruct ininternal/api/server.goto holdstorage.FileStoreinstead of*storage.StorageNewServer()constructor and all call sitescmd/silod/main.gostartup wiring — currently passes*storage.Storage(or nil)FileKey()andThumbnailKey()as package-level helpers (not on interface)internal/config/config.goStorageConfigwith aBackendfield:Files to modify
internal/storage/storage.go— addExistsmethod, ensure interface complianceinternal/storage/interface.go— new file withFileStoreinterfaceinternal/api/server.go— changestorage *storage.Storagetostorage storage.FileStoreinternal/api/file_handlers.go— no changes needed if using interface (6 handlers:HandlePresignUpload,HandleListItemFiles,HandleAssociateItemFile,HandleDeleteItemFile,HandleSetItemThumbnail)internal/api/handlers.go—HandleUploadFile,HandleDownloadFileuses.storage.Put(),s.storage.Get(),s.storage.GetVersion()internal/config/config.go— addBackendandFilesystemconfig fieldscmd/silod/main.go— backend selection logicCurrent method signatures on
StoragePut(ctx, key, reader, size, contentType) (*PutResult, error)Get(ctx, key) (io.ReadCloser, error)GetVersion(ctx, key, versionID) (io.ReadCloser, error)Delete(ctx, key) errorPing(ctx) errorPresignPut(ctx, key, expiry) (*url.URL, error)Copy(ctx, srcKey, dstKey) errorBucket() stringFileKey(partNumber, revision) string(standalone)ThumbnailKey(partNumber, revision) string(standalone)Acceptance criteria
FileStoreinterface defined and documentedStoragestruct implementsFileStoreServerusesFileStoreinterface, not concrete typestorage.backendfieldgo build ./...passes with no regressionsPriority
P0 — blocks all other storage migration work
Part of
Storage Migration: MinIO → PostgreSQL + Filesystem