Last active
August 29, 2015 14:01
-
-
Save ianneub/688a4265992893c0c347 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func updateSQS(t time.Time) { | |
log.Println("Sending heartbeat to SQS") | |
// create the SQS client | |
client, err := sqs.NewFrom(os.Getenv("AWS_ACCESS_KEY_ID"), os.Getenv("AWS_SECRET_ACCESS_KEY"), "us.east") | |
if err != nil { | |
log.Println("ERROR:", err) | |
} | |
// fake an existing sqs.Message by creating it and setting the ReceiptHandle | |
message := sqs.Message{} | |
message.ReceiptHandle = os.Getenv("RECEIPT_HANDLE") | |
// get the SQS queue | |
queue, err := client.GetQueue(os.Getenv("SQS_QUEUE_NAME")) | |
if err != nil { | |
log.Println("ERROR:", err) | |
} | |
// change the sqs message visibility | |
// In this case I don't care about the res object. I'm only worried if there was an err or not. | |
// | |
// What is the correct way to do this? | |
// | |
// The following will give a compiler error because I didn't use the res variable. | |
// res, err := queue.ChangeMessageVisibility(&message, 5 * 60) | |
// | |
// However the following seems like it might be bad if err could potentially be of a different Type than the err on line 15. | |
_, err = queue.ChangeMessageVisibility(&message, 5 * 60) | |
if (err != nil) { | |
log.Println("ERROR:", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment