0ebb8a21a1
Clean Up Testing and Linting * somescriptcleanup * mostgolangci * deplatest * imageversions * usingscratch * movedqueuefrtesting * finishedunittesting * linting * taskfilecontext
31 lines
649 B
Go
31 lines
649 B
Go
package queue
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/aws/aws-sdk-go-v2/aws"
|
|
"github.com/aws/aws-sdk-go-v2/service/sqs"
|
|
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
|
|
)
|
|
|
|
func Send(ctx context.Context, config *Config, body interface{}, attributes map[string]types.MessageAttributeValue) error {
|
|
jsonBytes, err := json.Marshal(body)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
strBody := string(jsonBytes)
|
|
|
|
_, err = config.Client.SendMessage(ctx, &sqs.SendMessageInput{
|
|
MessageAttributes: attributes,
|
|
QueueUrl: aws.String(config.URL),
|
|
MessageBody: aws.String(strBody),
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|