Skip to content

Conversation

@Tuntii
Copy link
Owner

@Tuntii Tuntii commented Jan 14, 2026

This pull request introduces a new benchmarking suite for RustAPI and adds several new crates and examples to the workspace. The most significant changes are the addition of comprehensive benchmarking code for middleware and extractor performance, updates to the workspace structure, and improvements to the publishing workflow.

Benchmarking Suite:

  • Added a new rustapi-bench crate with Criterion-based benchmarks for middleware composition, extractor overhead, websocket handling, and more. This includes two new benchmark files: middleware_bench.rs and extractor_bench.rs, providing detailed performance measurements for various components. [1] [2] [3]

Workspace and Dependency Updates:

  • Added new crates (rustapi-testing, rustapi-jobs) and new example projects (microservices-advanced, event-sourcing, serverless-lambda) to the workspace in Cargo.toml. Also added the new rustapi-bench to the workspace benches. [1] [2] [3]
  • Bumped the workspace version to 0.1.8 and added async-trait as a new dependency. [1] [2]

CI/CD and Publishing Improvements:

  • Introduced a new GitHub Actions workflow (.github/workflows/publish.yml) to automate publishing crates to crates.io, including version verification, dry-run support, and dependency-order publishing to avoid failures.

These changes improve the maintainability of the project, add valuable performance insights, and streamline the release process.

Tuntii added 10 commits January 7, 2026 16:13
Introduces a new json module that uses simd-json for accelerated JSON parsing when enabled, with fallbacks to serde_json. Adds a stack-optimized PathParams type using smallvec for efficient path parameter storage, replacing HashMap usage in requests and routers. Logging is now gated behind a tracing feature using new conditional macros. Updates tests and internal APIs to use PathParams, and adds simd-json and smallvec as dependencies.
Implemented actual HTTP POST for the webhook exporter using reqwest when the 'webhook' feature is enabled, and added the 'webhook' feature to rustapi-extras. Introduced try_require_env for non-panicking env var retrieval. Added OpenAPI ResponseModifier for SSE streams. Updated workspace and crate versions to 0.1.8.
Introduces a new 'rustapi-bench' crate with Criterion-based benchmarks for extractors and middleware. Adds a GitHub Actions workflow for publishing to crates.io. Updates workspace members in Cargo.toml and re-exports FieldError in rustapi-core. Also adds comprehensive integration tests for rustapi-rs covering routing, state, JSON, error handling, OpenAPI, extractors, compression, and rate limiting.
Introduces comprehensive WebSocket message throughput benchmarks in benches/rustapi_bench, including text, binary, JSON parsing, frame encoding, and broadcast scenarios. Adds new modules to rustapi-extras for features like API key, cache, circuit breaker, CSRF, deduplication, Diesel, guards, logging, OAuth2, OpenTelemetry, retry, sanitization, security headers, structured logging, and timeout. Adds v2 validation modules to rustapi-validate, new WebSocket features to rustapi-ws, and a phase11-demo example. Updates dependencies and workspace configuration to support new features.
Introduces a comprehensive audit logging system in rustapi-extras with support for GDPR and SOC2 compliance, including in-memory and file-based stores, event/query types, and store trait. Adds the rustapi-testing crate for testing utilities. Updates workspace and dependencies to include the new audit and testing features.
Introduces streaming request body extraction to rustapi-core, allowing handlers to process large or unbuffered bodies efficiently. Refactors internal request body handling to support both buffered and streaming modes. Adds a new rustapi-jobs crate for background job processing with in-memory, Redis, and Postgres backends, including job queue management, retry logic, and tests. Updates workspace configuration and dependencies accordingly.
Introduces three new example projects: event-sourcing (CQRS/event sourcing demo), microservices-advanced (multi-binary microservices with service discovery and Docker support), and serverless-lambda (AWS Lambda integration). Updates core and extras crates for improved ergonomics, streaming, and OpenAPI support. Refactors test and example code for consistency and modern idioms.
Refactored product and registry endpoints to return structured response types (ProductList, SimpleResponse, ServicesListResponse) instead of raw values. This improves API consistency and schema generation.
Introduces comprehensive property-based tests using proptest for streaming memory bounds, audit event completeness, CSRF token lifecycle, OAuth2 token exchange, OpenTelemetry trace context propagation, and structured logging formats. These tests validate key requirements such as memory safety, field completeness, serialization round-trips, cryptographic uniqueness, standards compliance, and correct propagation of context and tokens.
Copilot AI review requested due to automatic review settings January 14, 2026 01:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces comprehensive benchmarking capabilities and significantly expands the RustAPI framework with new features including OpenAPI 3.1 support, background job processing, OAuth2 integration, structured logging, and enhanced middleware. The changes establish a robust foundation for performance monitoring and production-ready features.

Changes:

  • Added benchmarking suite with Criterion-based performance tests for middleware and extractors
  • Introduced OpenAPI 3.1.0 specification support with JSON Schema 2020-12 and webhooks
  • Added background job processing system with retry logic and multiple backend support
  • Integrated OAuth2 client with support for major providers (Google, GitHub, Microsoft, Discord)
  • Implemented structured logging with multiple output formats (JSON, Datadog, Splunk, Logfmt)
  • Added OpenTelemetry integration for distributed tracing
  • Enhanced SQLx integration with connection pool builder and health checks
  • Introduced validation derive macro for declarative input validation

Reviewed changes

Copilot reviewed 84 out of 142 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/rustapi-openapi/src/v31/spec.rs Complete OpenAPI 3.1.0 specification builder with webhook support
crates/rustapi-openapi/src/v31/schema.rs JSON Schema 2020-12 implementation with nullable type handling
crates/rustapi-macros/src/lib.rs Added Validate derive macro for automatic validation code generation
crates/rustapi-jobs/src/queue.rs Job queue manager with exponential backoff retry logic
crates/rustapi-jobs/src/error.rs Error types for job processing operations
crates/rustapi-extras/src/timeout.rs Request timeout middleware implementation
crates/rustapi-extras/src/structured_logging/* Structured logging system with multiple formatter support
crates/rustapi-extras/src/sqlx/mod.rs Enhanced SQLx integration with pool builder and configuration
crates/rustapi-extras/src/security_headers.rs Security headers middleware for web protection
crates/rustapi-extras/src/retry.rs Retry middleware with configurable backoff strategies
crates/rustapi-extras/src/otel/* OpenTelemetry integration for distributed tracing
crates/rustapi-extras/src/oauth2/* Complete OAuth2 client implementation with PKCE support
Comments suppressed due to low confidence (4)

crates/rustapi-openapi/src/lib.rs:1

  • The use of r# raw string literal syntax appears to be a mistake. This should likely be a standard doc comment /// or the raw string should be properly terminated. The content "RustAPI Jobs" seems unrelated to the rustapi-openapi crate.
//! OpenAPI documentation for RustAPI

crates/rustapi-jobs/src/queue.rs:1

  • The calculation of min_conn as a fraction of max_conn could result in min_conn being 0 when min_conn_factor is very small, which might not be the intended behavior. Consider adding a minimum threshold of 1 to ensure at least one minimum connection.
use crate::backend::{JobBackend, JobRequest};

crates/rustapi-extras/src/structured_logging/layer.rs:1

  • This unreachable!() is in the wrong file (should be in retry.rs). However, the logic structure suggests this should never be reached. Consider adding a comment explaining why this is unreachable, or restructure the loop to make it more obvious that all paths return.
//! Structured logging middleware layer

crates/rustapi-extras/src/otel/propagation.rs:1

  • The comment indicates constant-time comparison should be used to prevent timing attacks, but the implementation uses direct comparison which is NOT constant-time. Either use a proper constant-time comparison function (e.g., from subtle crate) or remove the misleading comment.
//! W3C Trace Context propagation utilities

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Ok(id)
}

/// Process a single job (for testing or manual control)
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function process_one is marked as public but lacks documentation. Add a doc comment explaining that this method processes a single job from the queue and returns whether a job was processed, primarily intended for testing or manual control.

Suggested change
/// Process a single job (for testing or manual control)
/// Processes a single job from the queue.
///
/// Returns `Ok(true)` if a job was fetched from the backend and processed
/// (including cases where it is retried or marked as failed), or
/// `Ok(false)` if no job was available to process. This method is
/// primarily intended for testing or manual control of job execution.

Copilot uses AI. Check for mistakes.
Comment on lines +366 to +367
pub fn try_require_env(name: &str) -> Result<String, ConfigError> {
std::env::var(name).map_err(|_| ConfigError::MissingVar(name.to_string()))
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new try_require_env function lacks comprehensive documentation. While there is a basic example, it should document the error type returned and when it would be preferred over require_env.

Copilot uses AI. Check for mistakes.
Tuntii and others added 12 commits January 14, 2026 04:02
This commit refactors property tests and benchmarks across multiple modules for improved readability and consistency. Changes include formatting, reducing unnecessary line breaks, and simplifying iterator usage. No functional logic is altered.
Replaces 'status_code' with 'status' in property tests for error handling in stream.rs. Removes unnecessary boxing from the Direct variant of StreamImpl in socket.rs and adds a clippy lint allowance for large enum variants.
Refactors property tests in otel/propagation.rs and structured_logging/formats.rs to use .clone() for value comparisons, improving correctness and consistency. Adds proptest as a dev-dependency to rustapi-jobs and rustapi-testing crates. Introduces a regression seed file for structured logging proptests. Updates queue.rs to use InMemoryBackend and refines error handling in test jobs.
Added a regression seeds file for proptest failures to ensure reproducibility of past failure cases. Marked two property tests as ignored due to the need for time mocking, and fixed a logic error in the backoff linearity check in queue.rs.
Cleaned up unused imports in Postgres and Redis backends. Updated the RedisBackend implementation to specify type parameters for the zadd call, improving type clarity and resolving potential type inference issues.
Added the 'r2d2' feature to the diesel dependency in rustapi-extras to ensure r2d2 integration is available. Updated error handling in DieselPoolBuilder to explicitly use r2d2::Error, improving type clarity.
Updated property-based tests in csrf/token.rs and oauth2/tokens.rs to use .clone() on values in prop_assert_eq! and prop_assert_ne! macros. This ensures that the tests do not move values, improving clarity and preventing potential ownership issues.
Introduces new CLI commands: 'watch' for auto-reloading, 'add' for adding dependencies or features, and 'doctor' for checking environment health. Updates argument parsing, command dispatch, and command modules accordingly. Also improves file writing in the minimal template by parallelizing operations and updates ignored directories in watch-related commands for better performance. Minor import reordering in rustapi-jobs property tests.
Updated the watch command to remove unnecessary await on spawn, fixing process handling. Improved file writing in the minimal template by wrapping async file writes with error mapping to ensure proper error propagation in parallel execution.
Updated CI and publish GitHub Actions workflows to exclude the 'target' directory from cache paths, improving cache efficiency and avoiding potential issues with stale build artifacts. Also refined the version extraction regex in publish.yml for better accuracy.
@Tuntii Tuntii merged commit f4c0d99 into main Jan 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants