octopush/internal/server/storage_server.go

29 lines
827 B
Go
Raw Normal View History

2022-09-11 14:52:21 +02:00
package server
import (
"context"
2022-09-11 22:56:54 +02:00
"time"
2022-09-11 14:52:21 +02:00
"git.front.kjuulh.io/kjuulh/curre"
"git.front.kjuulh.io/kjuulh/kraken/internal/serverdeps"
"go.uber.org/zap"
)
func NewStorageServer(logger *zap.Logger, deps *serverdeps.ServerDeps) curre.Component {
storage := deps.GetStorageService()
return curre.NewFunctionalComponent(&curre.FunctionalComponent{
2022-09-11 22:56:54 +02:00
InitFunc: func(_ *curre.FunctionalComponent, ctx context.Context) error {
2022-09-11 14:52:21 +02:00
logger.Debug("Initializing storage")
return storage.InitializeStorage(ctx)
},
StartFunc: func(fc *curre.FunctionalComponent, ctx context.Context) error {
return nil
},
2022-09-11 22:56:54 +02:00
StopFunc: func(_ *curre.FunctionalComponent, ctx context.Context) error {
2022-09-11 14:52:21 +02:00
logger.Debug("Cleaning up storage")
2022-09-11 22:56:54 +02:00
ctx, _ = context.WithTimeout(ctx, time.Second*10)
2022-09-11 14:52:21 +02:00
return storage.CleanupStorage(ctx)
},
})
}