mirror of
https://github.com/GayFurCity/autocompleted.git
synced 2026-11-07 05:05:44 +00:00
No description
- Rust 94.8%
- Dockerfile 5.2%
| .github/workflows | ||
| sql | ||
| src | ||
| .dockerignore | ||
| .env.sample | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| docker-compose.yml | ||
| Dockerfile | ||
| LICENSE | ||
| README.md | ||
autocompleted
A tag autocomplete API service for Fennec, written in Rust using actix-web. It queries a PostgreSQL database for matching tags and caches results in memory. Used for GayFurCity.
Endpoints
| Method | Path | Description |
|---|---|---|
GET |
/ |
Autocomplete tags |
GET |
/up |
Health check (returns 204) |
Prometheus metrics are served separately, on METRICS_ADDR, so /metrics is never reachable through the public reverse proxy:
| Method | Path | Description |
|---|---|---|
GET |
/metrics |
Prometheus metrics (on METRICS_ADDR, not SERVER_ADDR) |
Exposes standard actix-web-prom HTTP metrics (autocompleted_http_requests_total, autocompleted_http_requests_duration_seconds) plus:
autocompleted_cache_hits_total/autocompleted_cache_misses_total— in-memory cache effectivenessautocompleted_db_query_duration_seconds— tag lookup query latency
GET /?search[name_matches]=<prefix>
Returns a JSON array of matching tags. The prefix must be 3–100 characters.
Example:
GET /?search[name_matches]=cani
Response:
[
{"id": 1, "name": "canine", "post_count": 12345, "category_id": 0, "antecedent_name": null}
]
Responses are cached for 6 hours (up to 15,000 entries). Supports * as a wildcard in the prefix.
Configuration
Copy .env.sample to .env and fill in the values:
SERVER_ADDR=0.0.0.0:3000
METRICS_ADDR=0.0.0.0:9396
PG__USER=postgres
PG__PASSWORD=secret
PG__HOST=localhost
PG__PORT=5432
PG__DBNAME=mydb
PG__POOL__MAX_SIZE=16
Running
# Development
cargo run
# Docker
docker compose up
Building
cargo build --release
License
See LICENSE.