Skip to main content

QueryEngine

Struct QueryEngine 

Source
pub struct QueryEngine { /* private fields */ }
Expand description

Read-only query interface to the storage database.

Implementations§

Source§

impl QueryEngine

Source

pub fn clients(&self, params: &ClientsParams) -> Result<Vec<ClientRow>, Error>

Aggregate client usage across sessions, sorted by total calls descending.

Source§

impl QueryEngine

Source

pub fn logs(&self, params: &LogsParams) -> Result<Vec<LogRow>, Error>

Fetch recent request logs, newest first.

Source

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

Source

pub fn schema(&self, params: &SchemaParams) -> Result<Vec<SchemaRow>, Error>

Fetch all captured schema snapshots, optionally filtered by proxy name and/or MCP method.

Source

pub fn schema_changes( &self, params: &SchemaChangesParams, ) -> Result<Vec<SchemaChangeRow>, Error>

Fetch schema change history, optionally filtered by proxy name and/or MCP method.

Source

pub fn schema_status( &self, upstream_url: &str, ) -> Result<SchemaStatusRow, Error>

Compute the schema status for a given upstream URL.

Source

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).

Source

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

Source

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

Source

pub fn sessions( &self, params: &SessionsParams, ) -> Result<Vec<SessionRow>, Error>

List sessions for a proxy, most recently seen first.

Source§

impl QueryEngine

Source

pub fn slow(&self, params: &SlowParams) -> Result<Vec<LogRow>, Error>

Fetch the slowest requests above a latency threshold, slowest first.

Source

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

Source

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

Source

pub fn store_stats(&self, db_path: &Path) -> Result<StoreStats, Error>

Get database-level statistics.

Source

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.

Source§

impl QueryEngine

Source

pub fn open(db_path: &Path) -> Result<Self, Error>

Open a query connection to the database at the given path.

Runs migrations on open. The writer also migrates on Store::open, but a user who upgrades the binary and runs a read command before restarting the proxy would otherwise hit “no such column” errors against a stale schema. Migrations are idempotent + WAL-safe, so it’s fine for the reader to bump the schema if the writer hasn’t caught up yet.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,