|
@@ -48,7 +48,7 @@ func receiver(ctx context.Context, w io.Writer, client *sqs.Client, qURL string)
|
|
|
spew.Fdump(w, msg.Messages)
|
|
|
}
|
|
|
|
|
|
-type Handler func(ctx context.Context, enc *json.Encoder, input []byte) error
|
|
|
+type Handler func(ctx context.Context, enc *json.Encoder, msgID uuid.UUID, sent time.Time, input []byte, meta map[string]types.MessageAttributeValue) error
|
|
|
|
|
|
type message types.Message
|
|
|
|
|
@@ -86,7 +86,7 @@ func consumer(ctx context.Context, w io.Writer, enc *json.Encoder, client *sqs.C
|
|
|
if err != nil {
|
|
|
fmt.Fprintf(w, "invalid message %s: %w, dropping it anyway", msg, err)
|
|
|
} else {
|
|
|
- if err := hdl(ctx, enc, evt.Body); err != nil {
|
|
|
+ if err := hdl(ctx, enc, evt.MessageID, evt.SentTime, evt.Body, evt.MessageAttributes); err != nil {
|
|
|
fmt.Fprintf(w, "Error processing message: %s: %v, dropping it anyway\n", msg, err)
|
|
|
} else {
|
|
|
fmt.Fprintf(w, "Message %s processed successfully\n", msg)
|
|
@@ -117,7 +117,8 @@ type Event struct {
|
|
|
AttrSum string `json:"MD5MofMessageAttributes"`
|
|
|
|
|
|
EventAttributes
|
|
|
- Body []byte
|
|
|
+ MessageAttributes map[string]types.MessageAttributeValue
|
|
|
+ Body []byte
|
|
|
}
|
|
|
|
|
|
func validateMessage(msg message) (*Event, error) {
|
|
@@ -159,6 +160,8 @@ func validateMessage(msg message) (*Event, error) {
|
|
|
}
|
|
|
evt.EventAttributes.ApproximateFirstReceiveTimestamp = time.Unix(int64(msec)/1000, int64(msec)*1000)
|
|
|
|
|
|
+ evt.MessageAttributes = msg.MessageAttributes
|
|
|
+
|
|
|
// EventBody field
|
|
|
if msg.Body == nil {
|
|
|
return nil, fmt.Errorf("message body is nil")
|