scrapper-mandarake/internal/app/handler.go

45 lines
699 B
Go
Raw Normal View History

2026-04-03 13:02:10 +03:00
package app
import (
"context"
log "github.com/sirupsen/logrus"
"parser-mandarake/config"
"time"
)
const AppName string = "Mandarake parser"
type App struct {
mode string
}
func NewApp(cfg *config.Config) *App {
a := App{
mode: cfg.App.Mode,
}
log.Infof("%v: %v", AppName, a.mode)
return &a
}
func (app *App) Run(ctx context.Context) error {
log.Info("App started")
errChan := make(chan error, 3)
select {
case <-ctx.Done():
return app.Shutdown(ctx)
case err := <-errChan:
return err
}
}
func (app *App) Shutdown(ctx context.Context) error {
log.Info("App shutting down")
ctx, cancel := context.WithTimeout(ctx, time.Second*10)
defer cancel()
_ = ctx
return nil
}