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>
130 lines
4.0 KiB
TOML
130 lines
4.0 KiB
TOML
[nats]
|
|
url = "nats://localhost:4222"
|
|
# mode: "jetstream" (required - only JetStream mode is supported)
|
|
# JetStream provides:
|
|
# * Message persistence and replay capability
|
|
# * ACK/NAK mechanism for guaranteed delivery
|
|
# * Automatic retry with configurable backoff
|
|
# * Dead-letter queue (DLQ) support
|
|
# * Batch processing and consumer monitoring
|
|
mode = "jetstream"
|
|
client = "serial-client"
|
|
cluster = "tele-cluster"
|
|
stream = "TELEGRAM"
|
|
consumer = "telegram-consumer"
|
|
|
|
[nats.stream_limits]
|
|
# Stream retention and storage limits
|
|
# max_msgs: Maximum number of messages to keep in the stream (0 = unlimited)
|
|
max_msgs = 100000
|
|
# max_bytes: Maximum total size of messages in bytes (0 = unlimited, 67108864 = 64MB)
|
|
max_bytes = 67108864
|
|
# max_age: Maximum age of messages before automatic deletion (e.g., "24h", "7d")
|
|
max_age = "24h"
|
|
# discard: What to do when limits are reached: "old" (delete oldest) or "new" (reject new)
|
|
discard = "old"
|
|
# storage: "file" (persistent to disk) or "memory" (ephemeral, faster but lost on restart)
|
|
storage = "file"
|
|
# replicas: Number of stream replicas for high availability (1 = single node, 3+ for production cluster)
|
|
replicas = 1
|
|
|
|
[nats.consumer_rules]
|
|
# Consumer delivery rules
|
|
# max_deliver: Maximum number of delivery attempts before giving up (0 = unlimited)
|
|
max_deliver = 3
|
|
# ack_wait: Time to wait for ACK before redelivering message (e.g., "30s", "2m")
|
|
ack_wait = "30s"
|
|
# max_ack_pending: Maximum number of unacknowledged messages before pausing delivery
|
|
max_ack_pending = 1000
|
|
|
|
[nats.auth]
|
|
# NATS authentication configuration (optional for development)
|
|
# token: Simple token authentication (uncomment if needed)
|
|
# token = "your-dev-token"
|
|
|
|
# TLS configuration (optional - uncomment for secure connections)
|
|
# tls_enabled = true
|
|
# tls_cert_file = "/path/to/client.crt"
|
|
# tls_key_file = "/path/to/client.key"
|
|
# tls_ca_file = "/path/to/ca.crt"
|
|
|
|
[subscription]
|
|
topic = "telegram.serial"
|
|
queue_group = "tele-queue"
|
|
|
|
[publisher]
|
|
topic = "telegram.json"
|
|
|
|
[timeouts]
|
|
server = "5s"
|
|
reconnect_wait = "5s"
|
|
close = "10s"
|
|
ack_wait = "5s"
|
|
|
|
[postgres]
|
|
url = "postgres://caatsm:caatsm@localhost:5432/aviation?sslmode=disable"
|
|
max_conns = 10
|
|
min_conns = 2
|
|
|
|
[app]
|
|
# Batch processing configuration
|
|
# batch_size: Number of messages to fetch in each batch (JetStream pull batch size)
|
|
batch_size = 50
|
|
# batch_timeout: Maximum time to wait when fetching a batch (e.g., "2s")
|
|
batch_timeout = "2s"
|
|
# monitor_interval: How often to emit consumer statistics and metrics
|
|
monitor_interval = "30s"
|
|
|
|
[log]
|
|
level = "info"
|
|
format = "console"
|
|
output = ["stdout", "file"]
|
|
file = "logs/caatsm.log"
|
|
|
|
# File rotation settings
|
|
max_size = 100 # MB
|
|
max_backups = 7 # Keep 7 rotated files
|
|
max_age = 30 # Keep logs for 30 days
|
|
compress = true # Compress old log files
|
|
|
|
# Advanced options
|
|
disable_caller = false
|
|
disable_stacktrace = false
|
|
development = false
|
|
|
|
# Sampling configuration (optional, for high-volume scenarios)
|
|
# [log.sampling]
|
|
# initial = 100 # Log first 100 messages
|
|
# thereafter = 100 # Then log every 100th message
|
|
# tick = "1s" # Per second
|
|
|
|
[telemetry]
|
|
enabled = true
|
|
endpoint = "localhost:4318"
|
|
insecure = true
|
|
|
|
[monitoring]
|
|
disabled = false
|
|
addr = ":2112"
|
|
enable_metrics = true
|
|
enable_health = true
|
|
read_timeout = "5s"
|
|
write_timeout = "5s"
|
|
health_timeout = "2s"
|
|
|
|
[dlq]
|
|
# Dead-Letter Queue configuration
|
|
# enabled: Enable DLQ routing for poison messages (messages that fail after max_deliver attempts)
|
|
enabled = true # Set to true when switching to JetStream mode
|
|
# subject: NATS subject where failed messages will be published for manual inspection
|
|
subject = "caatsm.dlq"
|
|
|
|
[aftn]
|
|
# AFTN Protocol Validation and Monitoring
|
|
# validation_enabled: Enable AFTN protocol validation for telegrams (disabled by default for safe rollout)
|
|
validation_enabled = false
|
|
# message_gap_threshold: Duration after which serial reader is considered stalled (no messages received)
|
|
message_gap_threshold = "2m"
|
|
# enable_sequence_gap_detection: Monitor for missing sequence numbers in telegram stream
|
|
enable_sequence_gap_detection = true
|