Conditions | 6 |
Total Lines | 29 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | package sqs |
||
9 | func (svc *SQS) XIsEmptyQueue(ctx context.Context, queueURL string) (bool, error) { |
||
10 | attrList := []QueueAttributeName{ |
||
11 | QueueAttributeNameApproximateNumberOfMessages, |
||
12 | QueueAttributeNameApproximateNumberOfMessagesDelayed, |
||
13 | QueueAttributeNameApproximateNumberOfMessagesNotVisible, |
||
14 | } |
||
15 | resp, err := svc.GetQueueAttributes(ctx, GetQueueAttributesRequest{ |
||
16 | QueueURL: queueURL, |
||
17 | AttributeNames: attrList, |
||
18 | }) |
||
19 | if err != nil { |
||
20 | return false, err |
||
21 | } |
||
22 | |||
23 | result := resp.Attributes |
||
24 | for _, v := range attrList { |
||
25 | attr, ok := result[string(v)] |
||
26 | if !ok { |
||
27 | return false, nil |
||
28 | } |
||
29 | num, err := strconv.Atoi(attr) |
||
30 | if err != nil { |
||
31 | return false, err |
||
32 | } |
||
33 | if num > 0 { |
||
34 | return false, nil |
||
35 | } |
||
36 | } |
||
37 | return true, nil |
||
38 | } |
||
39 |