pulse-lets-go/CONTRIBUTING.md
Maksim Totmin 938c9e9362 feat: weighted random routing + mode switching + EWMA smoothing + stale eviction
- 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
2026-06-25 20:42:46 +07:00

1.5 KiB
Raw Blame History

Contributing

Code Style

  • Go: go fmt, go vet, staticcheck
  • Svelte/JS: стандартный формат Prettier

Перед коммитом:

make fmt
make lint
make test

Как добавить новый эндпоинт

  1. Определить модель в internal/models/types.go
  2. Реализовать хендлер в internal/api/<name>.go
  3. Зарегистрировать маршрут в internal/api/router.go с нужными middleware (auth, admin)
  4. Добавить тесты в 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

  1. Ветка от main, название feature/, fix/ или docs/
  2. Один PR — одно логическое изменение
  3. Все тесты проходят (make test)
  4. Код проходит make lint
  5. Если меняется API — обновить README.md

Тестирование

make test          # юнит-тесты
make test-race     # с race detector
make emulate-normal # интеграционная проверка