Expand description
Portable gateway-domain contracts for Athena.
This crate intentionally stays free of Actix and runtime registry concerns.
It owns the reusable request/response DTOs and normalization helpers that
power /gateway/* routes across adapters, SDKs, deferred queue payloads,
and future server splits.
The current scope covers:
- gateway operation kinds,
- fetch/insert/update/delete/rpc request bodies,
- delete-side resource-ID lookup planning and explicit column normalization,
- deferred gateway queue payloads,
- gateway authorization right naming and wildcard matching helpers,
- fetch request parsing and post-processing helpers,
- fetch body preprocessing for legacy and structured gateway fetch requests,
- legacy
GET /datacompatibility planning and cache-key derivation, - fetch singleflight coordination for cache-equivalent gateway reads,
- metadata-aware fetch condition builders and stats-rollup type fallbacks,
- PostgREST compatibility parsing and filter conversion helpers,
- RPC compatibility parsing for legacy
/rpc/{function_name}routes, - gateway resource-ID fallback resolution heuristics for insert/delete/upsert paths,
- row-response metadata,
- schema/table normalization helpers for gateway requests,
/gateway/queryrequest parsing, normalization, and bounded compatibility planning,/gateway/updaterequest planning, condition coercion, and derived write-right helpers,/gateway/deleterequest planning, resource-ID lookup planning, and derived delete-right helpers,- relation-select compatibility rewrite helpers for bounded
/gateway/querySQL-to-structured-fetch translation, - structured-fetch SQL compilation, metadata loading, and execution helpers.
Structs§
- Gateway
ApiRequest - Unified API-level gateway request wrapper.
- Gateway
Deferred Request - Canonical deferred queue payload for gateway operations.
- Gateway
Delete Request - Canonical
/gateway/deleterequest shape. - Gateway
Delete Request Plan - Portable delete request plan derived from the canonical
/gateway/deletepayload. - Gateway
Delete Resource IdPlan - Portable delete-side resource ID lookup plan.
- Gateway
Error Data - Normalized gateway error response data.
- Gateway
Error Envelope - Normalized gateway error response envelope.
- Gateway
Fetch Body Plan - Parsed fetch-body plan used by the runtime adapter to authorize and execute a read.
- Gateway
Fetch Condition Error - Structured validation error returned while parsing fetch request conditions.
- Gateway
Fetch Request - Canonical
/gateway/fetchrequest shape. - Gateway
Fetch Singleflight - Stateful coordinator that deduplicates concurrent gateway fetches per cache key.
- Gateway
GetFetch Compatibility Plan - Query-parameter-derived plan for the legacy
GET /datacompatibility route. - Gateway
InFlight Fetch - Tracks a single in-flight fetch result and wakes followers when it completes.
- Gateway
Insert Request - Canonical
/gateway/insertrequest shape. - Gateway
Query Compatibility Plan - Structured rewrite plan for relation-select compatibility queries.
- Gateway
Query Request Plan - Portable request plan derived from a canonical
/gateway/querypayload. - Gateway
Relation Select Rewrite - Structured-fetch rewrite result produced from a bounded compatibility SQL query.
- Gateway
Relation Select Table Ref - Normalized table selector derived from a relation-select compatibility query.
- Gateway
Request Condition - Simple equality filter used by gateway CRUD requests.
- Gateway
Rows Meta - Shared response metadata for query-like gateway responses.
- Gateway
Rows Response - Shared row-based gateway success response.
- Gateway
RpcFilter - Canonical RPC filter clause.
- Gateway
RpcOrder - Canonical RPC ordering clause.
- Gateway
RpcRequest - Canonical
/gateway/rpcrequest shape. - Gateway
SqlExecution Request - Canonical
/query/sql+/gateway/sqlrequest shape. - Gateway
SqlRequest - Canonical
/gateway/queryrequest shape. - Gateway
Update Request - Canonical
/gateway/updaterequest shape. - Gateway
Update Request Plan - Portable request plan derived from a canonical
/gateway/updatepayload. - Order
Spec - Parsed
orderquery parameter. - Post
Processing Config - Gateway fetch post-processing configuration parsed from request bodies.
- Postgrest
Filter - One parsed PostgREST filter expression.
- Postgrest
Query - Normalized PostgREST query components derived from a request URL.
- Sort
Options - Sort options for gateway fetch requests.
- Structured
Column Field - Column projection inside a structured fetch query.
- Structured
Filter - Structured filter clause.
- Structured
Gateway Fetch Plan - Parsed structured gateway fetch request plus the normalized root selector.
- Structured
Order By - Structured ordering clause.
- Structured
Relation Field - Nested relation projection inside a structured fetch query.
- Structured
Select Query - Parsed structured fetch query.
Enums§
- Aggregation
Strategy - Supported aggregation strategies for grouped fetch results.
- Gateway
ApiRequest Payload - API-level operation variants for normalized gateway requests.
- Gateway
Delete Request Plan Error - Validation errors for portable
/gateway/deleteplanning. - Gateway
Fetch Body Plan Error - Body-preprocessing validation errors for gateway fetch request parsing.
- Gateway
Fetch Singleflight Role - Role assigned when a caller acquires a singleflight slot for a cache key.
- Gateway
GetFetch Compatibility Error - Validation errors for legacy
GET /dataquery parsing. - Gateway
Operation Kind - Domain-owned operation kinds for gateway handlers.
- Gateway
Query Request Parse Error - Validation errors for parsing
/gateway/queryrequest bodies. - Gateway
Query Request Plan Error - Validation errors for portable
/gateway/queryplanning. - Gateway
RpcFilter Operator - Supported filter operators for RPC request pushdown.
- Gateway
SqlExecution Mode - Portable execution modes accepted by gateway SQL request payloads.
- Gateway
Update Request Plan Error - Validation errors for portable
/gateway/updateplanning. - Postgrest
Filter Operator - PostgREST filter operators supported by the legacy REST shim.
- Structured
Filter Operator - Supported filter operators in structured fetch requests.
- Structured
Join Kind - Join behavior for nested structured relation selections.
- Structured
Select Field - Field projection entry in a structured fetch query.
- Structured
Select Operation - Structured-fetch operation kinds currently accepted by the public contract.
- Structured
Sort Direction - Supported sort directions in structured fetch requests.
- Time
Granularity - Granularity options used for grouping timestamp rows during post-processing.
Constants§
- GATEWAY_
DEFERRED_ KIND_ DELETE - GATEWAY_
DEFERRED_ KIND_ FETCH - GATEWAY_
DEFERRED_ KIND_ INSERT - GATEWAY_
DEFERRED_ KIND_ QUERY - GATEWAY_
DEFERRED_ KIND_ RPC - GATEWAY_
DEFERRED_ KIND_ UPDATE - GATEWAY_
ERROR_ CODE_ INTERNAL_ ERROR - GATEWAY_
ERROR_ CODE_ SERVICE_ UNAVAILABLE - GATEWAY_
ERROR_ CODE_ VALIDATION_ FAILED
Functions§
- apply_
post_ processing - Applies grouping and aggregation rules to fetched gateway rows.
- build_
fetch_ hashed_ cache_ key - Builds the hashed cache key used for POST gateway fetch requests.
- build_
fetch_ hashed_ cache_ key_ legacy8 - Builds the legacy 8-character hashed cache key used during fetch cache cutovers.
- build_
gateway_ delete_ request_ plan - Builds the portable
/gateway/deleterequest plan from the canonical request payload. - build_
gateway_ fetch_ body_ plan - Builds the portable request-domain plan for a fetch body.
- build_
gateway_ get_ fetch_ compatibility_ plan - Builds the compatibility fetch plan for
GET /data. - build_
gateway_ query_ request_ plan - Builds the portable
/gateway/queryexecution plan. - build_
gateway_ update_ request_ plan - Builds the portable
/gateway/updateexecution plan from a parsed JSON body. - build_
structured_ fetch_ cache_ key - Builds the structured fetch cache key from the normalized plan and compiled SQL.
- build_
structured_ fetch_ plan - Builds a parsed structured fetch plan when the request body uses the structured read contract.
- camel_
to_ snake_ case - Converts
camelCaseorPascalCaseidentifiers tosnake_case. - coerce_
room_ id_ eq_ value - Coerces
eq_valueto a JSON number when the column isroom_id/roomId. - convert_
postgrest_ filter_ to_ condition - Converts one parsed PostgREST filter into an Athena query condition.
- convert_
postgrest_ filters_ to_ conditions - Converts parsed PostgREST filters into Athena query-builder conditions.
- convert_
postgrest_ or_ filter_ groups_ to_ conditions - Converts OR filter groups into Athena query-builder condition groups.
- delete_
request_ required_ right - Derives the table-name-based delete right hint for
/gateway/delete. - delete_
right_ for_ resource - Required delete right for a specific resource or the gateway-wide fallback.
- execute_
structured_ fetch_ sql - Executes compiled structured fetch SQL against the selected Postgres pool.
- extract_
update_ payload - Extracts normalized update payload from gateway body.
- find_
closest_ uuid_ column - Finds the UUID column with the smallest Levenshtein distance to
table_name. - get_
resource_ id_ key_ with_ uuid_ loader - Resolves the fallback resource-ID column for
table_nameusing an injected UUID-column loader. - merge_
column_ types_ with_ stats_ fallback - Merges
resolve_where_column_typesoutput with static descriptors forclient_statistics/client_table_statisticsso string JSON filter values get correct cast handling and avoid Postgres42883. - missing_
required_ rights - Returns the subset of
required_rightsnot covered bygranted_rights. - normalize_
column_ name - Normalizes a gateway column name, optionally forcing
snake_case. - normalize_
delete_ resource_ id_ column_ name - Normalizes and validates an explicit delete
resource_idcolumn selector. - normalize_
delete_ resource_ id_ lookup_ table - Normalizes the table name used by metadata-backed delete resource-ID lookup.
- normalize_
gateway_ schema_ name - Validates and normalizes an optional schema name.
- parse_
columns_ from_ body - Parses
columnsfrom gateway body, supporting both CSV and JSON arrays. - parse_
conditions_ from_ body - Parses request conditions from JSON body.
- parse_
gateway_ fetch_ conditions - Parses
conditionsfrom a gateway fetch payload. - parse_
gateway_ query_ request_ body - Parses the canonical
/gateway/queryrequest payload from raw bytes. - parse_
postgrest_ query - Parses a Supabase/PostgREST query into a normalized representation that can be mapped to Athena/Postgres operations.
- parse_
room_ id_ value - Parses
eq_valuefor aroom_idcondition. - parse_
rpc_ argument_ value - Parses a scalar or array literal from the compatibility RPC grammar.
- parse_
rpc_ filter_ expression - Parses a compact filter expression like
eq.nameorin.(a,b). - parse_
rpc_ order - Parses a compact
column.asc/column.descorder clause. - parse_
sort_ options_ from_ body - Parses optional
sortByorsort_byfrom a fetch request body. - parse_
uuid_ columns_ from_ schema_ rows - Parses Scylla
system_schema.columnsrows into UUID column names. - plan_
delete_ resource_ id_ resolution - Builds the portable delete resource-ID resolution plan for a request.
- qualify_
gateway_ table_ name - Builds the normalized
schema.tabletarget used by downstream SQL builders. - query_
right - Right required for
/gateway/query. - read_
right_ for_ resource - Required read right for a specific resource or the gateway-wide fallback.
- render_
structured_ fetch_ sql - Loads relation metadata and compiles SQL for a parsed structured fetch plan.
- resolve_
where_ column_ types - Resolves
information_schema.columnstypes fortable_name, honoring the gateway’s optionalschema.tableprefix flag. - right_
matches - Returns true when
grantedsatisfiesrequired, including wildcard forms. - rpc_
request_ from_ get_ compat - Parses the legacy GET
/rpc/{function_name}query string into a canonical RPC request. - rpc_
request_ from_ post_ compat - Parses the legacy POST
/rpc/{function_name}body into a canonical RPC request. - rpc_
right - Right required for
/gateway/rpc. - schema_
name_ from_ body - Reads either
schema_nameor the compatibility aliasschemafrom a request body. - storage_
proxy_ right - Right required for
/storage/*proxy operations. - to_
query_ conditions - Converts request conditions into Postgres query conditions.
- to_
query_ conditions_ with_ types - Like
to_query_conditions, but stamps a Postgres placeholder cast on each condition based on the target column’s type descriptor (frominformation_schema.columns). - try_
rewrite_ relation_ select_ query - Rewrites a bounded relation-select compatibility query into a structured-fetch request body.
- typesense_
proxy_ right - Right required for
/typesense/*proxy/search operations. - write_
right_ for_ resource - Required write right for a specific resource or the gateway-wide fallback.
Type Aliases§
- Gateway
Fetch Rows Result - Shared fetch result shape propagated between singleflight leader/follower tasks.
- Request
Condition - Internal representation of a simple equality filter provided by gateway requests.