Conversation
Introduce built-in health endpoints and a production baseline preset, plus a synthetic in-process performance snapshot and CI wiring. Changes include: add HealthEndpointConfig, HealthResponse and health helper handlers; RustApi methods to enable health_endpoints(), with_health_check(), and production_defaults()/production_defaults_with_config(); automatically register /health, /ready and /live when configured; tests for health endpoints; a new perf_snapshot example and CI step to run and upload its output; README, CHANGELOG and RELEASES updates to document production defaults and benchmark guidance; new .env for local examples; API exports extended (oauth2/session/job/session stores and helpers); new session module and multiple cookbook/docs/recipes additions; and Cargo.lock updates for new dependencies. Overall this adds production probe ergonomics and a reproducible perf snapshot to the project.
Add public exports for the jobs API and SSE helper and refresh example docs and task list.
- Export sse_from_iter from core and prelude in api/public/rustapi-rs.{all-features,default}.txt
- Add extras::jobs exports (EnqueueOptions, InMemoryBackend, Job, JobBackend, JobContext, JobError, JobQueue, JobRequest) and expose them in the prelude/all-features file
- Update crates/rustapi-rs/examples/README.md: reorder/clarify examples, add endpoint samples for full_crud_api and inline example commands
- Update tasks.md: mark full_crud_api, streaming_api, and jobs_api examples as completed
Introduce observability and benchmarking workflows and CLI ergonomics: add new `bench` and `observability` commands, surface observability assets, and wire a benchmark runner. Expand the `doctor` command to scan workspace signals (health, shutdown, tracing, rate-limit, body limits, etc.), emit structured checks/warnings/failures, and support a --strict mode. Add project presets and template wiring: introduce ProjectPreset (prod-api, ai-api, realtime-api), recommended feature bundles, CLI --preset support for `cargo rustapi new`, and related tests. Enable the `replay` feature by default for the cargo CLI and export replay, streaming multipart, and RateLimitStrategy types in the public API files. Library tweaks: expose RateLimitStrategy and extend rate-limit internals to support multiple strategies; clarify multipart usage (drop/consume previous field before next). Update docs/README examples and CLI README entries, add tests for new commands, and update .gitignore to ignore markdown files.
There was a problem hiding this comment.
Pull request overview
This PR establishes a more production-oriented baseline for RustAPI by adding built-in health probes and a one-call production_defaults() preset, expanding rustapi-rs facade exports (sessions/OAuth2/jobs/replay/streaming multipart), and updating documentation + CLI workflows around benchmarking, observability, and replay.
Changes:
- Added built-in health endpoints (
/health,/ready,/live) and aproduction_defaults()preset + tests. - Expanded facade exports and added new examples/recipes for sessions, OAuth2, jobs, replay workflow, streaming APIs, and migrations.
- Introduced new
cargo-rustapicommands (bench,observability) and updated benchmark CI to upload a perf snapshot output.
Reviewed changes
Copilot reviewed 60 out of 63 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tasks.md | Task tracking placeholder (present in PR metadata). |
| docs/cookbook/src/reference/macro_attributes.md | New macro attribute reference page. |
| docs/cookbook/src/reference/README.md | Adds reference section intro + link to macro attribute reference. |
| docs/cookbook/src/recipes/session_auth.md | New session-auth recipe using facade exports. |
| docs/cookbook/src/recipes/replay.md | Updates replay docs into a workflow guide (now mixed-language). |
| docs/cookbook/src/recipes/oidc_oauth2_production.md | New production OAuth/OIDC guidance page. |
| docs/cookbook/src/recipes/observability.md | New observability baseline recipe referencing production defaults + layers. |
| docs/cookbook/src/recipes/oauth2_client.md | Updates OAuth2 client recipe to use facade exports + sessions. |
| docs/cookbook/src/recipes/middleware_debugging.md | New middleware debugging guide (layer order, checklist). |
| docs/cookbook/src/recipes/graceful_shutdown.md | Expands shutdown guidance, adds drain/readiness example. |
| docs/cookbook/src/recipes/error_handling.md | New error-handling recipe documenting ApiError patterns and wire format. |
| docs/cookbook/src/recipes/deployment.md | Adds probe recommendations + Kubernetes snippet + minimal production bootstrap. |
| docs/cookbook/src/recipes/db_integration.md | Expands DB guidance (SQLx vs Diesel vs SeaORM, pooling, migrations). |
| docs/cookbook/src/recipes/custom_extractors.md | New custom extractor patterns for parts vs body consumption. |
| docs/cookbook/src/recipes/axum_migration.md | New Axum→RustAPI migration guide. |
| docs/cookbook/src/recipes/actix_migration.md | New Actix-web→RustAPI migration guide. |
| docs/cookbook/src/recipes/README.md | Adds new recipe links (sessions/oauth/replay/observability/migrations/etc.). |
| docs/cookbook/src/learning/curriculum.md | Updates curriculum link to new error-handling recipe. |
| docs/cookbook/src/concepts/performance.md | Replaces static perf numbers with policy + benchmark doc pointers. |
| docs/cookbook/src/SUMMARY.md | Adds new reference/recipe pages to mdbook summary. |
| docs/README.md | Adds quick links to benchmark policy + production baseline/checklist + replay recipe. |
| docs/PERFORMANCE_BENCHMARKS.md | Adds benchmark policy + a “latest validated snapshot” section. |
| docs/GETTING_STARTED.md | Documents new health endpoints + production_defaults() usage. |
| crates/rustapi-rs/src/lib.rs | Expands core/prelude/extras re-exports (health, sessions, oauth2, jobs, replay, streaming multipart, sse_from_iter, etc.). |
| crates/rustapi-rs/examples/streaming_api.rs | New SSE streaming example using sse_from_iter. |
| crates/rustapi-rs/examples/jobs_api.rs | New jobs example gated on jobs feature. |
| crates/rustapi-rs/examples/full_crud_api.rs | New full CRUD example. |
| crates/rustapi-rs/examples/auth_api.rs | New session-auth example gated on session feature. |
| crates/rustapi-rs/examples/README.md | New examples index for facade crate. |
| crates/rustapi-rs/Cargo.toml | Adds rustapi-jobs + futures-util deps; introduces extras session/oauth/jobs features. |
| crates/rustapi-extras/src/rate_limit/mod.rs | Adds new rate limit strategies (fixed/sliding/token-bucket) + tests and exports. |
| crates/rustapi-extras/src/oauth2/tokens.rs | Adds PkceVerifier::new(...) to rebuild from stored verifier; adjusts generate. |
| crates/rustapi-extras/src/lib.rs | Re-exports session module/types + rate limit strategy. |
| crates/rustapi-extras/Cargo.toml | Adds redis dependency + session/session-redis features; updates full feature set. |
| crates/rustapi-core/tests/production_defaults.rs | New integration tests for production defaults preset + probe wiring. |
| crates/rustapi-core/tests/health_endpoints.rs | New integration tests for health endpoints and status codes. |
| crates/rustapi-core/src/multipart.rs | Adds streaming multipart extractor + field type + tests; adds multer integration. |
| crates/rustapi-core/src/lib.rs | Re-exports production defaults config, health endpoint config/response, streaming multipart, sse_from_iter. |
| crates/rustapi-core/src/health.rs | Adds HealthEndpointConfig, HealthResponse, and helper handlers + OpenAPI response modifier. |
| crates/rustapi-core/src/extract.rs | Adds OpenAPI OperationModifier for AsyncValidatedJson<T> (parity with ValidatedJson<T>). |
| crates/rustapi-core/src/app.rs | Adds health endpoint wiring and a ProductionDefaultsConfig + production_defaults* APIs. |
| crates/rustapi-core/examples/perf_snapshot.rs | New synthetic in-process perf snapshot example for CI/local runs. |
| crates/rustapi-core/Cargo.toml | Adds multer = "3" and enables tokio io-util feature. |
| crates/cargo-rustapi/tests/cli_tests.rs | Adds tests for presets and new commands’ help output. |
| crates/cargo-rustapi/src/templates/mod.rs | Adds ProjectPreset with recommended feature bundles. |
| crates/cargo-rustapi/src/commands/observability.rs | New observability command that surfaces workflow assets. |
| crates/cargo-rustapi/src/commands/new.rs | Adds --preset support and merges preset features with explicit features. |
| crates/cargo-rustapi/src/commands/mod.rs | Registers new bench and observability commands (and replay under feature). |
| crates/cargo-rustapi/src/commands/bench.rs | New bench command intended to run a repo benchmark script. |
| crates/cargo-rustapi/src/cli.rs | Wires new subcommands into CLI; changes replay wiring. |
| crates/cargo-rustapi/README.md | Documents new commands and presets. |
| crates/cargo-rustapi/Cargo.toml | Enables replay by default feature set. |
| api/public/rustapi-rs.default.txt | Updates public API snapshot for new exports (streaming multipart, sse_from_iter). |
| api/public/rustapi-rs.all-features.txt | Updates all-features snapshot for new exports (oauth2/session/jobs/replay/etc.). |
| RELEASES.md | Adds benchmark policy note pointing to canonical doc. |
| README.md | Adds probe and replay examples; replaces static perf number with benchmark-policy pointer. |
| Cargo.lock | Adds new dependency lock entries (multer, redis, etc.). |
| CHANGELOG.md | Adds note that old benchmark numbers are historical snapshots. |
| .gitignore | Adds ignores for production docs, internal GH assets, and *.md (very broad). |
| .github/workflows/benchmark.yml | Adds perf snapshot run and uploads perf_snapshot.txt artifact. |
| .env | Adds placeholder env vars for local docs/examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
crates/cargo-rustapi/src/cli.rs
Outdated
| @@ -33,9 +35,15 @@ enum Commands { | |||
| /// Add a feature or dependency | |||
| Add(AddArgs), | |||
|
|
|||
| /// Run the benchmark workflow | |||
| Bench(BenchArgs), | |||
|
|
|||
| /// Check environment health | |||
| Doctor(DoctorArgs), | |||
|
|
|||
| /// Surface observability docs and baseline workflow assets | |||
| Observability(ObservabilityArgs), | |||
|
|
|||
| /// Generate code from templates | |||
| #[command(subcommand)] | |||
| Generate(GenerateArgs), | |||
| @@ -59,9 +67,8 @@ enum Commands { | |||
| Deploy(DeployArgs), | |||
|
|
|||
| /// Replay debugging commands (time-travel debugging) | |||
| #[cfg(feature = "replay")] | |||
| #[command(subcommand)] | |||
| Replay(commands::ReplayArgs), | |||
| Replay(ReplayArgs), | |||
| } | |||
There was a problem hiding this comment.
ReplayArgs is imported behind #[cfg(feature = "replay")], but the Commands::Replay(ReplayArgs) variant (and its match arm) are unconditional. Building cargo-rustapi with default-features = false (or without replay) will fail to compile. Either gate the enum variant + match arm behind the same feature, or make the replay command always available and remove the conditional import/module gating.
| let script_path = workspace_root.join("scripts").join("bench.ps1"); | ||
|
|
||
| if !script_path.exists() { | ||
| bail!( | ||
| "Benchmark script was not found at {}", | ||
| script_path.display() | ||
| ); | ||
| } | ||
|
|
||
| let shell = if cfg!(windows) { "powershell" } else { "pwsh" }; | ||
|
|
||
| println!( | ||
| "{} {}", | ||
| style("Running benchmark workflow from").bold(), | ||
| style(script_path.display()).cyan() | ||
| ); | ||
|
|
||
| let mut command = Command::new(shell); | ||
| if cfg!(windows) { | ||
| command.args(["-ExecutionPolicy", "Bypass", "-File"]); | ||
| } else { | ||
| command.arg("-File"); | ||
| } | ||
| command.arg(&script_path).current_dir(&workspace_root); | ||
|
|
||
| if let Some(warmup) = args.warmup { | ||
| command.env("RUSTAPI_PERF_WARMUP", warmup.to_string()); | ||
| } | ||
| if let Some(iterations) = args.iterations { | ||
| command.env("RUSTAPI_PERF_ITERS", iterations.to_string()); | ||
| } | ||
|
|
||
| let status = command.status().await.context("Failed to launch benchmark workflow")?; | ||
| if !status.success() { | ||
| bail!("Benchmark workflow exited with status {}", status); |
There was a problem hiding this comment.
cargo rustapi bench hard-codes scripts/bench.ps1, but this repository currently has no scripts/ directory (so the command will always error). Consider either adding scripts/bench.ps1 in this PR, or updating the command to run cargo bench --workspace and the perf_snapshot example directly (matching docs/PERFORMANCE_BENCHMARKS.md and CI).
| let script_path = workspace_root.join("scripts").join("bench.ps1"); | |
| if !script_path.exists() { | |
| bail!( | |
| "Benchmark script was not found at {}", | |
| script_path.display() | |
| ); | |
| } | |
| let shell = if cfg!(windows) { "powershell" } else { "pwsh" }; | |
| println!( | |
| "{} {}", | |
| style("Running benchmark workflow from").bold(), | |
| style(script_path.display()).cyan() | |
| ); | |
| let mut command = Command::new(shell); | |
| if cfg!(windows) { | |
| command.args(["-ExecutionPolicy", "Bypass", "-File"]); | |
| } else { | |
| command.arg("-File"); | |
| } | |
| command.arg(&script_path).current_dir(&workspace_root); | |
| if let Some(warmup) = args.warmup { | |
| command.env("RUSTAPI_PERF_WARMUP", warmup.to_string()); | |
| } | |
| if let Some(iterations) = args.iterations { | |
| command.env("RUSTAPI_PERF_ITERS", iterations.to_string()); | |
| } | |
| let status = command.status().await.context("Failed to launch benchmark workflow")?; | |
| if !status.success() { | |
| bail!("Benchmark workflow exited with status {}", status); | |
| println!( | |
| "{} {}", | |
| style("Running `cargo bench --workspace` in").bold(), | |
| style(workspace_root.display()).cyan() | |
| ); | |
| let mut bench_cmd = Command::new("cargo"); | |
| bench_cmd | |
| .arg("bench") | |
| .arg("--workspace") | |
| .current_dir(&workspace_root); | |
| if let Some(warmup) = args.warmup { | |
| bench_cmd.env("RUSTAPI_PERF_WARMUP", warmup.to_string()); | |
| } | |
| if let Some(iterations) = args.iterations { | |
| bench_cmd.env("RUSTAPI_PERF_ITERS", iterations.to_string()); | |
| } | |
| let bench_status = bench_cmd | |
| .status() | |
| .await | |
| .context("Failed to run `cargo bench --workspace`")?; | |
| if !bench_status.success() { | |
| bail!("`cargo bench --workspace` exited with status {}", bench_status); | |
| } | |
| println!( | |
| "{} {}", | |
| style("Running `cargo run --example perf_snapshot --release` in").bold(), | |
| style(workspace_root.display()).cyan() | |
| ); | |
| let mut perf_cmd = Command::new("cargo"); | |
| perf_cmd | |
| .arg("run") | |
| .arg("--example") | |
| .arg("perf_snapshot") | |
| .arg("--release") | |
| .current_dir(&workspace_root); | |
| if let Some(warmup) = args.warmup { | |
| perf_cmd.env("RUSTAPI_PERF_WARMUP", warmup.to_string()); | |
| } | |
| if let Some(iterations) = args.iterations { | |
| perf_cmd.env("RUSTAPI_PERF_ITERS", iterations.to_string()); | |
| } | |
| let perf_status = perf_cmd | |
| .status() | |
| .await | |
| .context("Failed to run `cargo run --example perf_snapshot --release`")?; | |
| if !perf_status.success() { | |
| bail!( | |
| "`cargo run --example perf_snapshot --release` exited with status {}", | |
| perf_status | |
| ); |
| let assets = [ | ||
| ( | ||
| "Production baseline", | ||
| workspace_root.join("docs").join("PRODUCTION_BASELINE.md"), | ||
| ), | ||
| ( | ||
| "Observability cookbook", | ||
| workspace_root | ||
| .join("docs") | ||
| .join("cookbook") | ||
| .join("src") | ||
| .join("recipes") | ||
| .join("observability.md"), | ||
| ), | ||
| ( | ||
| "Benchmark workflow", | ||
| workspace_root.join("scripts").join("bench.ps1"), | ||
| ), | ||
| ( | ||
| "Quality gate", | ||
| workspace_root.join("scripts").join("check_quality.ps1"), | ||
| ), | ||
| ]; |
There was a problem hiding this comment.
The observability command treats several paths as required assets (docs/PRODUCTION_BASELINE.md, scripts/bench.ps1, scripts/check_quality.ps1), but those files/directories are not present in the repo. As a result, cargo rustapi observability --check will reliably fail (and the output will always report missing assets). Either add these assets in this PR or adjust the asset list to match what actually exists (e.g., .github/workflows/benchmark.yml and the benchmark commands it runs).
| Use the repository benchmark script: | ||
|
|
||
| ```powershell | ||
| ./scripts/bench.ps1 | ||
| ``` | ||
|
|
||
| This currently runs: | ||
|
|
||
| ```powershell | ||
| cargo bench --workspace | ||
| cargo run -p rustapi-core --example perf_snapshot --release | ||
| ``` |
There was a problem hiding this comment.
This doc instructs users to run ./scripts/bench.ps1, but the repository doesn't include that script right now. Either add the script in this PR, or update the docs to point at the actual benchmark entry points that exist (e.g., cargo bench --workspace and cargo run -p rustapi-core --example perf_snapshot --release).
| ### Run benchmarks locally | ||
|
|
||
| From the repository root: | ||
|
|
||
| ```powershell | ||
| ./scripts/bench.ps1 | ||
| ``` | ||
| </details> | ||
|
|
||
| That currently executes `cargo bench --workspace`. | ||
|
|
There was a problem hiding this comment.
This section references ./scripts/bench.ps1, but the repository doesn't currently contain that script. To avoid sending users to a dead command, update this to the actual benchmark invocation(s) that exist in-repo (or add the script as part of this PR).
| ```yaml | ||
| livenessProbe: | ||
| httpGet: | ||
| path: /live | ||
| port: 8080 | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 10 | ||
|
|
||
| readinessProbe: | ||
| httpGet: | ||
| path: /ready | ||
| port: 8080 | ||
| initialDelaySeconds: 2 | ||
| periodSeconds: 5 | ||
|
|
||
| startupProbe: | ||
| httpGet: | ||
| path: /live | ||
| port: 8080 | ||
| failureThreshold: 30 | ||
| periodSeconds: 2 | ||
| ``` |
There was a problem hiding this comment.
The Kubernetes YAML example uses tab characters for indentation. YAML requires spaces, so as-written this snippet will fail to parse if copied into a manifest. Replace the tabs with spaces and keep indentation consistent (typically 2 spaces) so the example is valid.
| OAUTH_CLIENT_ID=replace-me | ||
| OAUTH_CLIENT_SECRET=replace-me | ||
| OAUTH_REDIRECT_URI=http://127.0.0.1:3000/auth/callback | ||
| OIDC_ISSUER_URL=https://accounts.google.com |
There was a problem hiding this comment.
Committing a root .env file can cause accidental leakage if developers later add real secrets, and it can also unexpectedly affect local runs/CI that auto-load .env. Consider renaming this to .env.example (tracked) and adding .env to .gitignore, while keeping the docs pointing at the example file.
| OIDC_ISSUER_URL=https://accounts.google.com | |
| OIDC_ISSUER_URL=replace-me |
| | [GraphQL Adapter Plan](GRAPHQL_ADAPTER_PLAN.md) | Planned GraphQL integration shape and facade design | | ||
| | [Adaptive Execution Debug Plan](ADAPTIVE_EXECUTION_DEBUG_PLAN.md) | Proposed profiling/debug UX for making execution tiers visible in traces, logs, metrics, and headers | | ||
| | [Performance Benchmarks](PERFORMANCE_BENCHMARKS.md) | Authoritative source for benchmark methodology and published claims | | ||
| | [Recommended Production Baseline](PRODUCTION_BASELINE.md) | Opinionated starting point for production services | | ||
| | [Production Checklist](PRODUCTION_CHECKLIST.md) | Rollout-ready operational checklist | | ||
| | [Cookbook: Replay Workflow](cookbook/src/recipes/replay.md) | Official capture → inspect → replay → diff flow for time-travel debugging | |
There was a problem hiding this comment.
PRODUCTION_BASELINE.md and PRODUCTION_CHECKLIST.md are linked here, but those files are not present under docs/ in the repository. This creates broken links in the docs landing page; either add the missing documents in this PR or remove/adjust the links until they exist.
| ## Ne zaman kullanılır? | ||
|
|
||
| Add the `replay` feature to your `Cargo.toml`: | ||
| Replay en çok şu durumlarda işe yarar: | ||
|
|
||
| - staging ile local arasında davranış farkı varsa | ||
| - bir regresyonu gerçek trafik örneğiyle yeniden üretmek istiyorsanız | ||
| - yeni bir sürümü canary ortamına almadan önce kritik istekleri tekrar koşturmak istiyorsanız | ||
| - “bu istek neden dün çalışıyordu da bugün bozuldu?” sorusuna zaman makinesi tadında cevap arıyorsanız | ||
|
|
||
| ## Ön koşullar | ||
|
|
||
| Uygulamada canonical replay feature'ını açın: | ||
|
|
There was a problem hiding this comment.
This recipe switches from English to Turkish starting at the first section heading. If the cookbook is intended to be English-first, this makes the page inconsistent and harder to consume for most readers. Consider translating these sections to English (or splitting into localized copies with clear navigation/labels).
Enable the `sync` feature for tokio in cargo-rustapi and gate the Replay CLI subcommand/tests behind cfg(feature = "replay"). Additionally apply a series of small refactors and formatting fixes across the workspace: reflowed long expressions, added/removed trailing commas, normalized imports and multi-line signatures, and cleaned up test invocations and assertions. Changes touch cargo-rustapi, rustapi-core, rustapi-extras, rustapi-rs and related examples/tests; they are primarily stylistic and readability improvements (with the notable functional addition of the tokio `sync` feature and conditional replay wiring).
…n-baseline Production baseline f90345c
Description
This pull request introduces several important improvements to RustAPI's documentation, environment setup, and feature exports. Notably, it clarifies performance benchmarking methodology, adds standard health probe endpoints, and expands public exports for session management, OAuth2, jobs, and replay features. These changes make the framework easier to use in production and clarify how performance claims are maintained.
Documentation and Benchmarking Updates:
docs/PERFORMANCE_BENCHMARKS.md, with historical numbers preserved as snapshots in release notes and referenced fromREADME.md,CHANGELOG.md, andRELEASES.md. [1] [2] [3] [4]Production and Health Probe Features:
/health,/ready,/live) via.health_endpoints()andHealthCheckBuilder, as well as a single-call production baseline preset withproduction_defaults(). [1] [2]Replay and Incident Workflow Enhancements:
Environment Setup:
.envfile with placeholder environment variables for local development and documentation examples.Public API Expansion:
api/public/rustapi-rs.all-features.txtandapi/public/rustapi-rs.default.txtto include session management, OAuth2, jobs, replay, and streaming multipart features, making them available viapreludeand extras modules. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]CI Workflow Improvements:
Type of Change
Checklist
api/public/*snapshots changed, this PR hasbreakingorfeaturelabel