mirror of
https://github.com/acaloiaro/neoq
synced 2026-07-21 10:12:18 +00:00
feat: log job_id regardless of error
This commit is contained in:
parent
a6f7fbcd36
commit
9e3e803ec2
4 changed files with 12 additions and 11 deletions
|
|
@ -21,6 +21,7 @@ import (
|
|||
"github.com/iancoleman/strcase"
|
||||
"github.com/jackc/pgerrcode"
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"github.com/jsuar/go-cron-descriptor/pkg/crondescriptor"
|
||||
|
|
@ -618,17 +619,17 @@ func (p *PgBackend) updateJob(ctx context.Context, jobErr error) (err error) {
|
|||
status := internal.JobStatusProcessed
|
||||
errMsg := ""
|
||||
|
||||
if jobErr != nil {
|
||||
p.logger.Error("job failed", slog.Any("job_error", jobErr))
|
||||
status = internal.JobStatusFailed
|
||||
errMsg = jobErr.Error()
|
||||
}
|
||||
|
||||
var job *jobs.Job
|
||||
if job, err = jobs.FromContext(ctx); err != nil {
|
||||
return fmt.Errorf("error getting job from context: %w", err)
|
||||
}
|
||||
|
||||
if jobErr != nil {
|
||||
p.logger.Error("job failed", slog.Int64("job_id", job.ID), slog.Any("job_error", jobErr))
|
||||
status = internal.JobStatusFailed
|
||||
errMsg = jobErr.Error()
|
||||
}
|
||||
|
||||
var tx pgx.Tx
|
||||
if tx, err = txFromContext(ctx); err != nil {
|
||||
return fmt.Errorf("error getting tx from context: %w", err)
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -8,7 +8,7 @@ require (
|
|||
github.com/hibiken/asynq v0.24.0
|
||||
github.com/iancoleman/strcase v0.2.0
|
||||
github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa
|
||||
github.com/jackc/pgx/v5 v5.5.4
|
||||
github.com/jackc/pgx/v5 v5.6.0
|
||||
github.com/jsuar/go-cron-descriptor v0.1.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/robfig/cron v1.2.0
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -82,8 +82,8 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI
|
|||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgx/v5 v5.5.4 h1:Xp2aQS8uXButQdnCMWNmvx6UysWQQC+u1EoizjguY+8=
|
||||
github.com/jackc/pgx/v5 v5.5.4/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
|
||||
github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY=
|
||||
github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw=
|
||||
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
|
||||
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/jsuar/go-cron-descriptor v0.1.0 h1:Q97ujk+/xhcz1lA9nmUMq750FZV7RlV23TNyMB74xkQ=
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ schema = 3
|
|||
version = "v0.0.0-20221227161230-091c0ba34f0a"
|
||||
hash = "sha256-rBtUw15WPPDp2eulHXH5e2zCIed1OPFYwlCpgDOnGRM="
|
||||
[mod."github.com/jackc/pgx/v5"]
|
||||
version = "v5.5.4"
|
||||
hash = "sha256-T4nYUbDDiyN7v6BRhEkPJ9slatzUMrEyoGAyjfK9syI="
|
||||
version = "v5.6.0"
|
||||
hash = "sha256-6Tx7UF6gWc4e572x6wBDLghoe0Inhef0cH2Fq5I8fX4="
|
||||
[mod."github.com/jackc/puddle/v2"]
|
||||
version = "v2.2.1"
|
||||
hash = "sha256-Edf8SLT/8l+xfHm9IjUGxs1MHtic2VgRyfqb6OzGA9k="
|
||||
|
|
|
|||
Loading…
Reference in a new issue