fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 38s
Deploy Dev / Push (pull_request) Successful in 26s
Deploy Dev / Deploy dev (pull_request) Successful in 8s

This commit is contained in:
Egor Matveev 2024-12-31 02:36:30 +03:00
parent cd798328a7
commit 9533fe5637
3 changed files with 10 additions and 0 deletions

View File

@ -6,6 +6,8 @@ services:
image: mathwave/sprint-repo:queues
networks:
- queues-development
ports:
- 1239:1239
environment:
MONGO_HOST: "mongo.develop.sprinthub.ru"
MONGO_PASSWORD: $MONGO_PASSWORD_DEV

View File

@ -20,6 +20,7 @@ func Take(w http.ResponseWriter, r *http.Request) {
queue := r.Header.Get("queue")
task, err := tasks.Take(queue)
if err != nil {
println("Error taking")
w.WriteHeader(http.StatusInternalServerError)
return
}
@ -37,6 +38,7 @@ func Take(w http.ResponseWriter, r *http.Request) {
data, err := json.Marshal(response)
if err != nil {
println("Error marshalling")
w.WriteHeader(http.StatusInternalServerError)
return
}

View File

@ -64,6 +64,8 @@ func Take(queue string) (*Task, error) {
}
_, err = collection().UpdateByID(context.TODO(), task.Id, bson.M{"$set": bson.M{"taken_at": now, "attempts": task.Attempts + 1}})
if err != nil {
println("Error updaing")
println(err.Error())
return nil, errors.ErrInternalError
}
return task, nil
@ -78,12 +80,16 @@ func findTask(queue string, now time.Time) (*Task, error) {
},
)
if err != nil {
println("Error find")
println(err.Error())
return nil, errors.ErrInternalError
}
var results []Task
err = cursor.All(context.TODO(), &results)
if err != nil {
println("Error all")
println(err.Error())
return nil, errors.ErrInternalError
}