diff options
author | Nick White <git@njw.name> | 2019-10-17 16:48:00 +0100 |
---|---|---|
committer | Nick White <git@njw.name> | 2019-10-17 16:48:00 +0100 |
commit | 9840edb21ab1bca093001d81c510910bb00c73d4 (patch) | |
tree | 8f7f85d9016dff20eed7d2ee0b25236635eff1be | |
parent | 3b14764fda520266411500d09acb0da475c2c114 (diff) |
Adjust the heartbeat searching function to hopefully have better luck at finding it and not letting another process steal it.
-rw-r--r-- | aws.go | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -17,7 +17,7 @@ import ( ) const PreprocPattern = `_bin[0-9].[0-9].png` -const heartbeatRetry = 10 +const heartbeatRetry = 20 type Qmsg struct { Id, Handle, Body string @@ -157,9 +157,6 @@ func (a *AwsConn) QueueHeartbeat(msg Qmsg, qurl string, duration int64) (Qmsg, e if ok && aerr.Code() == "InvalidParameterValue" { // Try heartbeatRetry times to find the message for range [heartbeatRetry]bool{} { - // Wait a little in case existing visibilitytimeout needs to expire - time.Sleep((time.Duration(duration) / heartbeatRetry) * time.Second) - msgResult, err := a.sqssvc.ReceiveMessage(&sqs.ReceiveMessageInput{ MaxNumberOfMessages: aws.Int64(10), VisibilityTimeout: &duration, @@ -178,6 +175,8 @@ func (a *AwsConn) QueueHeartbeat(msg Qmsg, qurl string, duration int64) (Qmsg, e }, nil } } + // Wait a little in case existing visibilitytimeout needs to expire + time.Sleep((2 * time.Duration(duration) / heartbeatRetry) * time.Second) } return Qmsg{}, errors.New("Heartbeat error failed to find message to update heartbeat") } else { |