perf(api-server): batch route tracking through local outbox

This commit is contained in:
kdletters
2026-05-19 01:47:13 +08:00
parent 8038b6a6ee
commit 05a0f34722
23 changed files with 1131 additions and 23 deletions

View File

@@ -585,6 +585,35 @@ impl SpacetimeClient {
.await
}
pub async fn record_tracking_events(
&self,
events: Vec<module_runtime::RuntimeTrackingEventInput>,
) -> Result<u32, SpacetimeClientError> {
if events.is_empty() {
return Ok(0);
}
let procedure_inputs = events
.into_iter()
.map(crate::module_bindings::RuntimeTrackingEventInput::from)
.collect::<Vec<_>>();
self.call_after_connect(
"record_tracking_events_and_return",
move |connection, sender| {
connection
.procedures()
.record_tracking_events_and_return_then(procedure_inputs, move |_, result| {
let mapped = result
.map_err(SpacetimeClientError::from_sdk_error)
.and_then(map_runtime_tracking_event_batch_procedure_result);
send_once(&sender, mapped);
});
},
)
.await
}
pub async fn get_profile_task_center(
&self,
user_id: String,