-
Notifications
You must be signed in to change notification settings - Fork 80
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
support lazy, fail-fast and background initialization of asyncapi #297
Conversation
✅ Deploy Preview for springwolf-ui canceled.
|
...wolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiService.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned before, I like the change.
It may look like a lot of comments, but it is mostly nitpicking of details.
- I like the 3 options and view
failFast
andbackground
as essential.lazy
comes for free, but I wonder if we need it. I am thinking from the point of view of maintaining it. When it is out there, we cannot change/remove it. Is there a benefit to have lazy in comparison on background? - Personally, I view the feature as an expert/optimization setting. Therefore I would go with failFast as the default and opt in to other modes (and documented it on the website).
Where am I coming from? As a first time user, I want to quickly see if I have configured everything right. When the spring application starts, that's my indicator that everything is fine (I might not even view logs by default). Delaying it could create user frustration as it is not visible why the application is starting (and the ui showing), but the document is empty and/or has a REST endpoint exception. - Good question regarding the naming. I can imagine also
startUpMode
and probably preferinit-mode / initMode
out of the 3 options. - A stateless ChannelsService is great, as well as the improved naming of the methods. Yes, there is a side-effect, but I do not view it as a risk at this point.
- Caching the getAsyncApi result is great, including the behaviour to rethrow the cached exception.
- The word
detect
indicates to me that some is found/discovered (like the channels). For the AsyncApi document, I think it is rather build/constructed/generated.
I might be in the wrong, so feel free to ask questions and/or explain why another way/your suggestions is better.
Thanks again for the contribution.
...wolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiService.java
Outdated
Show resolved
Hide resolved
...wolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiService.java
Outdated
Show resolved
Hide resolved
...wolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiService.java
Show resolved
Hide resolved
...ava/io/github/stavshamir/springwolf/configuration/properties/SpringWolfConfigProperties.java
Show resolved
Hide resolved
...ava/io/github/stavshamir/springwolf/configuration/properties/SpringWolfConfigProperties.java
Show resolved
Hide resolved
...e/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiServiceUnitTest.java
Outdated
Show resolved
Hide resolved
...e/src/test/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiServiceUnitTest.java
Outdated
Show resolved
Hide resolved
...qp-plugin/src/main/java/io/github/stavshamir/springwolf/producer/SpringwolfAmqpProducer.java
Show resolved
Hide resolved
...olf-core/src/test/java/io/github/stavshamir/springwolf/integrationtests/LoadingModeTest.java
Outdated
Show resolved
Hide resolved
...wolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/DefaultAsyncApiService.java
Outdated
Show resolved
Hide resolved
Good points. I will try to apply the suggested modifications... |
Co-authored-by: Timon Back <[email protected]>
…ground' and 'fail_fast'. Moved Initialization completley into AsyncApiInitApplicationListener. Fixed some tests. Took 47 minutes
I changed 'LoadingMode' into 'InitMode'. Removed 'lazy', so there are two options left: 'background' and 'fail_fast'. Default is 'fail_fast'. Moved the initialization completely into the Cleaned up some tests. |
The changes look good to me. I made some changes so that initMode=lazy actually fails the start of the spring boot application: https://github.com/LVM-IT/springwolf-core/pull/1 |
feat(core): Ensure initMode=lazy stops application start
Documentation: springwolf/springwolf.github.io#49 |
This PR adresses issue #292 (provide option to create asyncapi lazy).
It introduces a new Property
springwolf.loading-mode
with three possible values:AsyncApiService.getAsyncApi()
.The default value ist LAZY
Some points that might be worth discussing:
DefaultChannelService
is stateless now, it does not cache the detectedChannelItem
s. I changed the service's method fromgetChannels()
tofindChannels()
to avoid 'getter' semantics, which could be interpreted as cheap 'get' operations.findChannels
always invokes the scanners to aquire the available channels.DefaultChannelService
has a sideeffect onSchemasService
.SchemasService
is a kind of registry, invoked by scanners and caching all detetected schemas. RepeatedfindChannels()
calls replaces the schemas inSchemaService
. This is currently no problem, becausefindChannels()
is only called once andSchemasService
can handle multiple registrations of the same schema. If that seems to be a risk,DefaultChannelService
should assure to call all scanners only once.getAsyncApi
call.