Reject async requests in case if MQ is not reachable

This commit is contained in:
Denis Makogon
2017-07-25 10:03:04 -07:00
committed by Reed Allman
parent 565f61fe6f
commit 97b0b97bd8
5 changed files with 64 additions and 18 deletions

View File

@@ -245,8 +245,14 @@ func (s *Server) serve(ctx context.Context, c *gin.Context, appName string, rout
priority := int32(0)
newTask.Priority = &priority
newTask.Payload = string(pl)
// Push to queue
enqueue(c, s.MQ, newTask)
_, err = enqueue(c, s.MQ, newTask)
if err != nil {
handleErrorResponse(c, err)
return true
}
log.Info("Added new task to queue")
c.JSON(http.StatusAccepted, map[string]string{"call_id": newTask.ID})