feat: Add timestamp fields to ParsedMessage struct

The code changes in `aviation_parser.go` add the `ParsedAt` and `ReceivedAt` fields to the `ParsedMessage` struct. These fields store the timestamps when the message was parsed and received, respectively. This enhancement provides valuable information for tracking and analyzing message processing times.
This commit is contained in:
windyboy
2024-07-20 22:25:28 +08:00
parent 2b83d9b785
commit 135ef12c4d
+3
View File
@@ -7,6 +7,7 @@ import (
"errors" // Import errors package to handle errors "errors" // Import errors package to handle errors
"fmt" "fmt"
"strings" "strings"
"time"
) )
const ( const (
@@ -115,6 +116,7 @@ func Parse(rawText string) (*domain.ParsedMessage, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
message.ParsedAt = time.Now()
message.BodyData = bodyData message.BodyData = bodyData
return &message, nil return &message, nil
} }
@@ -150,6 +152,7 @@ func ParseHeader(fullMessage string) (domain.ParsedMessage, error) {
Originator: originator, Originator: originator,
OriginatorDateTime: originatorDateTime, OriginatorDateTime: originatorDateTime,
BodyAndFooter: bodyAndFooter, BodyAndFooter: bodyAndFooter,
ReceivedAt: time.Now(),
}, nil }, nil
} }