Cookbook
Short recipes for jobs that come up in real services, daemons and CLIs. Each recipe is backed by a runnable example in the repository that finishes in well under a second and asserts its own result.
| Recipe | Crates | Example |
|---|---|---|
| Retry with virtual time | id_effect, id_effect_resilience | 010_retry_with_breaker, crates/id_effect/tests/schedule.rs |
| Bounded subprocess pool | id_effect, id_effect_platform | 152_cookbook_bounded_command_pool |
A CLI with run_main | id_effect_cli, id_effect_config | 153_cookbook_cli_edge |
| Supervised daemon skeleton | id_effect_process | 154_cookbook_supervised_daemon |
| Streaming ETL with bounded memory | id_effect | 151_cookbook_streaming_etl |
Run them from the repository root:
cargo run -p id_effect_resilience --example 010_retry_with_breaker
cargo run -p id_effect_platform --example 152_cookbook_bounded_command_pool
cargo run -p cli_minimal --example 153_cookbook_cli_edge -- --name Ada
cargo run -p id_effect_process --example 154_cookbook_supervised_daemon
cargo run -p id_effect --example 151_cookbook_streaming_etl
All five follow one pattern:
- Write the program as an
Effect<A, E, R>whoseRlists the capabilities it needs (caps!(A, B)or an explicitHCons<A, HCons<B, HNil>>). - Provide the real capabilities once, at the edge (
main):.provide_env(..),.provide_layer(..)orrun_main(program, env, config). - In tests, provide fakes instead (a
MapConfigProvider, a recording console, an instrumented source) and run time-based code on aTestExecutor, whose virtual clock moves only when the test advances it.