Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Cacheable annotation is not clear #155

Open
tomaszmichalak opened this issue May 12, 2020 · 0 comments
Open

@Cacheable annotation is not clear #155

tomaszmichalak opened this issue May 12, 2020 · 0 comments

Comments

@tomaszmichalak
Copy link
Member

I checked what factories are flagged with this annotation:

  • Circuit Breaker Action
  • HTTP Action
  • Knot Action
  • In-Memory Cache Action
  • Inline Payload Action
  • Inline Body Action

The stateful action is Circuit Breaker Action.

Other actions are stateless - it means that we would not break the logic by creating new instances each time. We added this annotation for better performance (I am guessing).

There are a few options what we can do:

  • we remove this annotation and we care about instances in action factories - each factory decides if the new or existing instance is returned
    • we need to have a cache per action factory instance
    • custom action implementations are more complex
    • we duplicate the same code in many places
  • move the annotation @Singleton to the io.knotx.fragments.action.api.ActionFactory#create method,
    • it is singleton per "action name", it means that we would get different instances for different action names
    • it is not easy to guess what is the reason for being singleton - stateful nature or some performance improvements
  • introduce @Stateful and @Singleton annotations, they would have the same "behaviour" but they will be self-descriptive.

Originally posted by @tomaszmichalak in #154

@tomaszmichalak tomaszmichalak mentioned this issue May 12, 2020
6 tasks
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

No branches or pull requests

1 participant