Make the README's storage, formats, TLS and metrics match the code (closes #74)
check / check (push) Successful in 10m10s
check / check (push) Successful in 10m10s
"Storage" names the cache directories pixa uses (cache/sources, cache/metadata, cache/variants) and how files are named in each; the schema comments name the same paths, and the output_content comment says the table is not written. Routes and the signature section give one list of output formats, jpg and original included, and say how those two are signed. The TLS sentence names allow_http as its exception. "Metrics" says what exists: generic HTTP and Go runtime metrics at /metrics, measured and served only when the metrics username and password are set. Model: opus-5-5
This commit was merged in pull request #172.
This commit is contained in:
@@ -71,13 +71,17 @@ prevent abuse, and allowlisted source hosts for open access.
|
||||
### Storage
|
||||
|
||||
- **Source content**:
|
||||
`<statedir>/cache/src-content/<ab>/<cd>/<sha256 of source content>`
|
||||
`<state_dir>/cache/sources/<ab>/<cd>/<sha256 of source content>`
|
||||
- **Source metadata**:
|
||||
`<statedir>/cache/src-metadata/<hostname>/<sha256 of path>.json`
|
||||
(fetch time, original headers, request, content hash)
|
||||
- **Database**: `<statedir>/state.sqlite3` (SQLite)
|
||||
- **Output documents**:
|
||||
`<statedir>/cache/dst-content/<ab>/<cd>/<sha256 of output content>`
|
||||
`<state_dir>/cache/metadata/<hostname>/<sha256 of path and query>.json`
|
||||
(host, path and query, content hash, upstream status and headers, fetch time)
|
||||
- **Database**: `<state_dir>/state.sqlite3` (SQLite)
|
||||
- **Transformed images**:
|
||||
`<state_dir>/cache/variants/<ab>/<cd>/<sha256 of host, path, query, size, format, quality and fit>`,
|
||||
each with a `.meta` file beside it holding its content type
|
||||
|
||||
`<ab>` and `<cd>` are the first and second pairs of characters of the file's
|
||||
name.
|
||||
|
||||
Multiple source paths may reference the same content blob; the
|
||||
database tracks references rather than using filesystem refcounting.
|
||||
@@ -92,12 +96,15 @@ the metadata file stored beside it.
|
||||
/v1/image/<host>/<path>/<size>.<format>?sig=<signature>&exp=<expiration>
|
||||
```
|
||||
|
||||
Images are only fetched from origins using TLS with valid certificates.
|
||||
Images are only fetched from origins using TLS with valid certificates, unless
|
||||
`allow_http` is set: then pixa fetches every image over plain HTTP, which is for
|
||||
testing only.
|
||||
|
||||
A request whose query string cannot be decoded, or gives any parameter more
|
||||
than once, is refused with 400.
|
||||
|
||||
- `<format>`: one of `orig`, `png`, `jpeg`, `webp`
|
||||
- `<format>`: one of `orig` (or `original`), `jpeg` (or `jpg`), `png`, `webp`,
|
||||
`avif`, `gif`
|
||||
- `<size>`: `orig` or `<width>x<height>` (e.g. `800x600`)
|
||||
|
||||
An image is served with `Cache-Control: public, max-age=<seconds>, immutable`.
|
||||
@@ -173,7 +180,8 @@ Where:
|
||||
- `query` — source query string, empty string if none
|
||||
- `width` — requested width in pixels, `0` for original
|
||||
- `height` — requested height in pixels, `0` for original
|
||||
- `format` — output format (jpeg, png, webp, avif, gif, orig)
|
||||
- `format` — output format, one of those listed under Routes, with `original`
|
||||
signed as `orig` and `jpg` as `jpeg`
|
||||
- `expiration` — the URL's `exp` query parameter, the Unix timestamp when
|
||||
the signature expires; a request whose `exp` is not a whole number, an
|
||||
empty `exp=` included, is refused with 400
|
||||
@@ -330,7 +338,10 @@ See `config.example.yml` for all options with defaults.
|
||||
- **Image processing**: govips (CGO wrapper for libvips)
|
||||
- **Database**: SQLite via modernc.org/sqlite
|
||||
- **Static assets**: embedded via `//go:embed`
|
||||
- **Metrics**: Prometheus
|
||||
- **Metrics**: Prometheus, at `/metrics`: generic HTTP request metrics
|
||||
(duration, response size, requests in flight) and the Go runtime and process
|
||||
metrics; requests are measured and `/metrics` is served only when
|
||||
`metrics.username` and `metrics.password` are set
|
||||
- **Logging**: stdlib slog
|
||||
|
||||
## Entrypoints
|
||||
|
||||
Reference in New Issue
Block a user