types.go 6.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package redriver
  2. type SystemMessageAttributes struct {
  3. ApproximateFirstReceiveTimestamp int64 `json:"approximate_first_receive_timestamp,omitempty"`
  4. ApproximateReceiveCount int64 `json:"approximate_receive_count,omitempty"`
  5. DeadLetterQueueSourceARN string `json:"dead_letter_queue_source_arn,omitempty"`
  6. SenderId string `json:"sender_id,omitempty"` // SenderId may be an IAM user or role
  7. SentTimestamp int64 `json:"sent_timestamp,omitempty"`
  8. SequenceNumber int `json:"sequence_number,omitempty"` // Only returned when producing, not consuming
  9. }
  10. type Message struct {
  11. Attributes *SystemMessageAttributes `json:"attributes,omitempty"`
  12. Body string `json:"body,omitempty"` // Body is not url-encoded
  13. Md5OfBody string `json:"md5_of_body,omitempty"` // Md5OfBody hold an MD5 digest of the non-URL-encoded message body string.
  14. Md5OfMessageAttributes string `json:"md5_of_message_attributes,omitempty"` // Md5OfMessageAttributes holds an MD5 digest of the non-URL-encoded message attribute string. You can use this attribute to verify that Amazon SQS received the message correctly. Amazon SQS URL-decodes the message before creating the MD5 digest. For information about MD5, see RFC1321 (https://www.ietf.org/rfc/rfc1321.txt).
  15. MessageAttributes map[string]any `json:"message_attributes,omitempty"` // Needs app-level interpretation
  16. MessageId string `json:"message_id,omitempty"` // MessageId is opaque.
  17. ReceiptHandle string `json:"receipt_handle,omitempty"` // ReceiptHandle is an identifier associated with the act of receiving the message. A new receipt handle is returned every time you receive a message. When deleting a message, you provide the last received receipt handle to delete the message.
  18. }
  19. func (m Message) Keys() ItemsKeys {
  20. return ItemsKeys{
  21. MessageID: m.MessageId,
  22. ReceiptHandle: m.ReceiptHandle,
  23. }
  24. }
  25. type NameRedriveBody struct {
  26. Id string `json:"id,omitempty"`
  27. ReceiptHandle string `json:"receipt_handle,omitempty"`
  28. }
  29. type QueueInfo struct {
  30. // Name is the queue name, for both human and machine use
  31. Name string `json:"name,omitempty"`
  32. URL string `json:"url,omitempty"`
  33. Attributes *QueueInfoAttributes `json:"attributes,omitempty"`
  34. }
  35. func (qi QueueInfo) IsDLQ() bool {
  36. return qi.Attributes.RedriveAllowPolicy != nil
  37. }
  38. type QueueInfoAttributes struct {
  39. // ApproximateNumberOfMessages holds the approximate number of messages available for retrieval from the queue.
  40. ApproximateNumberOfMessages int64 `json:"approximate_number_of_messages,omitempty"`
  41. // ApproximateNumberOfMessagesDelayed holds he approximate number of messages in the queue that are delayed and not available for reading immediately. This can happen when the queue is configured as a delay queue or when a message has been sent with a delay parameter.
  42. ApproximateNumberOfMessagesDelayed int64 `json:"approximate_number_of_messages_delayed,omitempty"`
  43. // ApproximateNumberOfMessagesNotVisible holds the approximate number of messages that are in flight. Messages are considered to be in flight if they have been sent to a client but have not yet been deleted or have not yet reached the end of their visibility window.
  44. ApproximateNumberOfMessagesNotVisible int64 `json:"approximate_number_of_messages_not_visible,omitempty"`
  45. // CreatedTimestamp holds the time when the queue was created in seconds (epoch time).
  46. CreatedTimestamp int64 `json:"created_timestamp,omitempty"`
  47. // DelaySeconds holds the default delay on the queue in seconds.
  48. DelaySeconds int64 `json:"delay_seconds,omitempty"`
  49. // LastModifiedTimestamp holds the time when the queue was last changed in seconds (epoch time).
  50. LastModifiedTimestamp int64 `json:"last_modified_timestamp,omitempty"`
  51. // MaximumMessageSize holds the limit of how many bytes a message can contain before Amazon SQS rejects it.
  52. MaximumMessageSize int64 `json:"maximum_message_size,omitempty"`
  53. // MessageRetentionPeriod holds the length of time, in seconds, for which Amazon SQS retains a message. When you change a queue's attributes, the change can take up to 60 seconds for most of the attributes to propagate throughout the Amazon SQS system. Changes made to the MessageRetentionPeriod attribute can take up to 15 minutes and will impact existing messages in the queue potentially causing them to be expired and deleted if the MessageRetentionPeriod is reduced below the age of existing messages.
  54. MessageRetentionPeriod int64 `json:"message_retention_period,omitempty"`
  55. QueueARN string `json:"queue_arn,omitempty"`
  56. // ReceiveMessageWaitTimeSeconds holds the length of time, in seconds, for which the ReceiveMessage action waits for a message to arrive.
  57. ReceiveMessageWaitTimeSeconds int64 `json:"receive_message_wait_time_seconds,omitempty"`
  58. // VisibilityTimeout holds the number of seconds a message remains hidden after being received. Max 43200.
  59. VisibilityTimeout int64 `json:"visibility_timeout,omitempty"`
  60. RedrivePolicy *QueueInfoAttributesRedrivePolicy `json:"redrive_policy,omitempty"`
  61. RedriveAllowPolicy *QueueInfoAttributesRedriveAllowPolicy `json:"redrive_allow_policy,omitempty"`
  62. }
  63. // QueueInfoAttributesRedriveAllowPolicy describes the permissions for the dead-letter queue redrive permission and which source queues can specify dead-letter queues.
  64. type QueueInfoAttributesRedriveAllowPolicy struct {
  65. // RedrivePermission defines which source queues can specify the current queue as the dead-letter queue.
  66. RedrivePermission string `json:"redrivePermission,omitempty"`
  67. SourceQueueARNs []string `json:"sourceQueueArns,omitempty"`
  68. }
  69. // QueueInfoAttributesRedrivePolicy holds the parameters for the dead-letter queue functionality of the source queue
  70. type QueueInfoAttributesRedrivePolicy struct {
  71. // DeadLetterTargetARN holds the Amazon Resource Name (ARN) of the dead-letter queue to which Amazon SQS moves messages after the value of maxReceiveCount is exceeded.
  72. DeadLetterTargetARN string `json:"deadLetterTargetArn,omitempty"`
  73. // MaxReceiveCount holds the number of times a message is delivered to the source queue before being moved to the dead-letter queue. Default 10. When the ReceiveCount for a message exceeds the maxReceiveCount for a queue, Amazon SQS moves the message to the dead-letter-queue.
  74. MaxReceiveCount int64 `json:"maxReceiveCount,omitempty"`
  75. }
  76. // Error is a general error response format
  77. type Error struct {
  78. // Message is a free-form string describing the error.
  79. Message string `json:"message,omitempty"`
  80. }