// process a message from the SQS queue. This should be run inside a goroutine. func processMessage(q *sqs.Queue, m sqs.Message, wo work_order.WorkOrder, wg *sync.WaitGroup) { logger.Debug("Starting process on %d from '%s'", wo.Id, m.MessageId) // start heartbeat beat := heartbeat.Start(q, &m) // execute the work err := wo.Execute() if err != nil { logger.Error("Error executing: %d - %v", wo.Id, err) } // send response back to devops-web wo.Report() // stop the heartbeat beat.Stop() // delete message logger.Debug("Deleting message: %s", m.MessageId) _, err = q.DeleteMessage(&m) if err != nil { logger.Error("ERROR: Couldn't delete message: %s - %v", m.MessageId, err) } // exit this goroutine wg.Done() }