feat(s3): add S3 client with bucket bootstrap

This commit is contained in:
kk10
2026-11-02 18:49:39 +03:00
parent 9b38e090ee
commit 45c9f7731d
5 changed files with 307 additions and 0 deletions
+17
View File
@@ -18,6 +18,7 @@ import (
"mtusi2026-messenger/internal/logger"
"mtusi2026-messenger/internal/postgres"
"mtusi2026-messenger/internal/redis"
s3store "mtusi2026-messenger/internal/s3"
"mtusi2026-messenger/internal/service"
)
@@ -63,6 +64,22 @@ func Run() error {
log.Info("session store configured", "store", cfg.SessionStore)
s3Client, err := s3store.New(context.Background(), cfg.S3, log)
if err != nil {
log.Error("create s3 client", "error", err)
return err
}
ensureCtx, cancelEnsure := context.WithTimeout(context.Background(), 10*time.Second)
err = s3Client.EnsureBucket(ensureCtx)
cancelEnsure()
if err != nil {
log.Error("ensure s3 bucket", "error", err)
return err
}
log.Info("s3 storage ready", "endpoint", cfg.S3.Endpoint, "bucket", s3Client.Bucket())
cleanupCtx, stopCleanup := context.WithCancel(context.Background())
var cleanupWG sync.WaitGroup
cleanupWG.Go(func() {