Files
BalanceServer/docs/DEVELOPMENT.md
T
wtandClaude Opus 5.5 10272f3851
CI / Rust (fmt / clippy / test / build) (push) Successful in 1m41s
CI / HTTP/JSON reference + SQLite persistence (push) Successful in 1m16s
CI / Rust (fmt / clippy / test / build) (pull_request) Successful in 47s
CI / HTTP/JSON reference + SQLite persistence (pull_request) Successful in 1m34s
Remove the Go reference server; keep only Rust
The Go implementation is preserved in the v1.0.0 tag. Its observable
behaviour stays the API reference: responses recorded from the Go server
live in tools/compatibility_expected.txt, and tools/compatibility.py now
compares the Rust server against them (--update re-records after an
intentional change). The Go SQLite schema is frozen in
tests/fixtures/go_schema_v1.sql for the existing-database test.

Move the web client from internal/httpapi/web to web/, drop the Go CI job
and Go version pin, and update README, AGENTS.md and docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 16:27:33 +07:00

120 lines
3.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Разработка и запуск
## Требования
Сервер использует Rust 1.90+ и bundled SQLite. Python 3 нужен для `tools/compatibility.py` и используется без сторонних пакетов. Go больше не нужен.
Проверить локальную версию:
```bash
rustc --version
cargo --version
python3 --version
```
## Установка зависимостей
```bash
cargo fetch --locked
```
## Сборка
```bash
cargo build --locked
```
## Тесты
```bash
cargo test --locked
cargo build --locked
python3 tools/compatibility.py
```
`tools/compatibility.py` запускает сервер на временных портах и базах и сравнивает
ответы API и статику с ответами исходного Go-сервера, записанными в
`tools/compatibility_expected.txt`. Расхождение означает изменение, видимое
клиентам. Если изменение намеренное, проверьте diff и перезапишите эталон:
```bash
python3 tools/compatibility.py --update
```
## Static checks
```bash
cargo fmt --check
cargo clippy --locked --all-targets -- -D warnings
```
Если в проекте есть Makefile/CI, его команды имеют приоритет как canonical build pipeline.
## Локальный запуск
Перед запуском изучите конфигурацию в коде и `.env`/deployment files.
Не коммитьте реальные credentials.
Собрать и запустить Rust-сервер:
```bash
cargo build --locked --release
export BALANCE_JWT_SECRET="replace-with-a-long-random-secret"
export BALANCE_DB_PATH="./data/balance.db"
./target/release/balance-server
```
По умолчанию сервер слушает `:8080`. Файл `.env` читает Docker Compose; при
прямом запуске переменные нужно передать процессу через окружение.
## Database
SQLite встроен в executable. При первом запуске сервер создаёт каталог,
таблицы и индексы автоматически. Отдельный процесс БД не нужен. При переходе
с Go сохраните существующий файл БД и `BALANCE_JWT_SECRET`; подробная
процедура и откат описаны в [DEPLOYMENT.md](DEPLOYMENT.md).
## Production
Рекомендуемый pipeline:
```text
source
↓
cargo fmt --check && cargo test --locked
↓
cargo clippy --locked --all-targets -- -D warnings
↓
cargo build --locked --release
↓
python3 tools/compatibility.py --binary target/release/balance-server
↓
container/package
↓
deploy
↓
health check
```
Для production нужны:
- TLS termination;
- persistent database;
- backups;
- monitoring;
- log rotation;
- secrets management;
- migration procedure.
## Совместимость
При релизе server проверяйте минимум:
- старый iOS client + новый server;
- новый iOS client + server;
- Android client + server;
- concurrent sync с двух устройств;
- login/refresh после истечения access token;
- delete → pull на другом устройстве.
Production build: `cargo build --locked --release`. Прямой запуск: `BALANCE_JWT_SECRET=<secret> target/release/balance-server`, порт 8080. Docker Compose публикует порт 8123 и сохраняет прежний volume `/data`. Процедура миграции Go → Rust и rollback: [DEPLOYMENT.md](DEPLOYMENT.md).