Compare commits

...

2 Commits

Author SHA1 Message Date
d99d766621 Merge pull request 'fix' (#22) from master into dev
Reviewed-on: #22
2025-03-23 11:31:12 +03:00
Egor Matveev
4d2e0198f3 fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 41s
Deploy Dev / Push (pull_request) Successful in 26s
Deploy Dev / Deploy dev (pull_request) Successful in 7s
2025-03-23 11:30:46 +03:00

View File

@ -71,7 +71,7 @@ func Take(queue string) (*Task, error) {
"taken_at": now, "taken_at": now,
"attempts": task.Attempts + 1, "attempts": task.Attempts + 1,
"available_from": now.Add( "available_from": now.Add(
time.Duration(task.SecondsToExecute) * time.Second, time.Duration(task.SecondsToExecute+task.Attempts) * time.Second,
), ),
}, },
}, },
@ -91,7 +91,7 @@ func findTask(queue string, now time.Time) (*Task, error) {
"queue": queue, "queue": queue,
"available_from": bson.M{"$lte": now}, "available_from": bson.M{"$lte": now},
}, },
options.Find().SetLimit(1), options.Find().SetSort(bson.D{{Key: "available_from", Value: 1}}).SetLimit(1),
) )
if err != nil { if err != nil {
println("Error find") println("Error find")