MCPcopy Index your code
hub / github.com/cortexlabs/cortex / GetQueueAttributes

Function GetQueueAttributes

pkg/dequeuer/queue_attributes.go:37–74  ·  view source on GitHub ↗
(client *awslib.Client, queueURL string)

Source from the content-addressed store, hash-verified

35}
36
37func 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}

Callers 3

onJobCompleteMethod · 0.85
NewSQSDequeuerFunction · 0.85
workerMethod · 0.85

Calls 3

WithStackFunction · 0.92
SQSMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected