service.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package sqs
  3. import (
  4. "github.com/aws/aws-sdk-go/aws"
  5. "github.com/aws/aws-sdk-go/aws/client"
  6. "github.com/aws/aws-sdk-go/aws/client/metadata"
  7. "github.com/aws/aws-sdk-go/aws/request"
  8. "github.com/aws/aws-sdk-go/aws/signer/v4"
  9. "github.com/aws/aws-sdk-go/private/protocol/query"
  10. )
  11. // Welcome to the Amazon Simple Queue Service API Reference. This section describes
  12. // who should read this guide, how the guide is organized, and other resources
  13. // related to the Amazon Simple Queue Service (Amazon SQS).
  14. //
  15. // Amazon SQS offers reliable and scalable hosted queues for storing messages
  16. // as they travel between computers. By using Amazon SQS, you can move data
  17. // between distributed components of your applications that perform different
  18. // tasks without losing messages or requiring each component to be always available.
  19. //
  20. // Helpful Links:
  21. //
  22. // * Current WSDL (2012-11-05) (http://queue.amazonaws.com/doc/2012-11-05/QueueService.wsdl)
  23. //
  24. // * Making API Requests (http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/MakingRequestsArticle.html)
  25. //
  26. // * Amazon SQS product page (http://aws.amazon.com/sqs/)
  27. //
  28. // * Using Amazon SQS Message Attributes (http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/SQSMessageAttributes.html)
  29. //
  30. // * Using Amazon SQS Dead Letter Queues (http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/SQSDeadLetterQueue.html)
  31. //
  32. // * Regions and Endpoints (http://docs.aws.amazon.com/general/latest/gr/rande.html#sqs_region)
  33. //
  34. // We also provide SDKs that enable you to access Amazon SQS from your preferred
  35. // programming language. The SDKs contain functionality that automatically takes
  36. // care of tasks such as:
  37. //
  38. // * Cryptographically signing your service requests
  39. //
  40. // * Retrying requests
  41. //
  42. // * Handling error responses
  43. //
  44. // For a list of available SDKs, go to Tools for Amazon Web Services (http://aws.amazon.com/tools/).
  45. //The service client's operations are safe to be used concurrently.
  46. // It is not safe to mutate any of the client's properties though.
  47. type SQS struct {
  48. *client.Client
  49. }
  50. // Used for custom client initialization logic
  51. var initClient func(*client.Client)
  52. // Used for custom request initialization logic
  53. var initRequest func(*request.Request)
  54. // A ServiceName is the name of the service the client will make API calls to.
  55. const ServiceName = "sqs"
  56. // New creates a new instance of the SQS client with a session.
  57. // If additional configuration is needed for the client instance use the optional
  58. // aws.Config parameter to add your extra config.
  59. //
  60. // Example:
  61. // // Create a SQS client from just a session.
  62. // svc := sqs.New(mySession)
  63. //
  64. // // Create a SQS client with additional configuration
  65. // svc := sqs.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  66. func New(p client.ConfigProvider, cfgs ...*aws.Config) *SQS {
  67. c := p.ClientConfig(ServiceName, cfgs...)
  68. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  69. }
  70. // newClient creates, initializes and returns a new service client instance.
  71. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *SQS {
  72. svc := &SQS{
  73. Client: client.New(
  74. cfg,
  75. metadata.ClientInfo{
  76. ServiceName: ServiceName,
  77. SigningRegion: signingRegion,
  78. Endpoint: endpoint,
  79. APIVersion: "2012-11-05",
  80. },
  81. handlers,
  82. ),
  83. }
  84. // Handlers
  85. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  86. svc.Handlers.Build.PushBackNamed(query.BuildHandler)
  87. svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler)
  88. svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler)
  89. svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler)
  90. // Run custom client initialization if present
  91. if initClient != nil {
  92. initClient(svc.Client)
  93. }
  94. return svc
  95. }
  96. // newRequest creates a new request for a SQS operation and runs any
  97. // custom request initialization.
  98. func (c *SQS) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  99. req := c.NewRequest(op, params, data)
  100. // Run custom request initialization if present
  101. if initRequest != nil {
  102. initRequest(req)
  103. }
  104. return req
  105. }