Skip to content

feat(anyspawn)!: add CustomSpawnerBuilder for composing multilayered spawner#308

Merged
Vaiz merged 17 commits intomainfrom
u/vaiz/2026/03/06/anyspawn-experiment
Mar 12, 2026
Merged

feat(anyspawn)!: add CustomSpawnerBuilder for composing multilayered spawner#308
Vaiz merged 17 commits intomainfrom
u/vaiz/2026/03/06/anyspawn-experiment

Conversation

@Vaiz
Copy link
Contributor

@Vaiz Vaiz commented Mar 6, 2026

No description provided.

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

⚠️ Breaking Changes Detected


--- failure method_parameter_count_changed: pub method parameter count changed ---

Description:
A publicly-visible method now takes a different number of parameters, not counting the receiver (self) parameter.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#fn-change-arity
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/method_parameter_count_changed.ron

Failed in:
  anyspawn::Spawner::new_custom now takes 2 parameters instead of 1, in /home/runner/work/oxidizer/oxidizer/crates/anyspawn/src/spawner.rs:154

If the breaking changes are intentional then everything is fine - this message is merely informative.

Remember to apply a version number bump with the correct severity when publishing a version with breaking changes (1.x.x -> 2.x.x or 0.1.x -> 0.2.x).

@Vaiz Vaiz requested a review from Copilot March 6, 2026 16:00
@Vaiz Vaiz requested a review from schgoo March 6, 2026 16:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CustomSpawnerBuilder for composing named layers and building a Spawner.
  • Make custom spawners and Spawner debug output include spawner/layer names; update Spawner::new_custom to accept a name.
  • 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

  • Future is referenced in the spawn method signature (impl Future<Output = T>) but std::future::Future is not imported anywhere in this module. This is a compile error; add use std::future::Future; (or use std::future::Future in 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
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (6ec4849) to head (f89d667).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI review requested due to automatic review settings March 9, 2026 09:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@martintmk
Copy link
Member

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?

@Vaiz
Copy link
Contributor Author

Vaiz commented Mar 9, 2026

What is the indented audience for this change? For example, when using directly types from 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

@schgoo
Copy link
Collaborator

schgoo commented Mar 9, 2026

What other use cases would use this abstraction? Could we solve this by integrating OTel directly?

@Vaiz
Copy link
Contributor Author

Vaiz commented Mar 10, 2026

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:

  • count number of tasks
  • wrap them to track poll/pending time
  • throttle
  • many other use cases

@Vaiz Vaiz force-pushed the u/vaiz/2026/03/06/anyspawn-experiment branch from 770b212 to ca2fc2e Compare March 10, 2026 15:44
@Vaiz Vaiz force-pushed the u/vaiz/2026/03/06/anyspawn-experiment branch from ca2fc2e to 0b9b941 Compare March 11, 2026 14:13
Copilot AI review requested due to automatic review settings March 11, 2026 14:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Vaiz Vaiz force-pushed the u/vaiz/2026/03/06/anyspawn-experiment branch from 0b9b941 to f89d667 Compare March 11, 2026 14:46
@Vaiz Vaiz merged commit d60d207 into main Mar 12, 2026
27 checks passed
@Vaiz Vaiz deleted the u/vaiz/2026/03/06/anyspawn-experiment branch March 12, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants