Skip to main content

Crate waratah_api

Crate waratah_api 

Source
Expand description

RDF4J-compatible HTTP facade over an in-process ComputeNode.

The router mounts /rdf4j, /waratah, /cors_proxy, the AI services (discovery + LLM egress proxy under /waratah/ai, /waratah/repositories/{id}/ai-context), the pre-built grevillea console at /, and — when the notebook service is enabled — the jupyter reverse proxy at /jupyter (waratah_notebook). GET/HEAD paths outside those API prefixes return the SPA index.html, except /assets/…, /sw.js, and /favicon.ico, which are exact files from the embedded dist-console. /download/… is not served.

The MVP mounts under /rdf4j and implements protocol version, SPARQL SELECT / ASK / CONSTRUCT / DESCRIBE on repository main, GET /rdf4j/repositories (lists main), repository size, namespace list, and a Waratah-specific .../explain endpoint that returns Jena SSE, SPARQL, or a row-estimate plan tree (format, pretty query params). Remaining RDF4J paths return 501 Not Implemented. Serialization of SPARQL Results uses Oxigraph’s sparesults crate; graph results use oxrdfio (Turtle / N-Triples / RDF/XML).

SELECT and ASK responses default to text/csv when the client sends no usable Accept (absent, *, */*); CONSTRUCT / DESCRIBE default to Turtle, and the repository / namespace listings default to JSON. The whole router compresses response bodies per the client’s Accept-Encoding — brotli at level 4 or gzip at level 5, brotli winning equal-weight ties — and marks compressed responses with Content-Encoding and Vary: Accept-Encoding. Buffered bodies under 256 bytes stay identity, which keeps every ASK boolean serialization uncompressed (waratah_api/src/compress.rs).

Staging ingest (list / upload / snippet / ingest) is a Waratah-specific API under /waratah/repositories/{id}/ingest, not RDF4J. Files are staged under {ingest_dir}/{repository_id} (repository is main). The same /waratah prefix serves GET /waratah/health (this process), GET /waratah/cluster (coordinator snapshot of computes + storage), and GET /waratah/repositories/{id}/queries — the read-only published query library behind --queries-dir (or the inline --load-demo samples; waratah_api/src/query_library.rs). /cors_proxy/{compute_id}/rdf4j|waratah/… streams that request to a cluster member’s configured HTTP origin. There are no browser CORS headers.

Structs§

AiConfig
Fully resolved AI configuration (what AppState serves from).
AiService
Resolved AI service state held by crate::state::AppState: the configuration plus one lazily built HTTP client.
AiToml
The {config-dir}/ai.toml document.
AiUpstream
One resolved egress upstream.
AppState
State cloned into every RDF4J / Waratah HTTP handler.
CorsProxyTarget
One static cluster member /cors_proxy may forward HTTP to.
QueryDebug
SPARQL arrival / completion / client-error logger.
QuerySpan
Token for one debug-traced SPARQL request.
RepositoryCatalog
Catalog of repositories exposed by this RDF4J server.
RepositoryState
Per-repository metadata held at the HTTP edge.
ServerQuery
One published query, exactly the wire shape of GET /waratah/repositories/{id}/queries entries.

Enums§

AiConfigError
Errors raised while resolving ai.toml into an AiConfig.
ApiError
Failure translating an RDF4J request into a compute call or wire format.
QueryLibrary
Where a repository’s query library comes from.
QueryLibraryError
Failure resolving a configured library. “Not configured at all” is a separate crate::error::ApiError::QueryLibraryNotConfigured and maps to 501; these two map to 404 / 500.

Constants§

MAIN_REPOSITORY_ID
Default repository ID served by the MVP (on-disk layout and HTTP URLs). MVP / default repository id used in on-disk paths and HTTP URLs.
PROTOCOL_VERSION
RDF4J protocol version advertised by GET /rdf4j/protocol.

Traits§

ComputeBackend
Operations the RDF4J facade and Waratah ingest API need from compute.

Functions§

bind_http
Bind addr for the RDF4J HTTP facade, returning the listener before any request is served.
console_is_stub
Whether this binary embedded the build-time stub instead of a grevillea dist-console.
console_missing_worker
Whether the embedded console has no sw.js.
negotiate_graph_format
Pick Turtle, N-Triples, TriG, N-Quads, RDF/XML, or JSON-LD from an Accept header; default Turtle.
negotiate_results_format
Pick JSON, XML, CSV, or TSV from an Accept header; default JSON.
negotiate_results_format_with_default
Like negotiate_results_format, but absent / wildcard Accept values (*, */*) fall back to default instead of JSON.
router
Build the HTTP router for state.
router_for_compute
Convenience: serve RDF4J over a live ComputeNode.
serialize_query_results
Serialize SELECT bindings, an ASK boolean, or a CONSTRUCT/DESCRIBE graph.
serialize_query_results_with_default
Like serialize_query_results, but solutions and boolean results fall back to solutions_default for absent / wildcard Accept values.
serve
Bind addr and serve until the listener fails.
serve_bound_with_shutdown
Serve the RDF4J HTTP facade on an already-bound listener until shutdown resolves or the listener fails.
serve_compute
Bind addr and serve a live ComputeNode.
serve_with_shutdown
Bind addr and serve until shutdown resolves or the listener fails.