worker/internal/workers/shortstat/timeout.go
skeris 525d54645c
All checks were successful
Deploy / CreateImage (push) Successful in 2m23s
Deploy / DeployService (push) Successful in 29s
debug: gigachat won't create questions
2025-06-03 21:00:05 +03:00

41 lines
780 B
Go

package shortstat
import (
"context"
"database/sql"
"gitea.pena/SQuiz/common/dal"
"gitea.pena/SQuiz/worker/internal/workers"
"time"
)
// ShortStat struct of worker for expiration worker
type ShortStat struct {
w *workers.Worker
d *dal.DAL
}
// New creation of worker
func New(d *dal.DAL, p time.Duration) *ShortStat {
return &ShortStat{
w: workers.New(p),
d: d,
}
}
// Start method for starting worker with long polling from postgres
func (t *ShortStat) Start(ctx context.Context) {
t.w.Start(ctx, func(ctx context.Context) error {
if err := t.d.WorkerRepo.WorkerStatProcess(ctx); err != nil {
if err != sql.ErrNoRows {
return err
}
}
return nil
})
}
func (t *ShortStat) ExposeErr(ctx context.Context, err *error) {
t.w.ExposeErr(ctx, err)
}