Skip to main content

Crate perfgate_server

Crate perfgate_server 

Source
Expand description

REST API server for centralized baseline management.

This crate provides a REST API server for storing and managing performance baselines. It supports multiple storage backends (in-memory, SQLite, PostgreSQL) and includes authentication via API keys.

Part of the perfgate workspace.

§Features

  • Multi-tenancy: Projects/namespaces for isolation
  • Version history: Track baseline versions over time
  • Rich metadata: Git refs, tags, custom metadata
  • Access control: Role-based permissions (Viewer, Contributor, Promoter, Admin)
  • Multiple backends: In-memory, SQLite, PostgreSQL (planned)

§Quick Start

use perfgate_server::{ServerConfig, StorageBackend, run_server};

#[tokio::main]
async fn main() {
    let config = ServerConfig::new()
        .bind("0.0.0.0:8080").unwrap()
        .storage_backend(StorageBackend::Sqlite)
        .sqlite_path("perfgate.db");

    run_server(config).await.unwrap();
}

§API Endpoints

MethodPathDescription
POST/projects/{project}/baselinesUpload a baseline
GET/projects/{project}/baselines/{benchmark}/latestGet latest baseline
GET/projects/{project}/baselines/{benchmark}/versions/{version}Get specific version
GET/projects/{project}/baselinesList baselines
DELETE/projects/{project}/baselines/{benchmark}/versions/{version}Delete baseline
POST/projects/{project}/baselines/{benchmark}/promotePromote version
GET/auditList audit events (admin only)
GET/healthHealth check
GET/metricsPrometheus metrics

Re-exports§

pub use auth::ApiKeyStore;
pub use auth::AuthContext;
pub use auth::AuthState;
pub use auth::JwtConfig;
pub use error::ConfigError;
pub use error::StoreError;
pub use oidc::OidcConfig;
pub use oidc::OidcProvider;
pub use oidc::OidcProviderType;
pub use oidc::OidcRegistry;
pub use server::AppState;
pub use server::PostgresPoolConfig;
pub use server::ServerConfig;
pub use server::StorageBackend;
pub use server::run_server;
pub use storage::AuditStore;
pub use storage::BaselineStore;
pub use storage::FleetStore;
pub use storage::InMemoryFleetStore;
pub use storage::InMemoryKeyStore;
pub use storage::InMemoryStore;
pub use storage::KeyRecord;
pub use storage::KeyStore;
pub use storage::SqliteKeyStore;
pub use storage::SqliteStore;
pub use storage::StorageHealth;
pub use models::*;

Modules§

auth
Authentication and authorization middleware.
cleanup
Background artifact cleanup for retention policy enforcement.
error
Error types for the perfgate server.
handlers
Re-export all handlers for use in the server.
metrics
Prometheus metrics middleware and endpoint.
models
Data models for the perfgate baseline service.
oidc
OIDC authentication support for perfgate-server.
server
Server configuration and bootstrap.
storage
Storage trait and implementations for baseline persistence.

Structs§

ApiKey
Represents an authenticated API key.
JwtClaims
JWT claims accepted by the server.

Enums§

AuthError
Role
Role-based access control.
Scope
Permission scope for API operations.

Constants§

VERSION
Server version string.