Implement comprehensive weather parsing capabilities following Clean Architecture principles with composite parser pattern for routing between aviation and weather messages. ## Features Added - Weather report parsing (METAR, SPECI, TAF) - Composite parser pattern for message routing - Lenient parsing with warnings for unrecognized tokens - Support for PROB and RMK sections in TAF - Rich domain modeling with typed weather elements ## Architecture **Domain Layer** (internal/domain/weather/): - WeatherMessage interface with Metar and Taf implementations - Weather elements: Wind, Visibility, Cloud, Temperature, Altimeter, Phenomenon - Domain errors: ErrInvalidFormat, ErrMissingStation, ErrMissingTime **Port Layer** (internal/port/weather_parser.go): - WeatherParser interface with CanParse and Parse methods **Adapter Layer** (internal/adapter/parser/weather/): - WeatherParserImpl with classification and parsing logic - Comprehensive regex patterns for weather elements - METAR/SPECI parser with element extraction - TAF parser with period handling (FM, TEMPO, BECMG, PROB) - Helper functions for time parsing and unit conversions **Composite Parser** (internal/adapter/parser/composite.go): - Routes weather reports to weather parser - Falls back to aviation parser for telegrams - Converts WeatherMessage to ParsedTelegram format ## Integration - Updated ProvideParser to create composite parser with weather parser - Added weather parser to Wire DI configuration - Updated processor_bench_test.go for weather parser integration - Documentation added in docs/weather-parser.md ## Testing - 29 comprehensive tests for weather parsing (all passing) - Tests for classification, METAR, SPECI, TAF, and composite routing - Benchmark compatibility maintained ## Fixes Applied - TAF PROB parsing: Include PROB/RMK in special section detection - Composite test: Updated to use properly formatted AFTN telegram - Linter issues: Switch statement refactor, removed unused patterns - Ineffective break statement fixed in TAF parser ## Coverage ~1,743 lines of new code with: - Complete METAR/SPECI parsing - TAF parsing with period support - Lenient error handling with warnings - Unit conversions and time utilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
AGENTS.md to streamline commands and code style guidelines, enhancing clarity and usability. Update README.md with refined NATS consumer configuration details and observability metrics. Modify .gitignore to exclude dynamically generated Prometheus target files. Enhance configuration files for development and production environments, ensuring consistency and clarity in settings.
AGENTS.md to streamline commands and code style guidelines, enhancing clarity and usability. Update README.md with refined NATS consumer configuration details and observability metrics. Modify .gitignore to exclude dynamically generated Prometheus target files. Enhance configuration files for development and production environments, ensuring consistency and clarity in settings.
docker-compose.dev.yml to dynamically generate target configurations for the CAATSM receiver. Modify Makefile and Taskfile to allow setting the monitoring address via environment variables. Update observability settings in config.dev.toml and Prometheus scrape configurations to improve integration with the monitoring stack. Enhance CLI options for monitoring address and disable monitoring features as needed.
go.uber.org/zap to version 1.27.1 and golang.org/x/crypto to version 0.45.0. Revise Makefile and documentation to reflect changes in NATS mode, ensuring consistent messaging behavior across development and production environments. Enhance README and configuration files to clarify JetStream usage and remove references to Core NATS mode.
go.uber.org/zap to version 1.27.1 and golang.org/x/crypto to version 0.45.0. Revise Makefile and documentation to reflect changes in NATS mode, ensuring consistent messaging behavior across development and production environments. Enhance README and configuration files to clarify JetStream usage and remove references to Core NATS mode.
go-caatsm
Civil Aviation Authority Telegram Message Processor.
High-performance processing for aviation telegrams using Clean Architecture, NATS JetStream, and PostgreSQL/TimescaleDB.
Architecture
Clean Architecture with clear separation of concerns:
- cmd: application entry points
- internal/domain: core domain types
- internal/port: interfaces/contracts
- internal/app: application orchestration
- internal/adapter: parsing, mapping, DTOs
- internal/infra: NATS, PostgreSQL, config, logging, metrics, telemetry
- pkg/di: dependency injection (Wire)
Features
- JetStream ingestion with retries and DLQ support
- PostgreSQL/TimescaleDB persistence
- Structured logging (Zap)
- OpenTelemetry tracing and Prometheus metrics
- Optional AFTN protocol validation
- Batch processing and health monitoring
- Weather report parsing (METAR, SPECI, TAF)
Prerequisites
- Go 1.24+
- PostgreSQL 12+
- NATS Server with JetStream enabled
- Docker (integration tests)
Quick Start
-
Start dependencies:
docker compose -f docker-compose.dev.yml up -d postgres nats nats-box -
Configure the application:
- Copy
configs/config.dev.tomland edit as needed - Or set environment variables with the
CAATSM_prefix
- Copy
-
Run in dev mode:
make run-dev
Build and Run
- Build:
make build - Run (dev):
make run-dev - Run (prod):
make run-prod - Run (local go run):
make run-local
Configuration
Configuration loads from configs/config.{env}.toml, where {env} is GO_ENV (default: dev).
Required values:
nats.urlpostgres.urlpublisher.topic
Defaults:
nats.streamdefaults toTELEGRAMsubscription.topicdefaults totelegram.>nats.modemust bejetstreamor empty (defaults to JetStream)
Minimal example:
[nats]
url = "nats://localhost:4222"
mode = "jetstream"
stream = "TELEGRAM"
consumer = "telegram-consumer"
[publisher]
topic = "telegram.json"
[subscription]
topic = "telegram.serial"
[postgres]
url = "postgres://user:password@localhost:5432/aviation?sslmode=disable"
[app]
batch_size = 50
batch_timeout = "2s"
monitor_interval = "30s"
[log]
level = "info"
format = "json"
Timeouts and Ack Wait
[timeouts] is optional. To tune redelivery, set timeouts.ack_wait and/or nats.consumer_rules.ack_wait. When neither is specified the application defaults to 30s.
JetStream Notes
- JetStream is required; other modes are not supported.
- In dev/test (
GO_ENV=devorGO_ENV=test), the stream and consumer are auto-created. - In production, ensure the stream and consumer exist before starting the service.
- Configure retention and delivery behavior under
[nats.stream_limits]and[nats.consumer_rules].
AFTN Validation
AFTN validation is optional and disabled by default. Enable it with:
[aftn]
validation_enabled = true
message_gap_threshold = "2m"
enable_sequence_gap_detection = true
When enabled, invalid telegrams are logged, recorded with error details, and can be routed to a DLQ if configured.
Observability
- Metrics:
GET /metrics - Liveness:
GET /livez - Readiness:
GET /readyz
Monitoring server settings are under [monitoring]. Tracing is configured via [telemetry].
CLI
./bin/receiver listen --help
Common flags:
--nats-url--subject--stream--consumer--publisher-topic--postgres-url--log-level--replay-from--ack-wait--telemetry-enabled,--telemetry-endpoint,--telemetry-insecure
Testing
- Unit tests (Ginkgo):
make test - Integration tests (Docker):
make test-int - All tests:
make test-all - Lint:
make lint - Coverage:
make coverage
Single test example:
ginkgo -r -v --focus "Test Description" ./path/to/package
Seed Tool
cmd/seed-telegrams publishes synthetic telegrams for development and testing.
Example:
go run ./cmd/seed-telegrams \
--nats-url nats://localhost:4222 \
--jetstream \
--stream TELEGRAM \
--js-subject telegram.serial \
--count 10 \
--category mixed \
--status random
Documentation
docs/dev-guide.mddocs/prod-guide.mddocs/nats.mddocs/observability.mddocs/performance.mddocs/migrations.mddocs/secret-management.mddocs/reliability.md
Contributing
See AGENTS.md for coding standards, testing expectations, and release hygiene.
License
This repository has not declared a public license yet.