docs: cookbook expansion and learning path improvements#132
Conversation
- Fixed `MockServer` usage in `recipes/testing.md` to match actual API. - Added new "Graceful Shutdown" recipe in `recipes/graceful_shutdown.md`. - Updated `recipes/README.md` and `SUMMARY.md` to include new recipe. - Enhanced "Module 11: Background Jobs" in `learning/curriculum.md` with mini-project. - Generated run report and updated docs coverage/inventory.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR updates the RustAPI documentation with fixes, new content, and learning path improvements. The changes primarily focus on correcting MockServer examples, adding a comprehensive graceful shutdown guide, and enhancing the background jobs module in the learning curriculum.
Changes:
- Fixed MockServer API usage in testing recipe (removed incorrect
.awaitand replaced nonexistenturl()method) - Added new "Graceful Shutdown" recipe covering signal handling and
run_with_shutdownAPI - Enhanced Module 11 of the learning curriculum with a mini-project and improved knowledge checks
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/cookbook/src/recipes/testing.md | Fixed MockServer example to use correct API (removed .await on builder, use base_url() + format string) |
| docs/cookbook/src/recipes/graceful_shutdown.md | New comprehensive recipe for graceful shutdown with CTRL+C and SIGTERM handling |
| docs/cookbook/src/recipes/README.md | Added link to new Graceful Shutdown recipe |
| docs/cookbook/src/learning/curriculum.md | Enhanced Module 11 with "The Email Worker" mini-project and better knowledge checks |
| docs/cookbook/src/SUMMARY.md | Added Graceful Shutdown to table of contents |
| docs/.agent/run_report_2026-02-23.md | New run report documenting the changes |
| docs/.agent/last_run.json | Updated last run metadata |
| docs/.agent/docs_coverage.md | Added Graceful Shutdown entry to coverage map |
Comments suppressed due to low confidence (1)
docs/cookbook/src/recipes/testing.md:115
- The MockServer test is missing a verification call at the end. According to the rustapi-testing implementation, MockServer does not auto-verify expectations on Drop; tests must explicitly call
mock_server.verify()at the end to ensure that all expectations were met. Addmock_server.verify();after the assertions to complete the test properly.
async fn test_external_integration() {
// 1. Start a mock server
let mock_server = MockServer::start().await;
// 2. Define an expectation
mock_server.expect(
rustapi_testing::RequestMatcher::new()
.method("GET")
.path("/external-data")
).respond_with(
MockResponse::new()
.status(200)
.body(r#"{"data": "mocked"}"#)
);
// 3. Use the mock server's URL in your app configuration
let mock_url = format!("{}{}", mock_server.base_url(), "/external-data");
// Simulating your app logic calling the external service
let client = reqwest::Client::new();
let res = client.get(&mock_url).send().await.unwrap();
assert_eq!(res.status(), 200);
let body = res.text().await.unwrap();
assert_eq!(body, r#"{"data": "mocked"}"#);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 2. Enqueue this job inside your `POST /register` handler. | ||
| 3. Write an integration test using `TestClient` to verify the registration endpoint. | ||
| - **Expected Output:** Registration returns 200 immediately (low latency); console logs show "Sending welcome email to ..." shortly after (asynchronous). Tests pass. | ||
| - **Pitfalls:** Forgetting to start the job worker loop (`JobWorker::new(queue).run().await`). |
There was a problem hiding this comment.
The API usage mentioned here is incorrect. The rustapi-jobs library doesn't have a JobWorker type. Based on the actual implementation in crates/rustapi-jobs/src/queue.rs, the correct way to start the worker loop is to call queue.start_worker().await where queue is a JobQueue instance. The pitfall should read: "Forgetting to start the job worker loop (spawn queue.start_worker().await in a background task)".
| - **Pitfalls:** Forgetting to start the job worker loop (`JobWorker::new(queue).run().await`). | |
| - **Pitfalls:** Forgetting to start the job worker loop (spawn `queue.start_worker().await` in a background task). |
|
|
||
| #[tokio::main] | ||
| async fn main() -> Result<()> { | ||
| let app = RustApi::new().route("/", get(hello)); |
There was a problem hiding this comment.
The production example references a hello function on line 59, but this function is not defined in this code block. The example should either include the hello function definition (copying it from the basic example) or use an inline closure instead, such as .route("/", get(|| async { "Hello" })), to make the example self-contained and compilable.
…tenance-2026-02-23-12444186712278693427 docs: cookbook expansion and learning path improvements 189ae08
This PR updates the RustAPI documentation as part of the scheduled maintenance run.
Key changes:
MockServerexamples inrecipes/testing.mdwhich were using incorrect async syntax and nonexistent methods.CTRL+CandSIGTERMhandling.PR created automatically by Jules for task 12444186712278693427 started by @Tuntii