Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
kojisaikiAtSony committed May 21, 2024
1 parent f1de347 commit 7342cdd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
3 changes: 2 additions & 1 deletion app/gosqs/send_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func SendMessageV1(req *http.Request) (int, interfaces.AbstractResponseBody) {

queueName := ""
if queueUrl == "" {
// TODO: Remove this query param logic if it's not still valid or something
vars := mux.Vars(req)
queueName = vars["queueName"]
} else {
Expand Down Expand Up @@ -103,7 +104,7 @@ func SendMessageV1(req *http.Request) (int, interfaces.AbstractResponseBody) {
}

// TODO:
// Refactor internal MessageAttribute model between SendMessage and ReceiveMessage
// Refactor internal model for MessageAttribute between SendMessage and ReceiveMessage
// from app.MessageAttributeValue(old) to models.MessageAttributeValue(new) and remove this temporary function.
func convertToOldMessageAttributeValueStructure(newValues map[string]models.MessageAttributeValue) map[string]app.MessageAttributeValue {
attributes := make(map[string]app.MessageAttributeValue)
Expand Down
16 changes: 11 additions & 5 deletions app/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,17 @@ func NewSendMessageRequest() *SendMessageRequest {
}

type SendMessageRequest struct {
DelaySeconds int `json:"Del1aySeconds" schema:"DelaySeconds"`
MessageAttributes map[string]MessageAttributeValue `json:"MessageAttributes" schema:"MessageAttributes"`
MessageBody string `json:"MessageBody" schema:"MessageBody"`
MessageDeduplicationId string `json:"MessageDeduplicationId" schema:"MessageDeduplicationId"`
MessageGroupId string `json:"MessageGroupId" schema:"MessageGroupId"`
DelaySeconds int `json:"DelaySeconds" schema:"DelaySeconds"`
// MessageAttributes is custom attributes that users can add on the message as they like.
// Please see: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html#SQS-SendMessage-request-MessageAttributes
MessageAttributes map[string]MessageAttributeValue `json:"MessageAttributes" schema:"MessageAttributes"`
MessageBody string `json:"MessageBody" schema:"MessageBody"`
MessageDeduplicationId string `json:"MessageDeduplicationId" schema:"MessageDeduplicationId"`
MessageGroupId string `json:"MessageGroupId" schema:"MessageGroupId"`
// MessageSystemAttributes is custom attributes for AWS services.
// Please see: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html#SQS-SendMessage-request-MessageSystemAttributes
// On AWS, the only supported attribute is AWSTraceHeader that is for AWS X-Ray.
// Goaws does not contains X-Ray emulation, so currently MessageSystemAttributes is unsupported.
MessageSystemAttributes map[string]MessageAttributeValue `json:"MessageSystemAttributes" schema:"MessageSystemAttributes"`
QueueUrl string `json:"QueueUrl" schema:"QueueUrl"`
}
Expand Down
4 changes: 2 additions & 2 deletions app/models/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func TestSendMessageRequest_SetAttributesFromForm_success(t *testing.T) {
form.Add("MessageAttribute.1.Value.DataType", "String")
form.Add("MessageAttribute.1.Value.StringValue", "Value1")
form.Add("MessageAttribute.2.Name", "Attr2")
form.Add("MessageAttribute.2.Value.DataType", "String")
form.Add("MessageAttribute.2.Value.DataType", "Binary")
form.Add("MessageAttribute.2.Value.BinaryValue", "VmFsdWUy")
form.Add("MessageAttribute.3.Name", "")
form.Add("MessageAttribute.3.Value.DataType", "String")
Expand All @@ -286,7 +286,7 @@ func TestSendMessageRequest_SetAttributesFromForm_success(t *testing.T) {

assert.NotNil(t, r.MessageAttributes["Attr2"])
attr2 := r.MessageAttributes["Attr2"]
assert.Equal(t, "String", attr2.DataType)
assert.Equal(t, "Binary", attr2.DataType)
assert.Equal(t, "", attr2.StringValue)
assert.Equal(t, "VmFsdWUy", attr2.BinaryValue)
}
Expand Down

0 comments on commit 7342cdd

Please sign in to comment.