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

Provide option to create asyncapi lazy #292

Closed
tvahrst opened this issue Jul 15, 2023 · 1 comment
Closed

Provide option to create asyncapi lazy #292

tvahrst opened this issue Jul 15, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@tvahrst
Copy link
Contributor

tvahrst commented Jul 15, 2023

The asyncapi and channel retrieval logic is impelemented in @PostConstruct methods inside DefaultAsyncApiService and DefaultChannelService - which means that the asyncapi detection runs during creation of the central spring(boot) context. This has an impact on the startup time of a spring boot application (especially if the scanning scope - springwolf.docket.base-package is large).

I suggest to provide an option to create the asyncapi lazy on first invocation of getAsyncApi. This option could be implemented as 'fail-fast' Property: true = current behavior, false = lazy asyncapi creation.

Motivation
Beside a better startup-performance, there is an additional advantage: we could pass context parameters between DefaultAsyncApiService and DefaultChannelService. This could help to implement additional functionality - for example an early validation of channel annotations against properties provided in a docket. (see additional feature request #293 ).

Technical details

  • DefaultChannelService becames a stateless service which provides a channel map. @PostConstruct will be removed, the findChannels method will scan for channels and return the resulting map.
  • DefaultAsyncApiService will cache a created asyncapi. The class supports two modes:
    • 'fail-fast' = true : The detection/creation of asyncapi will run in 'afterPropertiesSet' (synonym to @PostConstruct) - on bean creation. An exception will interrupt the spring context creation (i.e. the application start). The springwolf behavior stays compatible.
    • fail-fast = false: The detection/creation of asyncapi will run on first invocation of getAsyncApi. An exception during asyncapi creation will be cached and thrown each time getAsyncApi is invoced.
@timonback
Copy link
Member

Thank your for the report, the issue has been addressed in the new release.

Feel free to reopen this issue if there is still something missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants