Commit Graph

159 Commits

Author SHA1 Message Date
Phoebe Goldman c18b291f12 Add additional logging to subscribe route and simplify calling client_connected (#2998)
# Description of Changes

Out-of-band discussions with the BitCraft team brought up questions
about whether it was possible for a rejected client connection to start
an expensive computation like a subscription before their connection was
killed, e.g. by sending a `Subscribe` message along the WebSocket before
`client_connected` had finished returning `Err`.

I don't believe this was actually possible, as `ClientConnection::spawn`
called and awaited `call_identity_connected` before invoking its `actor`
closure, and it was that `actor` which processed `Subscribe` messages.
But it was somewhat difficult to verify that behavior, and so I
re-organized the code so that the outer layer of the `subscribe` handler
obviously had that property without having to step into
`ClientConnection::spawn`.

I also added some additional logging to the subscribe route, including
the `X-Forwarded-For` header in more messages, as the BitCraft team
complained about having difficulty correlating IP addresses with
connections. The log levels remain the same as before, just with
additional information added:

- Successful connections are at `debug` level,
- Rejected connections are at `info` level (these are the ones BitCraft
cares about in this case).
- Failed connections are at `warn`.

As the levels are unchanged, this should not add undesirable log noise.

# API and ABI breaking changes

N/a

# Expected complexity level and risk

3? The `subscribe` route was complex and remains so. I believe this
change simplifies the code and makes the logic more obvious, but
reviewers should take care to verify that the behavior actually is
equivalent as I believe.

# Testing

- [ ] I would like a test deployment of BitCraft to staging or
something, or to include this patch in the next bot test that we do
anyways, just for sanity's sake.
2025-07-29 18:29:04 +00:00
ResuBaka 7fb4df4275 Update tungstenite to get client read performance improvement (#2966)
Co-authored-by: Kim Altintop <kim@eagain.io>
2025-07-24 17:06:43 +00:00
Kim Altintop 09717e97ad Make websocket configurable via config.toml (#2944) 2025-07-16 19:31:07 +00:00
Noa 742303ca49 Bump rust-toolchain to rust 1.88 (#2749)
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2025-07-15 17:39:41 +00:00
Tyler Cloutier 20b087c248 Split datastore into its own crate (#2933) 2025-07-12 21:41:00 +00:00
Kim Altintop b63216aec9 client-api: Rewrite websocket loop (#2906)
Signed-off-by: Kim Altintop <kim@eagain.io>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
2025-07-10 10:50:06 +00:00
joshua-spacetime e4d5c18f3c Wrap websocket flush in timeout (#2908) 2025-07-01 01:41:59 +00:00
joshua-spacetime 28186d8721 Track disconnects initiated by the client (#2893) 2025-06-25 23:28:29 +00:00
joshua-spacetime 718712a8f7 Record the size of a client's outgoing message queue on drop (#2877) 2025-06-18 17:28:55 +00:00
Mazdak Farrokhzad 1318e7e1f5 messages::serialize: take/put buffers from/into a SerializeBufferPool (#2823)
Co-authored-by: Noa <coolreader18@gmail.com>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
2025-06-16 16:44:57 +00:00
Phoebe Goldman 1e3e8db9bc Database-specific Timestamp route (#2864) 2025-06-13 20:23:30 +00:00
Tyler Cloutier 013e268eb5 Fixed rename by using put instead of post (#2764)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2025-06-12 17:05:02 +00:00
Kim Altintop 4974676ce8 client-api: Don't debug-print dropped outgoing Ws messages at info (#2819) 2025-06-11 09:23:41 +00:00
Phoebe Goldman 0866fd39d5 Add an HTTP route to get the current Timestamp (#2850) 2025-06-09 17:26:25 +00:00
Viktor Szépe f6da9e1f5f Fix typos (#2812)
Signed-off-by: Viktor Szépe <viktor@szepe.net>
2025-06-04 16:33:32 +00:00
Phoebe Goldman ac187906ad Per-database incoming and outgoing queue length metrics (#2773) 2025-05-28 16:17:48 +00:00
Kim Altintop c729c2100d Reintroduce replication factor parameter (#2718) 2025-05-19 06:55:09 +00:00
Phoebe Goldman 03a56e11a2 Check validity of modules before control DB modifications during initial publish (#2580) 2025-04-14 15:56:23 +00:00
Noa 483a9488e2 Update rand (#2568) 2025-04-11 17:39:41 +00:00
Noa 68d23d4c25 Remove spacetimedb-core as a dep of cli (#2244) 2025-04-09 19:37:44 +00:00
Noa 649ce34b01 Update tungstenite to 0.26 (#2539) 2025-04-02 18:09:13 +00:00
Mazdak Farrokhzad eb380e6a18 Repair transactionality of st_client removals after disconnect (#2446)
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
2025-04-01 14:04:16 +00:00
Jeffrey Dallatezza 64aef29d3c Add endpoints for heap profiling (#2517)
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2025-03-31 18:12:31 +00:00
Mario Montoya 98395ca530 Print back the # of rows affected (ins, upd, del) with timings (#2462)
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2025-03-28 16:57:23 +00:00
Mario Montoya f9f38543c8 Add readmes to all implementation crates specifying that they do no offer stable interfaces (#2320) 2025-03-06 19:50:17 +00:00
Kim Altintop e32b00420b set names atomic (#2325)
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: Noa <coolreader18@gmail.com>
2025-02-28 21:59:23 +00:00
Jeffrey Dallatezza 909040f716 hacky auth check for database creation. (#2308) 2025-02-26 16:52:30 +00:00
Kim Altintop 55cd1e4587 sdk: Client ping on idle connections (#2309)
Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
2025-02-26 16:22:42 +00:00
Tyler Cloutier d147dff5b1 Added in a SQL execution time calculation (#2297) 2025-02-25 21:44:21 +00:00
Noa f307d531a5 Fixup comment for SpacetimeCreds (#2250) 2025-02-11 20:14:32 +00:00
Noa e76ba2bd35 Only support bearer auth (#2248) 2025-02-11 18:51:05 +00:00
Noa 6a8375260f Refactor HTTP api to better adhere to REST guidelines (real) (#2243) 2025-02-11 02:59:45 +00:00
Noa cf6822541f Remove janky schema from http API (#2181) 2025-02-11 00:56:07 +00:00
Phoebe Goldman aedc601145 Rename Address to ConnectionId (#2220)
Signed-off-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: James Gilles <jameshgilles@gmail.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2025-02-10 00:40:16 +00:00
Piotr Sarnacki 00c6aa0baf Add /health endpoint (#1989)
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2025-02-08 19:58:14 +00:00
joshua-spacetime 6aa75bd0eb Track compute metrics for sql dml with new engine (#2190) 2025-01-31 17:59:33 +00:00
Noa 293aebaef9 Bump to Rust 1.84 (#2001) 2025-01-28 23:11:29 +00:00
Noa 7c6af12b84 Use actual types for api responses, not ad-hoc json!() objects (#1931) 2025-01-21 03:13:22 +00:00
Noa cf6ac18eaf Lookup lifecycle reducers by lifecycle flag, not by name (#2132) 2025-01-17 23:21:52 +00:00
Noa c24042609e Split binaries (#2011) 2025-01-15 18:45:14 +00:00
Zeke Foppa 43ad8be2b0 CLI - Remove deprecated use of the --project-path flag (#915)
Co-authored-by: Zeke Foppa <github.com/bfops>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2024-12-30 18:41:44 +00:00
Kim Altintop 125ab58388 commitlog: Fix set_epoch (#2005) 2024-11-21 13:34:10 +00:00
Shubham Mishra 9c64d1fbd1 Durability Provider (#1864)
Signed-off-by: Shubham Mishra <shubham@clockworklabs.io>
Co-authored-by: Kim Altintop <kim@eagain.io>
2024-11-19 09:06:52 +00:00
Jeffrey Dallatezza cccadd10ee Clean up auth related code with traits, and reuse existing key generation code. (#1988) 2024-11-12 21:22:20 +00:00
Noa f136670420 Directory structure impl (#1879)
Co-authored-by: Jeffrey Dallatezza <jeffreydallatezza@gmail.com>
2024-11-12 04:24:43 +00:00
james gilles a24a206c28 Be more careful about endianness with Identity and Address (#1926)
Co-authored-by: Puru Vijay <awesomepuruvj@gmail.com>
2024-11-05 20:04:05 +00:00
Mazdak Farrokhzad ac0053caab Websocket API: Light transaction updates & NoSuccessNotify (#1812)
Signed-off-by: Mazdak Farrokhzad <twingoow@gmail.com>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
2024-11-04 15:59:11 +00:00
Mario Montoya a6a6c4f08f Put ExecutionContext inside the Tx context (#1876)
Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
2024-10-29 16:24:06 +00:00
Jeffrey Dallatezza 25ea57db50 Fix the endpoint for short-lived tokens (#1907)
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
2024-10-25 19:56:32 +00:00
Tyler Cloutier fa960b3be9 Small naming fixes. Fixes database identity creation. (#1892) 2024-10-24 23:02:21 +00:00