Skip to content

Commit

Permalink
Don't log error when job exists
Browse files Browse the repository at this point in the history
  • Loading branch information
git-hulk committed Sep 27, 2023
1 parent 0f41b01 commit 4180f84
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions engine/engine.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package engine

import (
"errors"
"io"
)

var ErrJobExisted = errors.New("job existed")

type Engine interface {
Publish(job Job) (jobID string, err error)
Consume(namespace string, queues []string, ttrSecond, timeoutSecond uint32) (job Job, err error)
Expand Down
3 changes: 1 addition & 2 deletions engine/redis_v2/pool.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package redis_v2

import (
"errors"
"time"

go_redis "github.com/go-redis/redis/v8"
Expand Down Expand Up @@ -47,7 +46,7 @@ func (p *Pool) Add(j engine.Job) error {
return err
}
if !ok {
return errors.New("key existed") // Key existed before, avoid overwriting it, so return error
return engine.ErrJobExisted // Key existed before, avoid overwriting it, so return error
}
return err
}
Expand Down
2 changes: 1 addition & 1 deletion storage/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (m *Manager) PumpFn(name string, pool engine.Engine, threshold int64) func(
jobsID := make([]string, 0)
for _, job := range jobs {
_, err = pool.Publish(job)
if err != nil {
if err != nil && !errors.Is(err, engine.ErrJobExisted) {
logger.WithFields(logrus.Fields{
"job": job,
"err": err,
Expand Down

0 comments on commit 4180f84

Please sign in to comment.