Skip to content

Commit 2a1b92d

Browse files
Introduce attribute-based components (#478)
We introduce new attribute macros to mark methods or functions as constructors: - `#[pavex::constructor]` - `#[pavex::request_scoped]` - `#[pavex::transient]` - `#[pavex::singleton]` We also introduce a new `Blueprint` method, `import`, to determine which annotated constructors are in scope at any given time, mimicking the behaviour of Rust's `use` (as well as its syntax). ## Internal refactors ### Diagnostics Beyond the changes required to find, validate and consider the new components, I also had to extensively rework our diagnostic system to provide a higher-level API, capable of abstracting over the way a component was registered. The outcome is a net positive change: working with spans is a lot easier now, and the code has clearer intent than before. ### `OrderedCallGraph` In order to simplify debugging, `OrderedCallGraph` has been reworked to embed the ordering the in the node indices rather than using an external `id <> position` mapping. This caused a lot of churn in our diagnostic snapshots.
1 parent 0404d2f commit 2a1b92d

File tree

413 files changed

+92126
-13069
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

413 files changed

+92126
-13069
lines changed

CHANGELOG.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [0.1.80](https://github.com/LukeMathWalker/pavex/compare/0.1.79...0.1.80) - 2025-03-22
1111

12-
1312
### 🐛 Bug Fixes
13+
1414
- Always check if pavexc dependencies are installed (by @LukeMathWalker) - #475
1515
- Fix the path to the configuration folder in the Dockerfile of the starter project (by @LukeMathWalker) - #475
1616

17-
1817
### Contributors
1918

20-
* @LukeMathWalker
19+
- @LukeMathWalker
2120

2221
## [0.1.79](https://github.com/LukeMathWalker/pavex/compare/0.1.78...0.1.79) - 2025-03-14
2322

doc_examples/quickstart/05-error.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
│ 12if let UserAgent::Unknown = user_agent {
1919
│ ╰────
2020
│ help: Register a constructor for `app::user_agent::UserAgent`.
21-
[31m│[0m [36m help: [0mAlternatively, use `Blueprint::prebuilt` to add a new input
21+
[31m│[0m [36mhelp:[0m Alternatively, use `Blueprint::prebuilt` to add a new input
2222
│ parameter of type `app::user_agent::UserAgent` to the (generated)
2323
│ `ApplicationState::new` method.

doc_examples/quickstart/07-error.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
│ · The fallible constructor was registered here
1111
│ 14
1212
│ ╰────
13-
[31m│[0m [36m help: [0mAdd an error handler via `.error_handler`
13+
[31m│[0m [36mhelp:[0m Add an error handler via `.error_handler`

0 commit comments

Comments
 (0)