quarkiverse / quarkus-temporal

Temporal (https://temporal.io/) is a developer-first, open source platform that ensures the successful execution of services and applications.
https://docs.quarkiverse.io/quarkus-temporal/dev
Apache License 2.0
3 stars 1 forks source link

Interceptors: Respect `@Priority` #88

Closed melloware closed 2 weeks ago

melloware commented 2 weeks ago

@rmanibus i feel like because it seems like Interceptors are executed in the order they are in the List we should respect Priority like other Quarkus Extensions do?

@Priority(99) // high priority
@Singleton
@Unremovable
public class FirstWorkflowClientInterceptor implements WorkflowClientInterceptor {}

@Priority(2) // low priority
@Singleton
@Unremovable
public class SecondWorkflowClientInterceptor implements WorkflowClientInterceptor {}

This way users have control over the order of interceptors?

cc @tmulle

rmanibus commented 2 weeks ago

This is doable but will probably require some build time work to introspect the annotations

melloware commented 2 weeks ago

I actually wonder if its something built into Arc CDI as I am seeing a lot of use of @Priority in the Quarkus Core but mostly just in tests never in Extensions when doing a select. So I wonder of Instance<XXX> already respects Priority at the CDI level?

tmulle commented 2 weeks ago

I found this reference for @Priority. If you search for that annotation on the page. https://quarkus.io/guides/cdi-reference

melloware commented 2 weeks ago

it looks like this one https://quarkus.io/guides/cdi-reference#injecting-multiple-bean-instances-intuitively if we inject @All the list is supposed to respect the Priority.

tmulle commented 2 weeks ago

These sections too: "Default beans can optionally declare @jakarta.annotation.Priority. If there is no priority defined, @Priority(0) is assumed. Priority value is used for bean ordering and during typesafe resolution to disambiguate multiple matching default beans"

https://quarkus.io/guides/cdi-reference#declaring-selected-alternatives

"In CDI, an alternative bean may be selected either globally for an application by means of @Priority, or for a bean archive using a beans.xml descriptor. Quarkus has a simplified bean discovery and the content of beans.xml is ignored.

However, it is also possible to select alternatives for an application using the unified configuration. The quarkus.arc.selected-alternatives property accepts a list of string values that are used to match alternative beans. If any value matches then the priority of Integer#MAX_VALUE is used for the relevant bean. The priority declared via @Priority or inherited from a stereotype is overridden."

melloware commented 2 weeks ago

Added a unit test showing its not working currently.