feat(anyspawn)!: add CustomSpawnerBuilder for composing multilayered spawner#308
feat(anyspawn)!: add CustomSpawnerBuilder for composing multilayered spawner#308
CustomSpawnerBuilder for composing multilayered spawner#308Conversation
|
There was a problem hiding this comment.
Pull request overview
Adds a composable, named custom spawner builder to anyspawn, improving debug output and enabling layered spawn behavior (e.g., context propagation) while updating the existing custom spawner API to include a stable name.
Changes:
- Introduce
CustomSpawnerBuilderfor composing named layers and building aSpawner. - Make custom spawners and
Spawnerdebug output include spawner/layer names; updateSpawner::new_customto accept aname. - Add tests (incl. snapshots) and an OpenTelemetry context propagation example; update docs/README/benches accordingly.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/anyspawn/tests/spawner.rs | Updates tests for new Spawner::new_custom(name, ...) API and debug output expectations. |
| crates/anyspawn/tests/builder.rs | Adds snapshot + behavioral tests for builder/spawner naming and debug output. |
| crates/anyspawn/src/spawner.rs | Adds named new_custom, internal new_with_layers, and custom Debug for Spawner. |
| crates/anyspawn/src/lib.rs | Exposes CustomSpawnerBuilder and BoxedFuture behind custom feature; updates docs. |
| crates/anyspawn/src/custom.rs | Extends CustomSpawner to carry name/layer metadata and improved Debug. |
| crates/anyspawn/src/builder.rs | Adds CustomSpawnerBuilder implementation (layering + build). |
| crates/anyspawn/examples/otel_context.rs | New example demonstrating OpenTelemetry context propagation via a layer. |
| crates/anyspawn/examples/custom.rs | Updates example to provide a custom spawner name. |
| crates/anyspawn/benches/spawner.rs | Updates benchmark custom spawner creation to include name. |
| crates/anyspawn/README.md | Updates README example and feature list to mention builder. |
| crates/anyspawn/Cargo.toml | Adds dev-deps (insta, opentelemetry) and registers new example. |
| Cargo.lock | Pulls in new dev dependency entries. |
| .spelling | Adds “typestate” to spelling dictionary. |
Comments suppressed due to low confidence (1)
crates/anyspawn/src/spawner.rs:12
Futureis referenced in thespawnmethod signature (impl Future<Output = T>) butstd::future::Futureis not imported anywhere in this module. This is a compile error; adduse std::future::Future;(or usestd::future::Futurein the signature).
use std::fmt::{self, Debug};
#[cfg(feature = "custom")]
use std::sync::Arc;
#[cfg(feature = "custom")]
use crate::custom::{BoxedFuture, CustomSpawner};
use crate::handle::JoinHandle;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #308 +/- ##
=======================================
Coverage 100.0% 100.0%
=======================================
Files 152 153 +1
Lines 9337 9401 +64
=======================================
+ Hits 9337 9401 +64 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
What is the indented audience for this change? For example, when using directly types form oxidizer runtime, my expectation is that context propagation is handled transparently, or do I have to use spawner to preserve it? |
unfortunately, otel context is not automatically propagated to child tasks/new threads. It has to be done manually |
|
What other use cases would use this abstraction? Could we solve this by integrating OTel directly? |
I think in general it's a useful abstraction to have for everyone who wants to track/intercept spawned tasks in some way for example:
|
770b212 to
ca2fc2e
Compare
ca2fc2e to
0b9b941
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0b9b941 to
f89d667
Compare
No description provided.