feat: inject attributes declared on handler into closure expressions (Enterprise)#685
Merged
Merged
Conversation
…(Enterprise) Closure expressions could resolve #[Header], #[Payload], #[Reference] and friends, but not an Attribute declared on the owning handler. Such a parameter fell through to payload conversion or a container lookup, failing with a misleading error. Resolve attribute typed closure parameters against the owning method, then the owning class, reusing AttributeBuilder so resolution stays lazy and survives the dumped container. Also adds coverage for propagating tenant header into #[ConsoleCommand].
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why is this change proposed?
Closure expressions can resolve
#[Header],#[Payload],#[Reference]and friends, but not an Attribute declared on the handler they sit on. A closure parameter type hinted with such an Attribute was treated as the payload, or looked up as a service in the container, and failed with a misleading error.This left configuration and behaviour unable to sit together: an Attribute can declare policy next to the endpoint, but the expression deciding how to act on that policy could not read it. The same closure had to be duplicated per variation, or the policy hardcoded into the closure.
Description of Changes
AttributeBuilder/AttributeReferencemechanism, so the attribute is resolved lazily through reflection and survives the dumped container (covered cold and warm).VerifyEnterpriseLicenceForClosureExpressionsalready covers anything reached through a closure expression.ConsoleCommandTenantPropagationTest, covering tenant header propagation into#[ConsoleCommand]and onward into a Command Bus sub-flow.Example
Configuration is declared once as an Attribute, and a single shared closure adapts to it:
Changing
scopeto'order'switches deduplication to per order, with the closure left untouched.Pull Request Contribution Terms
Drafted with /superpowers:test-driven-development, /superpowers:verification-before-completion, /ecotone-contributor.