fakecloud_timestream/lib.rs
1//! Amazon Timestream (`timestream`) awsJson1_0 service for fakecloud.
2//!
3//! One crate serves BOTH the Timestream **Write** and Timestream **Query**
4//! SDK clients. AWS ships them as two separate SDK clients
5//! (`aws-sdk-timestreamwrite` / `aws-sdk-timestreamquery`), but both share the
6//! same service family and the SAME awsJson1_0 target prefix
7//! `Timestream_20181101.<Operation>`, so fakecloud routes both to this single
8//! handler over a shared, account-partitioned state store: databases and
9//! tables are created on the write side and read back by the query side.
10//!
11//! 30 distinct operations (19 write + 15 query, with `DescribeEndpoints`,
12//! `ListTagsForResource`, `TagResource`, and `UntagResource` shared):
13//!
14//! * **Databases** -- `CreateDatabase` mints
15//! `arn:aws:timestream:<region>:<account>:database/<name>` and stores the
16//! optional `KmsKeyId`, `TableCount`, `CreationTime`; `DescribeDatabase` /
17//! `ListDatabases` / `UpdateDatabase` / `DeleteDatabase` (deleting a database
18//! that still holds tables is a `ValidationException`).
19//! * **Tables** -- `CreateTable` under a database, ARN
20//! `.../database/<db>/table/<name>`, `RetentionProperties`,
21//! `MagneticStoreWriteProperties`, and `Schema` (composite partition key)
22//! echoed back; status `ACTIVE`; `Describe` / `List` (filtered by
23//! `DatabaseName`) / `Update` / `Delete`.
24//! * **Ingestion** -- `WriteRecords` validates each record (dimensions,
25//! measure name/value/type, time/unit, version) against the table, merges
26//! `CommonAttributes`, stores the points in a bounded in-memory buffer so
27//! they are queryable, and returns `RecordsIngested`. Malformed records come
28//! back as `RejectedRecords` inside a `RejectedRecordsException`.
29//! * **Query** -- `Query` runs a real, bounded SQL handler over the ingested
30//! points (see "Honest gap" below), `PrepareQuery` returns `ColumnInfo` +
31//! `Parameters`, `CancelQuery` tears down an in-flight query id. Round-trips
32//! a `NextToken`.
33//! * **Scheduled queries** -- full CRUD (`Create` / `Describe` / `List` /
34//! `Update` / `Delete`) plus `ExecuteScheduledQuery`, state persisted.
35//! * **Batch load** -- `CreateBatchLoadTask` / `Describe` / `List` / `Resume`.
36//! * **Account settings** -- `DescribeAccountSettings` / `UpdateAccountSettings`
37//! (`MaxQueryTCU`, `QueryPricingModel`).
38//! * **Endpoint discovery** -- `DescribeEndpoints` returns an `Endpoints` list
39//! whose `Address` points back at the fakecloud host serving the request
40//! (derived from the `Host` header) with a large `CachePeriodInMinutes`, so a
41//! real SDK's discovery step resolves back to fakecloud.
42//! * **Tagging** -- ARN-keyed `TagResource` / `UntagResource` /
43//! `ListTagsForResource`.
44//!
45//! Every operation runs model-driven input validation first (required / enum /
46//! range), then real, account-partitioned, persisted behavior.
47//!
48//! Honest gap -- the query SQL subset: a faithful Timestream SQL engine (the
49//! full Trino-derived time-series dialect) is out of scope. [`query`] implements
50//! a real, bounded interpreter for the shapes the SDK/e2e/conformance exercise:
51//! `SELECT * FROM "db"."table"`, `SELECT COUNT(*) FROM "db"."table"`, an
52//! optional `WHERE time > ago(<n><unit>)` / `WHERE time <op> <literal>` time
53//! filter, `ORDER BY time [ASC|DESC]`, and `LIMIT <n>`. Ingested points come
54//! back as rows with AWS-shaped `ColumnInfo`/`Datum` typing (one column per
55//! dimension, `measure_name`, `measure_value::<type>`, `time`). Query shapes
56//! beyond this subset return a well-formed `ValidationException` naming the
57//! unsupported construct rather than a wrong or empty success. Endpoint
58//! discovery's optional auto-mode in the AWS SDK forces `https://<address>`, so
59//! the e2e drives the default (non-discovery) client pinned to fakecloud and
60//! calls `DescribeEndpoints` explicitly to prove the host echo.
61
62pub mod persistence;
63pub mod query;
64pub mod service;
65pub mod shared;
66pub mod state;
67mod validate;
68
69pub use service::{TimestreamService, TIMESTREAM_ACTIONS};
70pub use state::{
71 SharedTimestreamState, TimestreamData, TimestreamSnapshot, TIMESTREAM_SNAPSHOT_SCHEMA_VERSION,
72};