Commit 2a1b92d
authored
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- doc_examples/quickstart
- examples
- realworld/server_sdk/src
- starter/server_sdk/src
- libs
- generate_from_path
- pavex_bp_schema
- src
- pavex_cli_client
- pavex_cli_deps
- pavex_cli_diagnostic
- src
- pavex_cli_flock
- pavex_cli_shell
- pavex_cli
- src
- activation
- pavex_macros
- src
- constructor
- tests
- constructor/fail
- from
- fail
- success
- path_params
- fail
- success
- pavex_miette
- pavex_reflection
- src
- pavex_session_memory_store
- pavex_session_sqlx
- pavex_session
- pavex_test_runner
- src
- pavex_tracing
- pavexc_attr_parser
- src
- tests
- pavexc_cli_client
- pavexc_cli
- src
- pavexc_rustdoc_types
- src
- pavexc
- src
- compiler
- analyses
- application_state
- call_graph
- borrow_checker
- components
- db
- processing_pipeline
- user_components
- component
- diagnostic
- miette
- language
- rustdoc
- compute
- pavex
- src
- blueprint
- config
- constructor
- import
- middleware
- post
- pre
- wrapping
- prebuilt
- router
- kit
- persist_if_changed
- px_workspace_hack
- ui_tests
- annotations
- annotated_constructor_works
- expectations
- src
- non_existing_dependency
- expectations
- src
- app_builder
- expectations
- blueprint
- common
- async_callable_are_supported
- expectations
- cannot_return_the_unit_type
- expectations
- src
- cannot_take_mutable_references_as_input
- expectations
- src
- cloning_if_necessary_requires_clone
- expectations
- src
- cloning_strategy_is_observed_for_singletons_and_state_inputs
- expectations
- src
- components_can_fail
- expectations
- src
- output_type_must_implement_into_response
- expectations
- src
- config
- config_conflicts/expectations
- config_does_not_need_to_be_send_and_sync_if_only_used_at_build_time
- expectations
- config_works
- expectations
- invalid_config/expectations
- constructors
- a_warning_is_emitted_for_unused_constructors
- expectations
- src
- constructor_error_spans_are_correct_for_prebuilt_constructors/expectations
- constructors_input_parameters_cannot_be_generic
- expectations
- src
- output_type_of_constructors_can_contain_generic_parameters
- expectations
- output_type_of_constructors_cannot_be_a_naked_generic/expectations
- singleton_naming
- expectations
- static_references_are_valid_singletons
- expectations
- src
- the_latest_registered_constructor_takes_precedence
- expectations
- the_same_constructor_can_be_registered_multiple_times_using_the_same_lifecycle
- expectations
- trait_constraints_on_runtime_singletons/expectations
- unused_constructor_warning_can_be_ignored
- expectations
- error_handlers
- cannot_register_an_error_handler_for_a_sync_infallible_constructor/expectations
- cannot_register_an_error_handler_for_an_async_infallible_constructor/expectations
- error_handlers_can_take_pavex_error_rather_than_specific_error_type
- expectations
- generics_in_error_handlers_must_be_tied_to_the_error/expectations
- error_observers/error_observers_input_parameters_cannot_be_generic/expectations
- nesting
- application_state_should_include_runtime_singletons_from_all_scopes
- expectations
- multiple_levels_of_nesting_are_supported
- expectations
- nesting_fails_if_parent_singleton_is_overridden/expectations
- nesting_fails_if_the_same_singleton_constructor_is_registered_in_different_scopes/expectations
- nesting_hides_constructors_of_the_nested_bp_to_the_parent_bp/expectations
- post_processing_middlewares
- cannot_have_multiple_response_inputs/expectations
- finalizer_pattern
- expectations
- post_process_without_wrapping
- expectations
- post_processing_middlewares_input_parameters_cannot_be_generic/expectations
- pre_processing_middlewares
- pre_process_without_wrapping
- expectations
- pre_processing_middlewares_input_parameters_cannot_be_generic/expectations
- prebuilts
- invalid_prebuilt/expectations
- prebuilt_does_not_need_to_be_send_and_sync_if_only_used_at_build_time
- expectations
- prebuilt_works
- expectations
- prebuilts_can_be_cloned
- expectations
- unused_prebuilt
- expectations
- router
- ambiguous_fallback/expectations
- conflicting_any_and_single_method_guards/expectations
- different_fallback_for_each_method/expectations
- domain_conflict/expectations
- domain_routing
- expectations
- fallback_priority
- expectations
- http_method_routing_variants
- expectations
- mixed_domain_and_agnostic_is_forbidden/expectations
- path_prefix_is_validated/expectations
- request_handlers_can_take_mut_references
- expectations
- route_path_is_validated/expectations
- wrapping_middlewares
- cannot_have_multiple_next_inputs/expectations
- next_must_take_a_naked_generic_parameter/expectations
- wrapping_middlewares_input_parameters_cannot_be_generic/expectations
- borrow_checker
- across_middlewares/type_is_cloned_if_consumed_by_wrap_but_needed_by_post
- expectations
- cannot_borrow_clonable_request_scoped_as_mut/expectations
- cannot_borrow_singletons_as_mut/expectations
- cannot_borrow_transients_as_mut/expectations
- control_flow/you_can_consume_a_non_cloneable_type_from_two_different_control_flow_branches
- expectations
- diamond
- diamond_can_be_solved_if_type_is_copy
- expectations
- diamond_can_be_solved_if_we_can_clone
- expectations
- mixed_mutability
- expectations
- multiple_consumers
- a_clonable_framework_type_can_be_moved_twice
- expectations
- a_clonable_input_type_can_be_moved_twice
- expectations
- a_clonable_type_can_be_moved_twice_when_building_app_state
- expectations
- a_clonable_type_can_be_moved_twice
- expectations
- a_copy_type_can_be_moved_twice
- expectations
- triangle
- triangle_can_be_solved_if_framework_type_is_clonable
- expectations
- triangle_can_be_solved_if_input_type_is_clonable
- expectations
- triangle_can_be_solved_if_type_is_clonable
- expectations
- triangle_can_be_solved_if_type_is_copy
- expectations
- triangle_with_middleware_can_be_solved_if_type_is_clonable
- expectations
- connection_info
- connection_info_fallback_happy_path
- expectations
- connection_info_happy_path
- expectations
- dependency_injection
- clone_nodes_are_only_added_where_needed
- expectations
- cycles
- cycle_across_a_match_statement/expectations
- request_scoped_cycles/expectations
- transient_cycles/expectations
- downstream_code_needs_both_owned_and_ref_to_same_type
- expectations
- elided_lifetimes_are_handled
- expectations
- fallbacks_can_access_all_primitives
- expectations
- lifecycles
- non_static_references_cannot_be_singletons/expectations
- singletons_cannot_have_non_static_lifetime_parameters/expectations
- missing_handler_dependency/expectations
- missing_singleton_dependency/expectations
- next_state_is_populated_correctly
- expectations
- pavex_honors_the_restrictions_on_generics_introduced_by_constructors/expectations
- references_to_constructible_types_are_allowed
- expectations
- error_observers
- error_observer_with_generic_error
- expectations
- error_observers_can_depend_on_fallible_singletons
- expectations
- error_observers_happy_path
- expectations
- middlewares
- middlewares_execution_order
- expectations
- next_handles_lifetimes
- expectations
- next_handles_mut_references
- expectations
- path_parameters
- path_parameters_happy_path
- expectations
- path_parameters_non_existing_fields/expectations
- path_parameters_unsupported_types/expectations
- reflection
- a_fix_is_suggested_for_function_invocations/expectations
- always_use_public_path
- expectations
- ambiguous_dependency_version_is_handled
- expectations
- arc_singletons_are_supported
- expectations
- common_response_types_are_supported
- expectations
- crate_resolution
- dependencies_can_register_local_items
- expectations
- multiple_versions_for_the_same_crate_are_supported
- expectations
- remote_callable_paths_must_be_absolute/expectations
- transitive_dependencies_can_be_renamed
- expectations
- generic_handlers_are_supported
- expectations
- generic_parameters_can_come_from_another_crate
- expectations
- invalid_callable_path
- expectations
- src
- lifetime_restrictions_are_handled
- expectations
- local_callable_paths_must_be_prefixed_with_crate/expectations
- local_glob_reexports_are_supported
- expectations
- non_static_methods_are_supported
- expectations
- pattern_bindings_in_input_parameters_are_supported
- expectations
- reexported_type_alias_work
- expectations
- relative_paths_prefixed_with_self_are_supported
- expectations
- relative_paths_prefixed_with_super_are_supported
- expectations
- self_as_generic_parameter_is_supported
- expectations
- static_methods_are_supported
- expectations
- the_path_for_generic_arguments_must_be_absolute/expectations
- trait_methods_are_supported
- expectations
- trait_methods_with_non_local_generics_are_supported
- expectations
- tuples_are_supported
- expectations
- type_alias_are_supported
- expectations
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| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | | - | |
| 19 | + | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
0 commit comments