forked from elliotchance/mocksqs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete_message.go
79 lines (62 loc) · 2.39 KB
/
delete_message.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package mocksqs
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/sqs"
)
// DeleteMessage is fully supported.
func (client *SQS) DeleteMessage(input *sqs.DeleteMessageInput) (*sqs.DeleteMessageOutput, error) {
client.httpRequest()
client.Lock()
defer client.Unlock()
return client.deleteMessage(input)
}
func (client *SQS) deleteMessage(input *sqs.DeleteMessageInput) (*sqs.DeleteMessageOutput, error) {
err := checkRequiredFields(map[string]interface{}{
"DeleteMessageInput.QueueUrl": input.QueueUrl,
"DeleteMessageInput.ReceiptHandle": input.ReceiptHandle,
})
if err != nil {
return nil, err
}
if queue := client.GetQueue(*input.QueueUrl); queue != nil {
didDelete := queue.delete(*input.ReceiptHandle)
if !didDelete {
return nil, errorInternal()
}
return nil, nil
}
return nil, errorNonExistentQueue()
}
// DeleteMessageBatch is fully supported.
func (client *SQS) DeleteMessageBatch(input *sqs.DeleteMessageBatchInput) (*sqs.DeleteMessageBatchOutput, error) {
client.httpRequest()
client.Lock()
defer client.Unlock()
for _, message := range input.Entries {
_, err := client.deleteMessage(&sqs.DeleteMessageInput{
QueueUrl: input.QueueUrl,
ReceiptHandle: message.ReceiptHandle,
})
if err != nil {
return nil, err
}
}
return nil, nil
}
// DeleteMessageWithContext is not implemented. It will panic in all cases.
func (client *SQS) DeleteMessageWithContext(aws.Context, *sqs.DeleteMessageInput, ...request.Option) (*sqs.DeleteMessageOutput, error) {
panic("DeleteMessageWithContext is not implemented")
}
// DeleteMessageRequest is not implemented. It will panic in all cases.
func (client *SQS) DeleteMessageRequest(*sqs.DeleteMessageInput) (*request.Request, *sqs.DeleteMessageOutput) {
panic("DeleteMessageRequest is not implemented")
}
// DeleteMessageBatchWithContext is not implemented. It will panic in all cases.
func (client *SQS) DeleteMessageBatchWithContext(aws.Context, *sqs.DeleteMessageBatchInput, ...request.Option) (*sqs.DeleteMessageBatchOutput, error) {
panic("DeleteMessageBatchWithContext is not implemented")
}
// DeleteMessageBatchRequest is not implemented. It will panic in all cases.
func (client *SQS) DeleteMessageBatchRequest(*sqs.DeleteMessageBatchInput) (*request.Request, *sqs.DeleteMessageBatchOutput) {
panic("DeleteMessageBatchRequest is not implemented")
}