Skip to content

Comments

feat: introduce layered crate#189

Merged
martintmk merged 24 commits intomainfrom
u/mtomka/layered
Jan 12, 2026
Merged

feat: introduce layered crate#189
martintmk merged 24 commits intomainfrom
u/mtomka/layered

Conversation

@martintmk
Copy link
Member

@martintmk martintmk commented Jan 7, 2026

Summary

Introduces layered, a modern service abstraction crate for building composable async services with middleware.

Key features:

  • Service trait using native async fn with &self - no manual Future types or boxing required
  • Layer and Stack for composing middleware using ergonomic tuple syntax: (layer1, layer2, service).build()
  • Execute helper to convert closures into services
  • Intercept middleware for observing/modifying inputs and outputs (logging, metrics, validation)
  • DynamicService for type erasure when concrete types become unwieldy
  • Bidirectional Tower interoperability via the tower module

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

⚠️ Breaking Changes Detected

error: failed to retrieve local crate data from git revision

Caused by:
    0: failed to retrieve manifest file from git revision source
    1: possibly due to errors: [
         failed when reading /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/bb696d98146cef7b01a76566973996c83f574451/scripts/crate-template/Cargo.toml: TOML parse error at line 9, column 26
         |
       9 | keywords = ["oxidizer", {{CRATE_KEYWORDS}}]
         |                          ^
       missing key for inline table element, expected key
       : TOML parse error at line 9, column 26
         |
       9 | keywords = ["oxidizer", {{CRATE_KEYWORDS}}]
         |                          ^
       missing key for inline table element, expected key
       ,
         failed to parse /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/bb696d98146cef7b01a76566973996c83f574451/Cargo.toml: no `package` table,
       ]
    2: package `layered` not found in /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/bb696d98146cef7b01a76566973996c83f574451

Stack backtrace:
   0: anyhow::error::<impl anyhow::Error>::msg
   1: cargo_semver_checks::rustdoc_gen::RustdocFromProjectRoot::get_crate_source
   2: cargo_semver_checks::rustdoc_gen::StatefulRustdocGenerator<cargo_semver_checks::rustdoc_gen::CoupledState>::prepare_generator
   3: cargo_semver_checks::Check::check_release::{{closure}}
   4: cargo_semver_checks::Check::check_release
   5: cargo_semver_checks::exit_on_error
   6: cargo_semver_checks::main
   7: std::sys::backtrace::__rust_begin_short_backtrace
   8: main

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).

Copy link
Member

@geeknoid geeknoid left a comment

Choose a reason for hiding this comment

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

For the logo, how about a crab thinking of a crab in a thought bubbken, and the crab in the thought bubble thinking of another crab in a thought bubble, etc.

@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #189    +/-   ##
========================================
  Coverage   100.0%   100.0%            
========================================
  Files          98      104     +6     
  Lines        6541     6784   +243     
========================================
+ Hits         6541     6784   +243     

☔ 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.

@martintmk martintmk marked this pull request as ready for review January 12, 2026 15:36
@martintmk martintmk enabled auto-merge (squash) January 12, 2026 17:01
@martintmk martintmk merged commit ac52183 into main Jan 12, 2026
20 checks passed
@martintmk martintmk deleted the u/mtomka/layered branch January 12, 2026 17:06
@ralfbiedert
Copy link
Collaborator

Sorry, I did not get to review this last week. That said, could we do a follow-up PR addressing a few issues:

  • cargo doc gives me various warnings coming from layer, like warning: unresolved link to DynamicService --> crates/layered/src/lib.rs:113:40
  • most tests should be moved to tests/
  • the "Key Concepts" section is to short and doesn't quite make sense to me. For example, when you write "Service: An async function In → Out that processes inputs" you seem to want to say that a Service acts like a function (as it transforms some input to some output), but clearly it's a type with a trait implementation. I think all of these entries should be more clarified. I also wouldn't use the term "factory".
  • The example below that ("Layers and Middleware") doesn't work out well what a middleware actually is. It seems to be left as an exercise for the reader
  • Why is Execute called that? Shouldn't this be a ServiceFn or so?

Also, some docs look like so (apparently related to warnings above)

image

@geeknoid
Copy link
Member

@ralfbiedert To make cargo doc happy, give it the --all-features options.

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.

4 participants