Clean up and optimize codebase for production readiness

Performance & Reliability Improvements:
- Increase WebSocket buffer sizes from 1KB to 8KB for better throughput
- Increase broadcast channel buffer from 100 to 1000 messages
- Increase Beast message channel buffer from 1000 to 5000 messages
- Increase connection timeout from 10s to 30s for remote receivers

Code Quality Improvements:
- Remove debug output from production code (CPR Debug, Merger Update spam)
- Add MaxDistance constant to replace magic number (999999)
- Clean up comments for better maintainability
- Implement auto-enable for selected aircraft trails

Benefits:
- Much cleaner server logs without debug spam
- Better performance under high aircraft density
- More reliable WebSocket connections with larger buffers
- Improved fault tolerance with increased timeouts

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2025-08-24 17:54:17 +02:00
commit 064ba2de71
5 changed files with 23 additions and 23 deletions

View file

@ -73,7 +73,7 @@ func NewBeastClient(source *merger.Source, merger *merger.Merger) *BeastClient {
source: source,
merger: merger,
decoder: modes.NewDecoder(source.Latitude, source.Longitude),
msgChan: make(chan *beast.Message, 1000),
msgChan: make(chan *beast.Message, 5000),
errChan: make(chan error, 10),
stopChan: make(chan struct{}),
reconnectDelay: 5 * time.Second,
@ -146,7 +146,7 @@ func (c *BeastClient) run(ctx context.Context) {
addr := fmt.Sprintf("%s:%d", c.source.Host, c.source.Port)
fmt.Printf("Connecting to Beast stream at %s (%s)...\n", addr, c.source.Name)
conn, err := net.DialTimeout("tcp", addr, 10*time.Second)
conn, err := net.DialTimeout("tcp", addr, 30*time.Second)
if err != nil {
fmt.Printf("Failed to connect to %s: %v\n", c.source.Name, err)
c.source.Active = false