fix
This commit is contained in:
parent
cd798328a7
commit
9533fe5637
@ -6,6 +6,8 @@ services:
|
|||||||
image: mathwave/sprint-repo:queues
|
image: mathwave/sprint-repo:queues
|
||||||
networks:
|
networks:
|
||||||
- queues-development
|
- queues-development
|
||||||
|
ports:
|
||||||
|
- 1239:1239
|
||||||
environment:
|
environment:
|
||||||
MONGO_HOST: "mongo.develop.sprinthub.ru"
|
MONGO_HOST: "mongo.develop.sprinthub.ru"
|
||||||
MONGO_PASSWORD: $MONGO_PASSWORD_DEV
|
MONGO_PASSWORD: $MONGO_PASSWORD_DEV
|
||||||
|
@ -20,6 +20,7 @@ func Take(w http.ResponseWriter, r *http.Request) {
|
|||||||
queue := r.Header.Get("queue")
|
queue := r.Header.Get("queue")
|
||||||
task, err := tasks.Take(queue)
|
task, err := tasks.Take(queue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
println("Error taking")
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -37,6 +38,7 @@ func Take(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
data, err := json.Marshal(response)
|
data, err := json.Marshal(response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
println("Error marshalling")
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -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}})
|
_, err = collection().UpdateByID(context.TODO(), task.Id, bson.M{"$set": bson.M{"taken_at": now, "attempts": task.Attempts + 1}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
println("Error updaing")
|
||||||
|
println(err.Error())
|
||||||
return nil, errors.ErrInternalError
|
return nil, errors.ErrInternalError
|
||||||
}
|
}
|
||||||
return task, nil
|
return task, nil
|
||||||
@ -78,12 +80,16 @@ func findTask(queue string, now time.Time) (*Task, error) {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
println("Error find")
|
||||||
|
println(err.Error())
|
||||||
return nil, errors.ErrInternalError
|
return nil, errors.ErrInternalError
|
||||||
}
|
}
|
||||||
|
|
||||||
var results []Task
|
var results []Task
|
||||||
err = cursor.All(context.TODO(), &results)
|
err = cursor.All(context.TODO(), &results)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
println("Error all")
|
||||||
|
println(err.Error())
|
||||||
return nil, errors.ErrInternalError
|
return nil, errors.ErrInternalError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user