- Weighted random routing (math/rand/v2 per-goroutine ChaCha8) - PUT /api/route/mode for runtime mode switch (best / weighted_random) - EWMA score smoothing (configurable smoothing_factor, default 0.3) - Periodic stale node eviction (5 min threshold, 60s interval) - Non-blocking WS broadcast (per-client buffered channel + writePump) - Background rate limiter cleanup goroutine - In-memory trunk gateway cache (zero disk I/O in hot path) - Configurable load_avg multiplier (default 50.0, backward compat) - UI mode indicator + admin Switch button in dashboard - 42 tests: weighted random, mode switching, EWMA, eviction, API integration
1.5 KiB
1.5 KiB
Contributing
Code Style
- Go:
go fmt,go vet,staticcheck - Svelte/JS: стандартный формат Prettier
Перед коммитом:
make fmt
make lint
make test
Как добавить новый эндпоинт
- Определить модель в
internal/models/types.go - Реализовать хендлер в
internal/api/<name>.go - Зарегистрировать маршрут в
internal/api/router.goс нужными middleware (auth, admin) - Добавить тесты в
internal/engine/engine_test.goесли затрагивается scoring
Commit Messages
Формат — Conventional Commits:
feat: add support for custom scoring weights
fix: handle nil ESL client in route handler
docs: add API reference table to README
refactor: extract scoring logic into separate method
test: add lethal condition tests for stale nodes
chore: update Go dependencies
PR Process
- Ветка от
main, названиеfeature/,fix/илиdocs/ - Один PR — одно логическое изменение
- Все тесты проходят (
make test) - Код проходит
make lint - Если меняется API — обновить README.md
Тестирование
make test # юнит-тесты
make test-race # с race detector
make emulate-normal # интеграционная проверка