chore: stabilize lint and verify builds
This commit is contained in:
@@ -5,19 +5,21 @@ import (
|
||||
|
||||
"github.com/riverqueue/river"
|
||||
"github.com/riverqueue/river/rivertype"
|
||||
log "github.com/sirupsen/logrus"
|
||||
logrus "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type CustomErrorHandler struct{}
|
||||
|
||||
func (*CustomErrorHandler) HandleError(ctx context.Context, job *rivertype.JobRow, err error) *river.ErrorHandlerResult {
|
||||
log.Infof("Job errored with: %s\n", err)
|
||||
func (*CustomErrorHandler) HandleError(_ context.Context, _ *rivertype.JobRow, err error) *river.ErrorHandlerResult {
|
||||
logrus.Infof("Job errored with: %s\n", err)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*CustomErrorHandler) HandlePanic(ctx context.Context, job *rivertype.JobRow, panicVal any, trace string) *river.ErrorHandlerResult {
|
||||
log.Infof("Job panicked with: %v\n", panicVal)
|
||||
log.Infof("Stack trace: %s\n", trace)
|
||||
func (*CustomErrorHandler) HandlePanic(_ context.Context, _ *rivertype.JobRow, panicVal any, trace string) *river.ErrorHandlerResult {
|
||||
logrus.Infof("Job panicked with: %v\n", panicVal)
|
||||
logrus.Infof("Stack trace: %s\n", trace)
|
||||
|
||||
return &river.ErrorHandlerResult{
|
||||
SetCancelled: true,
|
||||
}
|
||||
|
||||
@@ -3,11 +3,8 @@ package queue
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.ipao.vip/atom"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/contracts"
|
||||
|
||||
"quyun/v2/app/commands"
|
||||
"quyun/v2/app/errorx"
|
||||
"quyun/v2/app/jobs"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/database"
|
||||
@@ -17,8 +14,11 @@ import (
|
||||
"quyun/v2/providers/postgres"
|
||||
"quyun/v2/providers/storage"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
logrus "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"go.ipao.vip/atom"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/contracts"
|
||||
"go.uber.org/dig"
|
||||
)
|
||||
|
||||
@@ -56,20 +56,25 @@ type Service struct {
|
||||
CronJobs []contracts.CronJob `group:"cron_jobs"`
|
||||
}
|
||||
|
||||
func Serve(cmd *cobra.Command, args []string) error {
|
||||
return container.Container.Invoke(func(ctx context.Context, svc Service) error {
|
||||
log.SetFormatter(&log.JSONFormatter{})
|
||||
func Serve(_ *cobra.Command, _ []string) error {
|
||||
if err := container.Container.Invoke(func(ctx context.Context, svc Service) error {
|
||||
logrus.SetFormatter(&logrus.JSONFormatter{})
|
||||
|
||||
if svc.App.IsDevMode() {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
}
|
||||
|
||||
if err := svc.Job.Start(ctx); err != nil {
|
||||
return err
|
||||
return errorx.ErrOperationFailed.WithCause(err)
|
||||
}
|
||||
defer svc.Job.Close()
|
||||
|
||||
<-ctx.Done()
|
||||
|
||||
return nil
|
||||
})
|
||||
}); err != nil {
|
||||
return errorx.ErrOperationFailed.WithCause(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user