able to get product

This commit is contained in:
Gitea
2023-11-30 00:39:51 +03:00
parent 606b94e35b
commit 414dc87091
19 changed files with 2204 additions and 77 deletions

View File

@ -0,0 +1,43 @@
package ports
import (
"context"
"log/slog"
"git.loyso.art/frx/kurious/internal/common/xlog"
"git.loyso.art/frx/kurious/internal/kurious/service"
"github.com/robfig/cron/v3"
)
type BackgroundParser struct {
scheduler *cron.Cron
}
func NewBackgroundParser(ctx context.Context, svc service.Application, log *slog.Logger) *BackgroundParser {
clog := xlog.WrapSLogger(ctx, log)
scheduler := cron.New(cron.WithSeconds(), cron.WithChain(
cron.Recover(clog),
))
bp := &BackgroundParser{
scheduler: scheduler,
}
return bp
}
func (bp *BackgroundParser) Run() {
bp.scheduler.Run()
}
func (bp *BackgroundParser) Shutdown(ctx context.Context) error {
sdctx := bp.scheduler.Stop()
select {
case <-ctx.Done():
return ctx.Err()
case <-sdctx.Done():
return nil
}
}