From d0adb06565f6eef6970eac69af0430d5fa44f6b9 Mon Sep 17 00:00:00 2001 From: Filip Date: Thu, 16 Mar 2017 13:38:23 +0100 Subject: [PATCH] Automatic consumer recovery + sqs/sns tests --- forwarder/forwarder.go | 5 + rabbitmq/consumer.go | 20 +- sns/forwader.go | 23 +- sns/forwarder_test.go | 79 ++++++ sqs/forwader.go | 21 +- sqs/forwarder_test.go | 79 ++++++ .../service/sns/snsiface/interface.go | 193 +++++++++++++++ .../service/sqs/sqsiface/interface.go | 131 ++++++++++ vendor/vendor.json | 226 ++++++++++++++++++ 9 files changed, 753 insertions(+), 24 deletions(-) create mode 100644 vendor/github.com/aws/aws-sdk-go/service/sns/snsiface/interface.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/sqs/sqsiface/interface.go diff --git a/forwarder/forwarder.go b/forwarder/forwarder.go index a33706a..0588ecc 100644 --- a/forwarder/forwarder.go +++ b/forwarder/forwarder.go @@ -1,5 +1,10 @@ package forwarder +const ( + // EmptyMessageError empty error message + EmptyMessageError = "message is empty" +) + // Client interface to forwarding messages type Client interface { Name() string diff --git a/rabbitmq/consumer.go b/rabbitmq/consumer.go index 012e101..e20fb7f 100644 --- a/rabbitmq/consumer.go +++ b/rabbitmq/consumer.go @@ -103,31 +103,37 @@ func (c Consumer) Start(forwarder forwarder.Client, check chan bool, stop chan b return failOnError(err, "Failed to register a consumer") } params := workerParams{forwarder, msgs, check, stop, conn, ch} - go c.push(params) + go c.startForwarding(¶ms) return nil } -func (c Consumer) push(params workerParams) { +func (c Consumer) startForwarding(params *workerParams) { forwarderName := params.forwarder.Name() + defer params.ch.Close() + defer params.conn.Close() log.Printf("[%s] Started forwarding messages to %s", c.Name(), forwarderName) for { select { - case d := <-params.msgs: + case d, ok := <-params.msgs: + if !ok { // channel already closed + go c.Start(params.forwarder, params.check, params.stop) + return + } log.Printf("[%s] Message to forward: %v", c.Name(), d.MessageId) err := params.forwarder.Push(string(d.Body)) if err != nil { log.Printf("[%s] Could not forward message. Error: %s", forwarderName, err.Error()) } else { - d.Ack(true) + if err := d.Ack(true); err != nil { + log.Println("Could not ack message with id:", d.MessageId) + } } case <-params.check: log.Printf("[%s] Checking", forwarderName) case <-params.stop: log.Printf("[%s] Closing", forwarderName) - params.ch.Close() - params.conn.Close() - return + break } } } diff --git a/sns/forwader.go b/sns/forwader.go index 349936a..7c9b042 100644 --- a/sns/forwader.go +++ b/sns/forwader.go @@ -1,6 +1,7 @@ package sns import ( + "errors" "log" "github.com/AirHelp/rabbit-amazon-forwarder/config" @@ -8,6 +9,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sns" + "github.com/aws/aws-sdk-go/service/sns/snsiface" ) const ( @@ -16,13 +18,18 @@ const ( type Forwarder struct { name string - snsClient *sns.SNS + snsClient snsiface.SNSAPI topic string } // CreateForwarder creates instance of forwarder -func CreateForwarder(entry config.AmazonEntry) forwarder.Client { - client := awsClient() +func CreateForwarder(entry config.AmazonEntry, snsClient ...snsiface.SNSAPI) forwarder.Client { + var client snsiface.SNSAPI + if len(snsClient) > 0 { + client = snsClient[0] + } else { + client = sns.New(session.Must(session.NewSession())) + } forwarder := Forwarder{entry.Name, client, entry.Target} log.Print("Created forwarder: ", forwarder.Name()) return forwarder @@ -35,6 +42,9 @@ func (f Forwarder) Name() string { // Push pushes message to forwarding infrastructure func (f Forwarder) Push(message string) error { + if message == "" { + return errors.New(forwarder.EmptyMessageError) + } params := &sns.PublishInput{ Message: aws.String(message), TargetArn: aws.String(f.topic), @@ -45,11 +55,6 @@ func (f Forwarder) Push(message string) error { log.Printf("[%s] Could not forward message. Error: %s", f.Name(), err.Error()) return err } - log.Printf("[%s] Forward succeeded. Response: %s", f.Name(), resp) + log.Printf("[%s] Forward succeeded. Response: %v", f.Name(), resp) return nil } - -func awsClient() *sns.SNS { - sess := session.New() - return sns.New(sess) -} diff --git a/sns/forwarder_test.go b/sns/forwarder_test.go index 3504d0d..89299dc 100644 --- a/sns/forwarder_test.go +++ b/sns/forwarder_test.go @@ -1,11 +1,18 @@ package sns import ( + "errors" "testing" "github.com/AirHelp/rabbit-amazon-forwarder/config" + "github.com/AirHelp/rabbit-amazon-forwarder/forwarder" + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/sns" + "github.com/aws/aws-sdk-go/service/sns/snsiface" ) +var badRequest = "Bad request" + func TestCreateForwarder(t *testing.T) { entry := config.AmazonEntry{Type: "SNS", Name: "sns-test", @@ -16,3 +23,75 @@ func TestCreateForwarder(t *testing.T) { t.Errorf("wrong forwarder name, expected:%s, found: %s", entry.Name, forwarder.Name()) } } + +func TestPush(t *testing.T) { + topicName := "topic1" + entry := config.AmazonEntry{Type: "SNS", + Name: "sns-test", + Target: topicName, + } + scenarios := []struct { + name string + mock snsiface.SNSAPI + message string + topic string + err error + }{ + { + name: "empty message", + mock: mockAmazonSNS{resp: sns.PublishOutput{MessageId: aws.String("messageId")}, topic: topicName, message: ""}, + message: "", + topic: topicName, + err: errors.New(forwarder.EmptyMessageError), + }, + { + name: "bad request", + mock: mockAmazonSNS{resp: sns.PublishOutput{MessageId: aws.String("messageId")}, topic: topicName, message: badRequest}, + message: badRequest, + topic: topicName, + err: errors.New(badRequest), + }, + { + name: "success", + mock: mockAmazonSNS{resp: sns.PublishOutput{MessageId: aws.String("messageId")}, topic: topicName, message: "abc"}, + message: "abc", + topic: topicName, + err: nil, + }, + } + for _, scenario := range scenarios { + t.Log("Scenario name: ", scenario.name) + forwarder := CreateForwarder(entry, scenario.mock) + err := forwarder.Push(scenario.message) + if scenario.err == nil && err != nil { + t.Errorf("Error should not occur") + return + } + if scenario.err == err { + return + } + if err.Error() != scenario.err.Error() { + t.Errorf("Wrong error, expecting:%v, got:%v", scenario.err, err) + } + } +} + +type mockAmazonSNS struct { + snsiface.SNSAPI + resp sns.PublishOutput + topic string + message string +} + +func (m mockAmazonSNS) Publish(input *sns.PublishInput) (*sns.PublishOutput, error) { + if *input.TargetArn != m.topic { + return nil, errors.New("Wrong topic name") + } + if *input.Message != m.message { + return nil, errors.New("Wrong message body") + } + if *input.Message == badRequest { + return nil, errors.New(badRequest) + } + return &m.resp, nil +} diff --git a/sqs/forwader.go b/sqs/forwader.go index 93fd0e1..112963e 100644 --- a/sqs/forwader.go +++ b/sqs/forwader.go @@ -1,6 +1,7 @@ package sqs import ( + "errors" "log" "github.com/AirHelp/rabbit-amazon-forwarder/config" @@ -8,6 +9,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go/service/sqs/sqsiface" ) const ( @@ -16,13 +18,18 @@ const ( type Forwarder struct { name string - sqsClient *sqs.SQS + sqsClient sqsiface.SQSAPI queue string } // CreateForwarder creates instance of forwarder -func CreateForwarder(entry config.AmazonEntry) forwarder.Client { - client := awsClient() +func CreateForwarder(entry config.AmazonEntry, sqsClient ...sqsiface.SQSAPI) forwarder.Client { + var client sqsiface.SQSAPI + if len(sqsClient) > 0 { + client = sqsClient[0] + } else { + client = sqs.New(session.Must(session.NewSession())) + } forwarder := Forwarder{entry.Name, client, entry.Target} log.Print("Created forwarder: ", forwarder.Name()) return forwarder @@ -35,6 +42,9 @@ func (f Forwarder) Name() string { // Push pushes message to forwarding infrastructure func (f Forwarder) Push(message string) error { + if message == "" { + return errors.New(forwarder.EmptyMessageError) + } params := &sqs.SendMessageInput{ MessageBody: aws.String(message), // Required QueueUrl: aws.String(f.queue), // Required @@ -49,8 +59,3 @@ func (f Forwarder) Push(message string) error { log.Printf("[%s] Forward succeeded. Response: %s", f.Name(), resp) return nil } - -func awsClient() *sqs.SQS { - sess := session.New() - return sqs.New(sess) -} diff --git a/sqs/forwarder_test.go b/sqs/forwarder_test.go index b564aec..ef2ea21 100644 --- a/sqs/forwarder_test.go +++ b/sqs/forwarder_test.go @@ -1,11 +1,18 @@ package sqs import ( + "errors" "testing" "github.com/AirHelp/rabbit-amazon-forwarder/config" + "github.com/AirHelp/rabbit-amazon-forwarder/forwarder" + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/sqs" + "github.com/aws/aws-sdk-go/service/sqs/sqsiface" ) +var badRequest = "Bad request" + func TestCreateForwarder(t *testing.T) { entry := config.AmazonEntry{Type: "SQS", Name: "sqs-test", @@ -16,3 +23,75 @@ func TestCreateForwarder(t *testing.T) { t.Errorf("wrong forwarder name, expected:%s, found: %s", entry.Name, forwarder.Name()) } } + +func TestPush(t *testing.T) { + queueName := "queue1" + entry := config.AmazonEntry{Type: "SQS", + Name: "sqs-test", + Target: queueName, + } + scenarios := []struct { + name string + mock sqsiface.SQSAPI + message string + queue string + err error + }{ + { + name: "empty message", + mock: mockAmazonSQS{resp: sqs.SendMessageOutput{MessageId: aws.String("messageId")}, queue: queueName, message: ""}, + message: "", + queue: queueName, + err: errors.New(forwarder.EmptyMessageError), + }, + { + name: "bad request", + mock: mockAmazonSQS{resp: sqs.SendMessageOutput{MessageId: aws.String("messageId")}, queue: queueName, message: badRequest}, + message: badRequest, + queue: queueName, + err: errors.New(badRequest), + }, + { + name: "success", + mock: mockAmazonSQS{resp: sqs.SendMessageOutput{MessageId: aws.String("messageId")}, queue: queueName, message: "abc"}, + message: "abc", + queue: queueName, + err: nil, + }, + } + for _, scenario := range scenarios { + t.Log("Scenario name: ", scenario.name) + forwarder := CreateForwarder(entry, scenario.mock) + err := forwarder.Push(scenario.message) + if scenario.err == nil && err != nil { + t.Errorf("Error should not occur") + return + } + if scenario.err == err { + return + } + if err.Error() != scenario.err.Error() { + t.Errorf("Wrong error, expecting:%v, got:%v", scenario.err, err) + } + } +} + +type mockAmazonSQS struct { + sqsiface.SQSAPI + resp sqs.SendMessageOutput + queue string + message string +} + +func (m mockAmazonSQS) SendMessage(input *sqs.SendMessageInput) (*sqs.SendMessageOutput, error) { + if *input.QueueUrl != m.queue { + return nil, errors.New("Wrong queue name") + } + if *input.MessageBody != m.message { + return nil, errors.New("Wrong message body") + } + if *input.MessageBody == badRequest { + return nil, errors.New(badRequest) + } + return &m.resp, nil +} diff --git a/vendor/github.com/aws/aws-sdk-go/service/sns/snsiface/interface.go b/vendor/github.com/aws/aws-sdk-go/service/sns/snsiface/interface.go new file mode 100644 index 0000000..4dd9a5e --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/sns/snsiface/interface.go @@ -0,0 +1,193 @@ +// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. + +// Package snsiface provides an interface to enable mocking the Amazon Simple Notification Service service client +// for testing your code. +// +// It is important to note that this interface will have breaking changes +// when the service model is updated and adds new API operations, paginators, +// and waiters. +package snsiface + +import ( + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/service/sns" +) + +// SNSAPI provides an interface to enable mocking the +// sns.SNS service client's API operation, +// paginators, and waiters. This make unit testing your code that calls out +// to the SDK's service client's calls easier. +// +// The best way to use this interface is so the SDK's service client's calls +// can be stubbed out for unit testing your code with the SDK without needing +// to inject custom request handlers into the the SDK's request pipeline. +// +// // myFunc uses an SDK service client to make a request to +// // Amazon Simple Notification Service. +// func myFunc(svc snsiface.SNSAPI) bool { +// // Make svc.AddPermission request +// } +// +// func main() { +// sess := session.New() +// svc := sns.New(sess) +// +// myFunc(svc) +// } +// +// In your _test.go file: +// +// // Define a mock struct to be used in your unit tests of myFunc. +// type mockSNSClient struct { +// snsiface.SNSAPI +// } +// func (m *mockSNSClient) AddPermission(input *sns.AddPermissionInput) (*sns.AddPermissionOutput, error) { +// // mock response/functionality +// } +// +// func TestMyFunc(t *testing.T) { +// // Setup Test +// mockSvc := &mockSNSClient{} +// +// myfunc(mockSvc) +// +// // Verify myFunc's functionality +// } +// +// It is important to note that this interface will have breaking changes +// when the service model is updated and adds new API operations, paginators, +// and waiters. Its suggested to use the pattern above for testing, or using +// tooling to generate mocks to satisfy the interfaces. +type SNSAPI interface { + AddPermissionRequest(*sns.AddPermissionInput) (*request.Request, *sns.AddPermissionOutput) + + AddPermission(*sns.AddPermissionInput) (*sns.AddPermissionOutput, error) + + CheckIfPhoneNumberIsOptedOutRequest(*sns.CheckIfPhoneNumberIsOptedOutInput) (*request.Request, *sns.CheckIfPhoneNumberIsOptedOutOutput) + + CheckIfPhoneNumberIsOptedOut(*sns.CheckIfPhoneNumberIsOptedOutInput) (*sns.CheckIfPhoneNumberIsOptedOutOutput, error) + + ConfirmSubscriptionRequest(*sns.ConfirmSubscriptionInput) (*request.Request, *sns.ConfirmSubscriptionOutput) + + ConfirmSubscription(*sns.ConfirmSubscriptionInput) (*sns.ConfirmSubscriptionOutput, error) + + CreatePlatformApplicationRequest(*sns.CreatePlatformApplicationInput) (*request.Request, *sns.CreatePlatformApplicationOutput) + + CreatePlatformApplication(*sns.CreatePlatformApplicationInput) (*sns.CreatePlatformApplicationOutput, error) + + CreatePlatformEndpointRequest(*sns.CreatePlatformEndpointInput) (*request.Request, *sns.CreatePlatformEndpointOutput) + + CreatePlatformEndpoint(*sns.CreatePlatformEndpointInput) (*sns.CreatePlatformEndpointOutput, error) + + CreateTopicRequest(*sns.CreateTopicInput) (*request.Request, *sns.CreateTopicOutput) + + CreateTopic(*sns.CreateTopicInput) (*sns.CreateTopicOutput, error) + + DeleteEndpointRequest(*sns.DeleteEndpointInput) (*request.Request, *sns.DeleteEndpointOutput) + + DeleteEndpoint(*sns.DeleteEndpointInput) (*sns.DeleteEndpointOutput, error) + + DeletePlatformApplicationRequest(*sns.DeletePlatformApplicationInput) (*request.Request, *sns.DeletePlatformApplicationOutput) + + DeletePlatformApplication(*sns.DeletePlatformApplicationInput) (*sns.DeletePlatformApplicationOutput, error) + + DeleteTopicRequest(*sns.DeleteTopicInput) (*request.Request, *sns.DeleteTopicOutput) + + DeleteTopic(*sns.DeleteTopicInput) (*sns.DeleteTopicOutput, error) + + GetEndpointAttributesRequest(*sns.GetEndpointAttributesInput) (*request.Request, *sns.GetEndpointAttributesOutput) + + GetEndpointAttributes(*sns.GetEndpointAttributesInput) (*sns.GetEndpointAttributesOutput, error) + + GetPlatformApplicationAttributesRequest(*sns.GetPlatformApplicationAttributesInput) (*request.Request, *sns.GetPlatformApplicationAttributesOutput) + + GetPlatformApplicationAttributes(*sns.GetPlatformApplicationAttributesInput) (*sns.GetPlatformApplicationAttributesOutput, error) + + GetSMSAttributesRequest(*sns.GetSMSAttributesInput) (*request.Request, *sns.GetSMSAttributesOutput) + + GetSMSAttributes(*sns.GetSMSAttributesInput) (*sns.GetSMSAttributesOutput, error) + + GetSubscriptionAttributesRequest(*sns.GetSubscriptionAttributesInput) (*request.Request, *sns.GetSubscriptionAttributesOutput) + + GetSubscriptionAttributes(*sns.GetSubscriptionAttributesInput) (*sns.GetSubscriptionAttributesOutput, error) + + GetTopicAttributesRequest(*sns.GetTopicAttributesInput) (*request.Request, *sns.GetTopicAttributesOutput) + + GetTopicAttributes(*sns.GetTopicAttributesInput) (*sns.GetTopicAttributesOutput, error) + + ListEndpointsByPlatformApplicationRequest(*sns.ListEndpointsByPlatformApplicationInput) (*request.Request, *sns.ListEndpointsByPlatformApplicationOutput) + + ListEndpointsByPlatformApplication(*sns.ListEndpointsByPlatformApplicationInput) (*sns.ListEndpointsByPlatformApplicationOutput, error) + + ListEndpointsByPlatformApplicationPages(*sns.ListEndpointsByPlatformApplicationInput, func(*sns.ListEndpointsByPlatformApplicationOutput, bool) bool) error + + ListPhoneNumbersOptedOutRequest(*sns.ListPhoneNumbersOptedOutInput) (*request.Request, *sns.ListPhoneNumbersOptedOutOutput) + + ListPhoneNumbersOptedOut(*sns.ListPhoneNumbersOptedOutInput) (*sns.ListPhoneNumbersOptedOutOutput, error) + + ListPlatformApplicationsRequest(*sns.ListPlatformApplicationsInput) (*request.Request, *sns.ListPlatformApplicationsOutput) + + ListPlatformApplications(*sns.ListPlatformApplicationsInput) (*sns.ListPlatformApplicationsOutput, error) + + ListPlatformApplicationsPages(*sns.ListPlatformApplicationsInput, func(*sns.ListPlatformApplicationsOutput, bool) bool) error + + ListSubscriptionsRequest(*sns.ListSubscriptionsInput) (*request.Request, *sns.ListSubscriptionsOutput) + + ListSubscriptions(*sns.ListSubscriptionsInput) (*sns.ListSubscriptionsOutput, error) + + ListSubscriptionsPages(*sns.ListSubscriptionsInput, func(*sns.ListSubscriptionsOutput, bool) bool) error + + ListSubscriptionsByTopicRequest(*sns.ListSubscriptionsByTopicInput) (*request.Request, *sns.ListSubscriptionsByTopicOutput) + + ListSubscriptionsByTopic(*sns.ListSubscriptionsByTopicInput) (*sns.ListSubscriptionsByTopicOutput, error) + + ListSubscriptionsByTopicPages(*sns.ListSubscriptionsByTopicInput, func(*sns.ListSubscriptionsByTopicOutput, bool) bool) error + + ListTopicsRequest(*sns.ListTopicsInput) (*request.Request, *sns.ListTopicsOutput) + + ListTopics(*sns.ListTopicsInput) (*sns.ListTopicsOutput, error) + + ListTopicsPages(*sns.ListTopicsInput, func(*sns.ListTopicsOutput, bool) bool) error + + OptInPhoneNumberRequest(*sns.OptInPhoneNumberInput) (*request.Request, *sns.OptInPhoneNumberOutput) + + OptInPhoneNumber(*sns.OptInPhoneNumberInput) (*sns.OptInPhoneNumberOutput, error) + + PublishRequest(*sns.PublishInput) (*request.Request, *sns.PublishOutput) + + Publish(*sns.PublishInput) (*sns.PublishOutput, error) + + RemovePermissionRequest(*sns.RemovePermissionInput) (*request.Request, *sns.RemovePermissionOutput) + + RemovePermission(*sns.RemovePermissionInput) (*sns.RemovePermissionOutput, error) + + SetEndpointAttributesRequest(*sns.SetEndpointAttributesInput) (*request.Request, *sns.SetEndpointAttributesOutput) + + SetEndpointAttributes(*sns.SetEndpointAttributesInput) (*sns.SetEndpointAttributesOutput, error) + + SetPlatformApplicationAttributesRequest(*sns.SetPlatformApplicationAttributesInput) (*request.Request, *sns.SetPlatformApplicationAttributesOutput) + + SetPlatformApplicationAttributes(*sns.SetPlatformApplicationAttributesInput) (*sns.SetPlatformApplicationAttributesOutput, error) + + SetSMSAttributesRequest(*sns.SetSMSAttributesInput) (*request.Request, *sns.SetSMSAttributesOutput) + + SetSMSAttributes(*sns.SetSMSAttributesInput) (*sns.SetSMSAttributesOutput, error) + + SetSubscriptionAttributesRequest(*sns.SetSubscriptionAttributesInput) (*request.Request, *sns.SetSubscriptionAttributesOutput) + + SetSubscriptionAttributes(*sns.SetSubscriptionAttributesInput) (*sns.SetSubscriptionAttributesOutput, error) + + SetTopicAttributesRequest(*sns.SetTopicAttributesInput) (*request.Request, *sns.SetTopicAttributesOutput) + + SetTopicAttributes(*sns.SetTopicAttributesInput) (*sns.SetTopicAttributesOutput, error) + + SubscribeRequest(*sns.SubscribeInput) (*request.Request, *sns.SubscribeOutput) + + Subscribe(*sns.SubscribeInput) (*sns.SubscribeOutput, error) + + UnsubscribeRequest(*sns.UnsubscribeInput) (*request.Request, *sns.UnsubscribeOutput) + + Unsubscribe(*sns.UnsubscribeInput) (*sns.UnsubscribeOutput, error) +} + +var _ SNSAPI = (*sns.SNS)(nil) diff --git a/vendor/github.com/aws/aws-sdk-go/service/sqs/sqsiface/interface.go b/vendor/github.com/aws/aws-sdk-go/service/sqs/sqsiface/interface.go new file mode 100644 index 0000000..7f81759 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/sqs/sqsiface/interface.go @@ -0,0 +1,131 @@ +// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. + +// Package sqsiface provides an interface to enable mocking the Amazon Simple Queue Service service client +// for testing your code. +// +// It is important to note that this interface will have breaking changes +// when the service model is updated and adds new API operations, paginators, +// and waiters. +package sqsiface + +import ( + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/service/sqs" +) + +// SQSAPI provides an interface to enable mocking the +// sqs.SQS service client's API operation, +// paginators, and waiters. This make unit testing your code that calls out +// to the SDK's service client's calls easier. +// +// The best way to use this interface is so the SDK's service client's calls +// can be stubbed out for unit testing your code with the SDK without needing +// to inject custom request handlers into the the SDK's request pipeline. +// +// // myFunc uses an SDK service client to make a request to +// // Amazon Simple Queue Service. +// func myFunc(svc sqsiface.SQSAPI) bool { +// // Make svc.AddPermission request +// } +// +// func main() { +// sess := session.New() +// svc := sqs.New(sess) +// +// myFunc(svc) +// } +// +// In your _test.go file: +// +// // Define a mock struct to be used in your unit tests of myFunc. +// type mockSQSClient struct { +// sqsiface.SQSAPI +// } +// func (m *mockSQSClient) AddPermission(input *sqs.AddPermissionInput) (*sqs.AddPermissionOutput, error) { +// // mock response/functionality +// } +// +// func TestMyFunc(t *testing.T) { +// // Setup Test +// mockSvc := &mockSQSClient{} +// +// myfunc(mockSvc) +// +// // Verify myFunc's functionality +// } +// +// It is important to note that this interface will have breaking changes +// when the service model is updated and adds new API operations, paginators, +// and waiters. Its suggested to use the pattern above for testing, or using +// tooling to generate mocks to satisfy the interfaces. +type SQSAPI interface { + AddPermissionRequest(*sqs.AddPermissionInput) (*request.Request, *sqs.AddPermissionOutput) + + AddPermission(*sqs.AddPermissionInput) (*sqs.AddPermissionOutput, error) + + ChangeMessageVisibilityRequest(*sqs.ChangeMessageVisibilityInput) (*request.Request, *sqs.ChangeMessageVisibilityOutput) + + ChangeMessageVisibility(*sqs.ChangeMessageVisibilityInput) (*sqs.ChangeMessageVisibilityOutput, error) + + ChangeMessageVisibilityBatchRequest(*sqs.ChangeMessageVisibilityBatchInput) (*request.Request, *sqs.ChangeMessageVisibilityBatchOutput) + + ChangeMessageVisibilityBatch(*sqs.ChangeMessageVisibilityBatchInput) (*sqs.ChangeMessageVisibilityBatchOutput, error) + + CreateQueueRequest(*sqs.CreateQueueInput) (*request.Request, *sqs.CreateQueueOutput) + + CreateQueue(*sqs.CreateQueueInput) (*sqs.CreateQueueOutput, error) + + DeleteMessageRequest(*sqs.DeleteMessageInput) (*request.Request, *sqs.DeleteMessageOutput) + + DeleteMessage(*sqs.DeleteMessageInput) (*sqs.DeleteMessageOutput, error) + + DeleteMessageBatchRequest(*sqs.DeleteMessageBatchInput) (*request.Request, *sqs.DeleteMessageBatchOutput) + + DeleteMessageBatch(*sqs.DeleteMessageBatchInput) (*sqs.DeleteMessageBatchOutput, error) + + DeleteQueueRequest(*sqs.DeleteQueueInput) (*request.Request, *sqs.DeleteQueueOutput) + + DeleteQueue(*sqs.DeleteQueueInput) (*sqs.DeleteQueueOutput, error) + + GetQueueAttributesRequest(*sqs.GetQueueAttributesInput) (*request.Request, *sqs.GetQueueAttributesOutput) + + GetQueueAttributes(*sqs.GetQueueAttributesInput) (*sqs.GetQueueAttributesOutput, error) + + GetQueueUrlRequest(*sqs.GetQueueUrlInput) (*request.Request, *sqs.GetQueueUrlOutput) + + GetQueueUrl(*sqs.GetQueueUrlInput) (*sqs.GetQueueUrlOutput, error) + + ListDeadLetterSourceQueuesRequest(*sqs.ListDeadLetterSourceQueuesInput) (*request.Request, *sqs.ListDeadLetterSourceQueuesOutput) + + ListDeadLetterSourceQueues(*sqs.ListDeadLetterSourceQueuesInput) (*sqs.ListDeadLetterSourceQueuesOutput, error) + + ListQueuesRequest(*sqs.ListQueuesInput) (*request.Request, *sqs.ListQueuesOutput) + + ListQueues(*sqs.ListQueuesInput) (*sqs.ListQueuesOutput, error) + + PurgeQueueRequest(*sqs.PurgeQueueInput) (*request.Request, *sqs.PurgeQueueOutput) + + PurgeQueue(*sqs.PurgeQueueInput) (*sqs.PurgeQueueOutput, error) + + ReceiveMessageRequest(*sqs.ReceiveMessageInput) (*request.Request, *sqs.ReceiveMessageOutput) + + ReceiveMessage(*sqs.ReceiveMessageInput) (*sqs.ReceiveMessageOutput, error) + + RemovePermissionRequest(*sqs.RemovePermissionInput) (*request.Request, *sqs.RemovePermissionOutput) + + RemovePermission(*sqs.RemovePermissionInput) (*sqs.RemovePermissionOutput, error) + + SendMessageRequest(*sqs.SendMessageInput) (*request.Request, *sqs.SendMessageOutput) + + SendMessage(*sqs.SendMessageInput) (*sqs.SendMessageOutput, error) + + SendMessageBatchRequest(*sqs.SendMessageBatchInput) (*request.Request, *sqs.SendMessageBatchOutput) + + SendMessageBatch(*sqs.SendMessageBatchInput) (*sqs.SendMessageBatchOutput, error) + + SetQueueAttributesRequest(*sqs.SetQueueAttributesInput) (*request.Request, *sqs.SetQueueAttributesOutput) + + SetQueueAttributes(*sqs.SetQueueAttributesInput) (*sqs.SetQueueAttributesOutput, error) +} + +var _ SQSAPI = (*sqs.SQS)(nil) diff --git a/vendor/vendor.json b/vendor/vendor.json index 83cbc8e..ca69163 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -2,6 +2,20 @@ "comment": "", "ignore": "test", "package": [ + { + "checksumSHA1": "zTn0jzjOiJlScR1px66MvrgrlLs=", + "origin": "github.com/docker/docker/vendor/github.com/Microsoft/go-winio", + "path": "github.com/Microsoft/go-winio", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "CujWu7+PWlZSX5+zAPJH91O5AVQ=", + "origin": "github.com/docker/docker/vendor/github.com/Sirupsen/logrus", + "path": "github.com/Sirupsen/logrus", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, { "checksumSHA1": "4zezAqthIhk7nrCi0RyZGLonH7M=", "path": "github.com/aws/aws-sdk-go/aws", @@ -134,18 +148,174 @@ "revision": "9a535c358fe58f8541d2edaaddce7ce50b3be7b6", "revisionTime": "2017-01-25T00:04:14Z" }, + { + "checksumSHA1": "GU4gaFfRhP11JMQK2QTTdYlgTew=", + "path": "github.com/aws/aws-sdk-go/service/sns/snsiface", + "revision": "62c16d8bf2fd6ee59f2bf11ae8268d045470ccf6", + "revisionTime": "2017-03-14T21:47:04Z" + }, { "checksumSHA1": "lUgSCELfdGC5p5ttveXgA40rmG0=", "path": "github.com/aws/aws-sdk-go/service/sqs", "revision": "9a535c358fe58f8541d2edaaddce7ce50b3be7b6", "revisionTime": "2017-01-25T00:04:14Z" }, + { + "checksumSHA1": "fvSayw4T/rRcmGjJGiep/8wJxis=", + "path": "github.com/aws/aws-sdk-go/service/sqs/sqsiface", + "revision": "62c16d8bf2fd6ee59f2bf11ae8268d045470ccf6", + "revisionTime": "2017-03-14T21:47:04Z" + }, { "checksumSHA1": "mTYnOiyBDqdeG6pBQi8FRbHO7Qg=", "path": "github.com/aws/aws-sdk-go/service/sts", "revision": "9a535c358fe58f8541d2edaaddce7ce50b3be7b6", "revisionTime": "2017-01-25T00:04:14Z" }, + { + "checksumSHA1": "Gj+xR1VgFKKmFXYOJMnAczC3Znk=", + "origin": "github.com/docker/docker/vendor/github.com/docker/distribution/digestset", + "path": "github.com/docker/distribution/digestset", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "FqADPtHUqEtmfC7Zf+0pI++Kb6g=", + "origin": "github.com/docker/docker/vendor/github.com/docker/distribution/reference", + "path": "github.com/docker/distribution/reference", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "ltUuB4vWwR0AxLyhvDWVWxgpKeQ=", + "path": "github.com/docker/docker/api/types", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "jVJDbe0IcyjoKc2xbohwzQr+FF0=", + "path": "github.com/docker/docker/api/types/blkiodev", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "B23tvnZvtvecfB7hCuE87+kApH0=", + "path": "github.com/docker/docker/api/types/container", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "fzeGodcTcWuV18AT0BcvB4EFByo=", + "path": "github.com/docker/docker/api/types/events", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "J2OKngfI3vgswudr9PZVUFcRRu0=", + "path": "github.com/docker/docker/api/types/filters", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "yeB781yxPhnN6OXQ9/qSsyih3ek=", + "path": "github.com/docker/docker/api/types/image", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "OXsrx4ynzLV+6/6vUeyru0Fprx8=", + "path": "github.com/docker/docker/api/types/mount", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "iwcPDgKRZRLixxX9PgGvWqbufsA=", + "path": "github.com/docker/docker/api/types/network", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "BHWRYLuNJly1Asgi2s/OQiS+LJU=", + "path": "github.com/docker/docker/api/types/reference", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "93qfc2M61FdF62qeGXZHWpVSK8k=", + "path": "github.com/docker/docker/api/types/registry", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "VTxWyFud/RedrpllGdQonVtGM/A=", + "path": "github.com/docker/docker/api/types/strslice", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "TX5chfz1oyHM+M4K/rCeHZffi4k=", + "path": "github.com/docker/docker/api/types/swarm", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "B7ZwKzrv3t3Vlox6/bYMHhMjsM8=", + "path": "github.com/docker/docker/api/types/time", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "uDPQ3nHsrvGQc9tg/J9OSC4N5dQ=", + "path": "github.com/docker/docker/api/types/versions", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "IBJy2zPEnYmcFJ3lM1eiRWnCxTA=", + "path": "github.com/docker/docker/api/types/volume", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "R9msQoTKd7c/hBYJDGP4oAm6S0g=", + "path": "github.com/docker/docker/client", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "8I0Ez+aUYGpsDEVZ8wN/Ztf6Zqs=", + "path": "github.com/docker/docker/pkg/tlsconfig", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "JbiWTzH699Sqz25XmDlsARpMN9w=", + "origin": "github.com/docker/docker/vendor/github.com/docker/go-connections/nat", + "path": "github.com/docker/go-connections/nat", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "CqKNaYjt0gZAi8utdsZSTKTV30g=", + "origin": "github.com/docker/docker/vendor/github.com/docker/go-connections/sockets", + "path": "github.com/docker/go-connections/sockets", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "DYKVPp+oYtFl91zBUk0o45CQw7Q=", + "origin": "github.com/docker/docker/vendor/github.com/docker/go-connections/tlsconfig", + "path": "github.com/docker/go-connections/tlsconfig", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "HfZvz2wBnLkwXJ5RbqC9Xw/EASY=", + "origin": "github.com/docker/docker/vendor/github.com/docker/go-units", + "path": "github.com/docker/go-units", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, { "checksumSHA1": "FCeEm2BWZV/n4oTy+SGd/k0Ab5c=", "origin": "github.com/aws/aws-sdk-go/vendor/github.com/go-ini/ini", @@ -160,11 +330,67 @@ "revision": "9a535c358fe58f8541d2edaaddce7ce50b3be7b6", "revisionTime": "2017-01-25T00:04:14Z" }, + { + "checksumSHA1": "6qI8HIHUPhGyRyxhe3Ds6N1pgUo=", + "origin": "github.com/docker/docker/vendor/github.com/opencontainers/go-digest", + "path": "github.com/opencontainers/go-digest", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "7tZiMvVKwDTtqedmi6VGVhB07A4=", + "origin": "github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/user", + "path": "github.com/opencontainers/runc/libcontainer/user", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "cozq4/7ioFamHmCA2IfgA1c+5Gc=", + "origin": "github.com/docker/docker/vendor/github.com/pkg/errors", + "path": "github.com/pkg/errors", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, { "checksumSHA1": "PNFiPbDwLwZs7CcqH91LH7gXI5U=", "path": "github.com/streadway/amqp", "revision": "d75c3a341ff43309ad0cb69ac8bdbd1d8772775f", "revisionTime": "2017-02-03T13:40:38Z" + }, + { + "checksumSHA1": "9QKY4bQlbQ/VZZFP8/1WtH4b0mA=", + "origin": "github.com/docker/docker/vendor/golang.org/x/net/context", + "path": "golang.org/x/net/context", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "EJMLw8rk55bsqmIpSMtVORJpSGo=", + "origin": "github.com/docker/docker/vendor/golang.org/x/net/context/ctxhttp", + "path": "golang.org/x/net/context/ctxhttp", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "LvdVRE0FqdR68SvVpRkHs1rxhcA=", + "origin": "github.com/docker/docker/vendor/golang.org/x/net/proxy", + "path": "golang.org/x/net/proxy", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "ENl6I8+3AaBanbn9CVExMjDTHPc=", + "origin": "github.com/docker/docker/vendor/golang.org/x/sys/unix", + "path": "golang.org/x/sys/unix", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" + }, + { + "checksumSHA1": "fpW2dhGFC6SrVzipJx7fjg2DIH8=", + "origin": "github.com/docker/docker/vendor/golang.org/x/sys/windows", + "path": "golang.org/x/sys/windows", + "revision": "8f8c4f20e39def31be57feb8913c676d49c96b47", + "revisionTime": "2017-02-01T08:52:55Z" } ], "rootPath": "github.com/AirHelp/rabbit-amazon-forwarder"