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, JWT, and OIDC mappings.

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

§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/api/v1/projects/{project}/baselinesUpload a baseline
GET/api/v1/projects/{project}/baselines/{benchmark}/latestGet latest baseline
GET/api/v1/projects/{project}/baselines/{benchmark}/versions/{version}Get specific version
GET/api/v1/projects/{project}/baselinesList baselines
DELETE/api/v1/projects/{project}/baselines/{benchmark}/versions/{version}Delete baseline
POST/api/v1/projects/{project}/baselines/{benchmark}/promotePromote version
POST/api/v1/projects/{project}/decisionsUpload a performance decision receipt
GET/api/v1/projects/{project}/decisions/latestGet latest performance decision
GET/api/v1/projects/{project}/decisionsList performance decisions
POST/api/v1/projects/{project}/decisions/prunePrune old performance decisions
GET/api/v1/auditList audit events (admin only)
POST/api/v1/keysCreate an API key (admin only)
GET/api/v1/keysList API keys (admin only)
DELETE/api/v1/keys/{id}Revoke an API key (admin only)
DELETE/api/v1/admin/cleanupRun artifact cleanup (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 credential_source::CredentialSource;
pub use credential_source::CredentialSourceError;
pub use credential_source::KeyPolicy;
pub use credential_source::LoadedCredential;
pub use credential_source::parse_credentials_document;
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::ApiKeyMetadata;
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.
credential_source
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 server.

Enums§

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

Constants§

VERSION
Server version string.