Implement comprehensive AFTN/ICAO protocol compliance validation with configurable enforcement, enabling early detection of malformed telegrams and reducing downstream processing errors. Add real-time serial reader health monitoring to automatically detect message flow interruptions and sequence gaps, ensuring operational visibility into the telegram ingestion pipeline. Key enhancements: - AFTN validator validates priority indicators (FF/GG/QU/DD/SS/KK), ICAO addresses (4-char alphanumeric), and datetime formats (DDHHMM) with detailed error categorization - Invalid telegrams automatically routed to DLQ with full context for offline review and correction - Serial reader health monitoring tracks message gaps and sequence numbers to detect stalled readers or missing messages within configurable threshold (default: 2 minutes) - Four new Prometheus metrics expose validation errors by type, message gaps, sequence gaps, and health status for operational alerting - Pre-configured Prometheus alert rules for critical conditions (stalled reader, high error rates, consumer lag) - Grafana dashboard provides real-time visibility into AFTN compliance and serial reader health - Validation disabled by default for safe rollout with zero breaking changes to existing functionality Implementation maintains clean architecture with validator in adapter layer, extends processor and consumer with health tracking, and ensures thread-safe concurrent access to tracking state. All changes fully tested with 48 validator tests, 10 processor tests, and 21 consumer tests passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
54 lines
2.1 KiB
Go
54 lines
2.1 KiB
Go
package dto
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// MessageStatus represents the parsing status of a telegram.
|
|
// It is intentionally decoupled from infrastructure concerns (e.g. DB or publish failures)
|
|
// so that domain parsing state can be reasoned about independently.
|
|
type MessageStatus string
|
|
|
|
const (
|
|
MessageStatusUnknown MessageStatus = "unknown"
|
|
MessageStatusParsed MessageStatus = "parsed"
|
|
MessageStatusHeaderError MessageStatus = "header_error"
|
|
MessageStatusBodyError MessageStatus = "body_error"
|
|
MessageStatusAFTNError MessageStatus = "aftn_error"
|
|
)
|
|
|
|
// ParsedTelegram holds the parsed data from an aviation message.
|
|
// It is a transport-oriented model used by the application pipeline (parser,
|
|
// persistence, publishing), and may embed domain-specific body structures
|
|
// (e.g. *domain.FPL, *domain.DEP) in BodyData.
|
|
type ParsedTelegram struct {
|
|
Uuid string `json:"uuid"`
|
|
MessageID string `json:"messageId"`
|
|
DateTime string `json:"dateTime"`
|
|
PriorityIndicator string `json:"priorityIndicator"`
|
|
PrimaryAddress string `json:"primaryAddress"`
|
|
SecondaryAddresses string `json:"secondaryAddresses,omitempty"`
|
|
Originator string `json:"originator,omitempty"`
|
|
OriginatorDateTime string `json:"originatorDateTime,omitempty"`
|
|
Category string `json:"category,omitempty"`
|
|
Body string `json:"body"`
|
|
Content string `json:"content,omitempty"`
|
|
BodyData interface{} `json:"bodyData,omitempty"`
|
|
ReceivedAt time.Time `json:"receivedAt"`
|
|
ParsedAt time.Time `json:"parsedAt,omitempty"`
|
|
DispatchedAt time.Time `json:"dispatchedAt,omitempty"`
|
|
NeedDispatch bool `json:"needDispatch"`
|
|
Parsed bool `json:"parsed"`
|
|
Comments string `json:"comments,omitempty"`
|
|
Status MessageStatus
|
|
ErrorReason string `json:"errorReason,omitempty"`
|
|
}
|
|
|
|
// NewParsedTelegram initializes a ParsedTelegram with default values.
|
|
func NewParsedTelegram() *ParsedTelegram {
|
|
return &ParsedTelegram{
|
|
Parsed: false,
|
|
Status: MessageStatusUnknown,
|
|
}
|
|
}
|