(client *awslib.Client, queueURL string)
| 35 | } |
| 36 | |
| 37 | func GetQueueAttributes(client *awslib.Client, queueURL string) (QueueAttributes, error) { |
| 38 | result, err := client.SQS().GetQueueAttributes( |
| 39 | &sqs.GetQueueAttributesInput{ |
| 40 | QueueUrl: aws.String(queueURL), |
| 41 | AttributeNames: aws.StringSlice([]string{"All"}), |
| 42 | }, |
| 43 | ) |
| 44 | if err != nil { |
| 45 | return QueueAttributes{}, errors.WithStack(err) |
| 46 | } |
| 47 | |
| 48 | attributes := aws.StringValueMap(result.Attributes) |
| 49 | |
| 50 | var visibleCount int |
| 51 | var notVisibleCount int |
| 52 | var hasRedrivePolicy bool |
| 53 | if val, found := attributes["ApproximateNumberOfMessages"]; found { |
| 54 | count, ok := s.ParseInt(val) |
| 55 | if ok { |
| 56 | visibleCount = count |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | if val, found := attributes["ApproximateNumberOfMessagesNotVisible"]; found { |
| 61 | count, ok := s.ParseInt(val) |
| 62 | if ok { |
| 63 | notVisibleCount = count |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | _, hasRedrivePolicy = attributes["RedrivePolicy"] |
| 68 | |
| 69 | return QueueAttributes{ |
| 70 | VisibleMessages: visibleCount, |
| 71 | InvisibleMessages: notVisibleCount, |
| 72 | HasRedrivePolicy: hasRedrivePolicy, |
| 73 | }, nil |
| 74 | } |
no test coverage detected