summaryrefslogtreecommitdiff
path: root/bookpipeline/aws.go
diff options
context:
space:
mode:
authorNick White <git@njw.name>2019-09-23 16:38:34 +0100
committerNick White <git@njw.name>2019-09-23 16:38:34 +0100
commit933aa3bf976f66d2a184922aff613c2b22fdca1b (patch)
tree858425d74bf2743c6d0baa53ba1474262ac34343 /bookpipeline/aws.go
parent107b1d28add39d1e252beec72b83f9fd69ee5cdb (diff)
Move the sqs stuff out to aws.go
Diffstat (limited to 'bookpipeline/aws.go')
-rw-r--r--bookpipeline/aws.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/bookpipeline/aws.go b/bookpipeline/aws.go
index 4d32f3d..689f1b2 100644
--- a/bookpipeline/aws.go
+++ b/bookpipeline/aws.go
@@ -165,6 +165,21 @@ func (a *AwsConn) QueueHeartbeat(msg Qmsg, qurl string, duration int64) (Qmsg, e
return Qmsg{}, nil
}
+// GetQueueDetails gets the number of in progress and available
+// messages for a queue. These are returned as strings.
+func (a *AwsConn) GetQueueDetails(url string) (string, string, error) {
+ numAvailable := "ApproximateNumberOfMessages"
+ numInProgress := "ApproximateNumberOfMessagesNotVisible"
+ attrs, err := a.sqssvc.GetQueueAttributes(&sqs.GetQueueAttributesInput{
+ AttributeNames: []*string{&numAvailable, &numInProgress},
+ QueueUrl: &url,
+ })
+ if err != nil {
+ return "", "", errors.New(fmt.Sprintf("Failed to get queue attributes: %s", err))
+ }
+ return *attrs.Attributes[numAvailable], *attrs.Attributes[numInProgress], nil
+}
+
func (a *AwsConn) PreQueueId() string {
return a.prequrl
}