pub struct QueryEngine { /* private fields */ }Expand description
Read-only query interface to the storage database.
Implementations§
Source§impl QueryEngine
impl QueryEngine
Source§impl QueryEngine
impl QueryEngine
Sourcepub fn logs(&self, params: &LogsParams) -> Result<Vec<LogRow>, Error>
pub fn logs(&self, params: &LogsParams) -> Result<Vec<LogRow>, Error>
Fetch recent request logs, newest first.
Sourcepub fn logs_since(
&self,
params: &LogsParams,
after_ts: i64,
) -> Result<Vec<LogRow>, Error>
pub fn logs_since( &self, params: &LogsParams, after_ts: i64, ) -> Result<Vec<LogRow>, Error>
Fetch logs newer than a given timestamp, oldest first.
Used for --follow mode: poll every 500ms with the last seen timestamp.
Source§impl QueryEngine
impl QueryEngine
Sourcepub fn schema(&self, params: &SchemaParams) -> Result<Vec<SchemaRow>, Error>
pub fn schema(&self, params: &SchemaParams) -> Result<Vec<SchemaRow>, Error>
Fetch all captured schema snapshots, optionally filtered by proxy name and/or MCP method.
Sourcepub fn schema_changes(
&self,
params: &SchemaChangesParams,
) -> Result<Vec<SchemaChangeRow>, Error>
pub fn schema_changes( &self, params: &SchemaChangesParams, ) -> Result<Vec<SchemaChangeRow>, Error>
Fetch schema change history, optionally filtered by proxy name and/or MCP method.
Sourcepub fn schema_status(
&self,
upstream_url: &str,
) -> Result<SchemaStatusRow, Error>
pub fn schema_status( &self, upstream_url: &str, ) -> Result<SchemaStatusRow, Error>
Compute the schema status for a given upstream URL.
Sourcepub fn latest_schema_row(
&self,
proxy: &str,
method: &str,
) -> Result<Option<LatestSchemaRow>, Error>
pub fn latest_schema_row( &self, proxy: &str, method: &str, ) -> Result<Option<LatestSchemaRow>, Error>
Fetch the latest persisted schema row for (proxy, method) —
used at proxy startup to hydrate SchemaManager from disk.
Returns None when no row matches. server_schema is an
UPSERT-keyed-by-(proxy, upstream_url, method) table, so the
“latest” is simply the single row per key; we pick by highest
captured_at to be robust against multiple upstream URLs that
share the same proxy name (unlikely today but possible).
Sourcepub fn schema_unused(
&self,
params: &SchemaUnusedParams,
) -> Result<Vec<SchemaToolUsageRow>, Error>
pub fn schema_unused( &self, params: &SchemaUnusedParams, ) -> Result<Vec<SchemaToolUsageRow>, Error>
Cross-reference captured tools/list schema with actual request logs. Returns all listed tools with their usage stats — unused tools have calls = 0.
Source§impl QueryEngine
impl QueryEngine
Sourcepub fn session_detail(
&self,
session_id: &str,
) -> Result<Option<SessionDetail>, Error>
pub fn session_detail( &self, session_id: &str, ) -> Result<Option<SessionDetail>, Error>
Fetch a single session by ID, along with all its request logs.
Returns None if the session doesn’t exist.
Source§impl QueryEngine
impl QueryEngine
Sourcepub fn sessions(
&self,
params: &SessionsParams,
) -> Result<Vec<SessionRow>, Error>
pub fn sessions( &self, params: &SessionsParams, ) -> Result<Vec<SessionRow>, Error>
List sessions for a proxy, most recently seen first.
Source§impl QueryEngine
impl QueryEngine
Sourcepub fn slow(&self, params: &SlowParams) -> Result<Vec<LogRow>, Error>
pub fn slow(&self, params: &SlowParams) -> Result<Vec<LogRow>, Error>
Fetch the slowest requests above a latency threshold, slowest first.
Sourcepub fn slow_since(
&self,
params: &SlowParams,
after_ts: i64,
) -> Result<Vec<LogRow>, Error>
pub fn slow_since( &self, params: &SlowParams, after_ts: i64, ) -> Result<Vec<LogRow>, Error>
Fetch slow calls newer than a given timestamp (for --tail live stream).
Source§impl QueryEngine
impl QueryEngine
Sourcepub fn stats(&self, params: &StatsParams) -> Result<StatsResult, Error>
pub fn stats(&self, params: &StatsParams) -> Result<StatsResult, Error>
Compute per-tool aggregated stats for a proxy within a time window.
Percentiles are computed in Rust (load latency values into a Vec and sort) because SQLite has no native percentile function. This is fine for the expected data volumes (<1M rows per proxy).
Source§impl QueryEngine
impl QueryEngine
Sourcepub fn store_stats(&self, db_path: &Path) -> Result<StoreStats, Error>
pub fn store_stats(&self, db_path: &Path) -> Result<StoreStats, Error>
Get database-level statistics.
Sourcepub fn vacuum(&self, params: &VacuumParams) -> Result<VacuumResult, Error>
pub fn vacuum(&self, params: &VacuumParams) -> Result<VacuumResult, Error>
Delete old requests and orphaned sessions, optionally scoped to one proxy. In dry-run mode, returns counts without deleting.