example: end-to-end walkthrough + fix rpc2_adapter set wrapper #105
No reviewers
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_rpc!105
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "walkthrough-example"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Two related changes:
example/recipe_server/crates/hero_recipes_examples/examples/01_walkthrough.rs— replaces the TODO placeholder01_connect.rswith a runnable top-to-bottom tour of how a Hero service is built. Six steps, each prints what it's doing, runs in a tempdir:WorkspaceScaffolder::scaffold()) + print the tree.Schema::to_openrpc()— lists 7 auto-CRUD methods + 1 service method.OsisRecipes::create→rpc2_adapter::module_for→ServerBuilder::serve_http→ClientBuilder::connect_http, then callrecipe_list/recipe_list_full/recipe_existsthrough the typed trait.Run with:
cargo run -p hero_recipes_examples --example 01_walkthroughrpc2_adapter::extract_datasetfix — while writing step 6 I caught a bug in my own #98 code: thesetbranch was unwrappingparams.databefore passing the JSON downstream, but the OSchema dispatcher'srecipe_rpc_setstill callsparams.get("data")and so failed with "Missing required parameter: data". Fix: always preserve the outer{"data": ..., "ctx": ...}wrapper. Tests replaced with two stricter ones that explicitly verify the wrapper survives.Open follow-up documented in the walkthrough output
The SDK uses
OTime(String)(transparent), the OSIS server stores epoch-integers — full Recipe ser/deser viarecipe.set/recipe.getcurrently fails on the cross-side serde shape. Separate codegen issue, not in scope here. The walkthrough explicitly calls this out inline.Test plan
cargo run -p hero_recipes_examples --example 01_walkthroughcompletes end-to-end with the expected printed output.## 01_walkthrough.rs Replaces the TODO placeholder 01_connect.rs with a runnable top-to-bottom tour of how a Hero RPC service is built. Six steps, each prints what it's doing: 1. Scaffold a fresh service workspace into a tempdir (`WorkspaceScaffolder::scaffold()`), then print the tree. 2. Show the OSchema input (Greeting [rootobject] + Hello service). 3. Generate the OpenRPC spec from that schema directly via `Schema::to_openrpc()`, list all 8 methods — 7 auto-CRUD on Greeting + the Hello.greet service method. 4. Print an excerpt of the generated typed Rust SDK trait. 5. Print the backend handler impl pattern (CRUD auto, service methods you write). 6. **Live in-process roundtrip** against the recipe_server domain: `OsisRecipes::create` → `rpc2_adapter::module_for` → `ServerBuilder::serve_http` → `ClientBuilder::connect_http`, then call `recipe_list` / `recipe_list_full` / `recipe_exists` through the typed trait. Steps 1–5 are static (no compilation, just emission + printing). Step 6 is fully live and exercises the same code paths a real service binary follows — exactly what the design promised in #98. The example documents one open follow-up: the SDK uses `OTime(String)` (transparent) while the OSIS server stores epoch-integers, so full-Recipe ser/deser via `recipe.set` / `recipe.get` currently fails — a separate codegen issue, called out inline in the walkthrough output. ## rpc2_adapter `set` data-extract fix While writing step 6 I caught a bug in my own `extract_data` from the #98 PR: the `"set"` branch was unwrapping `params.data` before passing the JSON downstream, but the OSchema dispatcher's `recipe_rpc_set` still calls `params.get("data")` and so failed with "Missing required parameter: data". Fix: always preserve the outer `{"data": ..., "ctx": ...}` wrapper when stringifying for `set` — the dispatcher then finds `params.data` as expected and `ctx` is a harmless extra key. Tests updated: replaced the old asserts (which only checked inner-field presence, so they passed even when the wrapper was stripped) with two stricter ones that explicitly verify the wrapper survives. - `extract_data_set_preserves_data_wrapper` - `extract_data_set_passes_through_ctx_alongside_data` All 9 rpc2_adapter tests + 138 generator unit tests still pass.