HaRSS Api
February 13, 2024 · View on GitHub
HaRSS Api
RSS API, but in rust
Disclaimer
This is still a prototype, not fit for production yet. The API is still subject to breaking change, without warning. Use at our own risk!
Even if it is still a prototype, it's still open to issue, idea, any input.
This is my pet project to learn rust, so there is, and there will probably be a lot of bad code, but I'm here to learn so if you want to highlight something, you're more than welcome!
Api specification
You can find an openapi specification here
Configuration
All the configuration must be pass through environment variables.
DATABASE_URL(required): The URL to the postgres database aspostgres://POSTGRES_USER:POSTGRES_PASSWORD@HOST:5432/rss-aggregatorREDIS_URL: The redis URL asredis://HOST. Defaultredis://locahostJWT_SECRET(required): String used as the key for JWTRSS_AGGREGATOR_ALLOW_ACCOUNT_CREATIONtrue/false (default false): Allow user to register an account. Otherwise, an admin should do itPOLLING_INTERVAL: The number of seconds between feeds update. Default300JAEGER_AGENT_ENDPOINT: If set tohost:port, enable the Jaeger telemetry layer. Defaultnot setDD_AGENT_ENDPOINT: If set tohttp://host:port, enable the DataDog telemetry layer. Defaultnot setOTEL_EXPORTER_JAEGER_AGENT_HOST: Hostname/IP of the jaeger agent. DefaultlocalhostOTEL_EXPORTER_JAEGER_AGENT_PORT: Port of the jaeger agent. Default6831RUST_LOG: (error/warn/info/debug/trace) Log level. DefaultinfoSENTRY_DSN: Your sentry DSN if you have one. If not provided, disable sentryFAILURE_THRESHOLD: Number of failure before automatically disabling a channel. If 0, never disable it. Default3FETCH_TIMEOUT: Timeout in seconds for RSS feed fetching. Default3RATE_LIMITING_BUCKET_SIZE: Set quota size that defines how many requests can occur before the governor middleware starts blocking requests from an IP address and clients have to wait until the elements of the quota are replenished. Default100RATE_LIMITING_FILL_RATE: Set the interval after which one element of the quota is replenished in seconds. Default10FETCH_CRON: Cron expression to determine when the scheduler should run. Default0 0 * * * *(every hour)
What does it use
sqlxfor migrationActixWebfor, well, the web stuffTracing/Jaegerfor logs and observability
How to launch it quickly
Using docker-compose
docker compose up
This will create the databases (postgres + redis), do the necessary migrations. You can uncomment all the jaeger related command if you want to enable it.
How to init/migrate database
Using docker-compose
If you use docker compose, the database migrations image will be build automatically and applied when you up the whole
compose.
But if you don't want to use the entire docker compose. you can still build the image and use it for your own database.
docker compose build migrations # ☕
# Run the migration against a containered database
docker run --link containered-postgres --rm -e DATABASE_URL=postgres://harss:harss@containered-postgres/harss rss-aggregator-migrations:latest sqlx migrate run
# Run the migration against the host's postgres
docker run --net host --rm -e DATABASE_URL=postgres://harss:harss@localhost/harss rss-aggregator-migrations:latest sqlx migrate run
Using sqlx-cli itself
Requires a rust toolchain
cargo install sqlx-cli --no-default-features --features native-tls,postgres
# Time to take a coffee brake ☕
DATABASE_URL="postgres://rss-aggregator:rss-aggregator@localhost/rss-aggregator" sqlx migrate run