-
Notifications
You must be signed in to change notification settings - Fork 8
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 Spring Boot 2 #87
Conversation
README.md
Outdated
@@ -40,7 +40,8 @@ You may of course always setup a fresh system with the newest version. | |||
|
|||
## Prerequisites | |||
|
|||
This library was tested with Spring Boot 1.5.3.RELEASE and relies on an existing configured PostgreSQL DataSource. | |||
This library was tested with Spring Boot 2.0.3.RELEASE and relies on an existing configured PostgreSQL DataSource. If | |||
you are still using Spring Boot 1.x, please use version 4.2.0 ([Release Notes](https://github.com/zalando-nakadi/nakadi-producer-spring-boot-starter/releases/tag/4.2.0), [Documentation](https://github.com/zalando-nakadi/nakadi-producer-spring-boot-starter/blob/4.2.0/README.md)) versions of this library. |
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.
The approach of making Spring-Boot 2 a dependency means that providing new features for applications which are still using Spring-Boot 1.x will be difficult (need to work on a separate branch?) or not done at all. I'm a bit hesitant to do this, given that the majority of the host-apps known to us are still based on Spring-Boot 1, and we still have quite some items in the wishlist which don't look like they would require Spring-Boot 2.
As an alternative approach, could we consider creating a new artifact (e.g. nakadi-producer-spring-boot-2-starter
) in parallel to the existing nakadi-producer-spring-boot-starter
(which would still support Spring Boot 1)? Both could be using the common nakadi-producer
base library.
e62d2b1
to
e74994e
Compare
a83551f
to
e74994e
Compare
Does this fix #72 (for the spring-boot 2 branch)? |
README.md
Outdated
|
||
will trigger a snapshot for the event type `my.event-type`. The (optional) request body is a "filter specifier". | ||
will trigger a snapshot for the event type `my.event-type`. There is an optional request parameter called "filter" that |
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.
A bit below (line 243 currently) we are still talking about "filter specifier", this should be adapted.
@@ -22,10 +29,9 @@ | |||
private DataSource dataSource; | |||
|
|||
@Autowired(required = false) | |||
@NakadiProducerFlywayCallback | |||
private FlywayCallback callback; | |||
private List<NakadiProducerFlywayCallback> callback; |
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.
If this is a list, could we name it in plural (callbacks
)?
flyway.setBaselineOnMigrate(true); | ||
flyway.setBaselineVersionAsString("2133546886.1.0"); | ||
flyway.migrate(); | ||
} | ||
|
||
private static class FlywayCallbackAdaptor extends BaseFlywayCallback { |
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.
Could we use the more common spelling "Adapter"?
(Adapter vs. Adaptor: What’s the Difference? → none, Adapter pattern)
|
||
/** | ||
* Qualifier annotation for a FlywayCallback to be injected in to nakadi-producer's Flyway instance. | ||
* This is the main callback interface that should be implemented to get access to flyway lifecycle notifications. | ||
* Simply add code to the callback method you are interested in having. |
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.
Could we use default
implementations for those methods doing nothing, so a host app doesn't need to implement all of them, if not all are needed?
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.
Fixed.
public void invoke(String eventType, String filter) { | ||
snapshotCreationService.createSnapshotEvents(eventType, filter); | ||
@WriteOperation | ||
public void createFilteredSnapshotEvents(@Selector String arg0, @Nullable String filter) { |
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.
Nicer parameter name, please?
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.
could do so, but because of some wild java compiler flag foo spring boot is doing here, it might than get quite itchy to get the test to run in the IDE. i guess i'll add a comment instead
@Test | ||
@DirtiesContext // Needed to make sure that flyway gets executed for each of the tests and Callbacks are called again | ||
public void flywayConfigurationIsSetIfCallbackIsConfigurationAware() { | ||
verify(configurationAwareNakadiProducerFlywayCallback).setFlywayConfiguration(any(FlywayConfiguration.class)); |
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.
Can we (and do we want to) verify that this method is called before the actual callback methods?
public void ourOwnFlywayConfigurationStillWorksFineWhenSpringsFlywayAutoconfigIsDisabled() { | ||
// Yes, this is redundant to the other test in here. | ||
// We consider it important to document the requirement, so it is here nonetheless. | ||
// This test does just enough to test it. |
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.
Maybe this could be reworded to "The test setup done by the class annotations do just enough to test it"?
@@ -21,13 +21,13 @@ | |||
@RunWith(SpringRunner.class) | |||
@SpringBootTest( | |||
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, | |||
properties = { "management.security.enabled=false", "zalando.team.id:alpha-local-testing", "nakadi-producer.scheduled-transmission-enabled:false" }, | |||
properties = { "management.security.enabled=false", "zalando.team.id:alpha-local-testing", "nakadi-producer.scheduled-transmission-enabled:false", "management.endpoints.web.exposure.include:snapshot-event-creation" }, |
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.
Can we get some line breaks here? I have to scroll in Github to read it all.
classes = { TestApplication.class, EmbeddedDataSourceConfig.class, SnapshotEventGenerationWebEndpointIT.Config.class } | ||
) | ||
public class SnapshotEventGenerationWebEndpointIT { | ||
|
||
private static final String MY_EVENT_TYPE = "my.event-type"; | ||
private static final String MY_REQUEST_BODY = "my request body"; | ||
private static final String filter = "myRequestBody"; |
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.
Constants in upper case, please?
.when().post("/snapshot_event_creation/" + MY_EVENT_TYPE) | ||
.then().statusCode(200); | ||
.contentType("application/json") | ||
.when().post("/actuator/snapshot-event-creation/" + MY_EVENT_TYPE + "?filter=" + filter) |
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.
Ah, I somehow missed that this is not a body parameter anymore. This should certainly be called out in the PR comment, and the Release notes.
Was this an intentional change, or a side effect of the new actuator stuff?
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.
the later. It can still be given in the request body, but the format has changed. Already documented the changed format in the Readme, just pushed an additional IT to make sure the Format stays stable and included the fact in my release notes draft
README.md
Outdated
|
||
will trigger a snapshot for the event type `my.event-type`. The (optional) request body is a "filter specifier". | ||
will trigger a snapshot for the event type `my.event-type`. There is an optional request parameter called "filter" that |
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.
"request parameter" → "query parameter", just to make it clear what is happening.
public SnapshotEventGenerator snapshotEventGenerator() { | ||
return new SimpleSnapshotEventGenerator("eventtype", new BiFunction<Object, String, List<Snapshot>>() { | ||
@Override | ||
public List<Snapshot> apply(Object withIdGreaterThan, String filter) { |
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.
Those three lines can be shortened using Java 8's Lambda syntax:
return new SimpleSnapshotEventGenerator("eventtype", (Object withIdGreaterThan, String filter) -> {
(and one }
at the end gets lost too). That was the reason to implement the SimpleSnapshotEventGenerator at all.
} | ||
}); | ||
|
||
// Todo: Test that some events arrive at a local nakadi mock |
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.
Not yet usable, but to get an idea: https://github.com/ePaul/nakadi-mock
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.
Woow, cool, keep us updated on the progress!
@@ -0,0 +1 @@ | |||
my fake token |
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.
How is this file used?
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.
Ah, in the integration test. Could this go into src/test/resources?
👍 |
… startup. Let's see what comes next.
- Documented that 4.2.0 should be used, if one is still using Spring Boot 1 - Spring Boot acutator got a big API rework in Spring Boot 2 so a lot of adaptions were neccessary here: -- Endpoints are not exposed via HTTP by default any more, has to be configured explicitly => documented -- Endpoint code is now technology independent and works out of the box with HTTP and JMX => removed the MvcEndpoint -- Because the endpoint id is automagically used in http paths and config property names and some parts of springs property handly code doesn't support underscores, we had to switch to dashes - The new spring boot version automatically collects *all* FlywayCallback Beans and adds them to the main Flyway instance. Since we want to isolate our flyway config, we had to make sure that our callbacks have a different class name. - The Spring Boot Flyway AutoConfiguration can be disabled. In this case no FlywayProperties will exist leading to an NPE in FlywayMigrator => Fixed - There seems to be no need any more to wrap the Actuator config in a @ManagementContextConfiguration - Added a seperate test module that uses the k8s way to configure access tokens. It can later be copy'n'pasted to test multiple permutation of optional dependencies - Deleted the deprecated Snapshot event provider, so that we don't carry deprecated interfaces into a new major release
…o nicely and gives us 16 Major Releases time before the Spring Boot 1.x release train overtakes the Spring Boot 2 one
d5f3c58
to
bcebbd2
Compare
👍 |
1 similar comment
👍 |
@RunWith(SpringRunner.class) | ||
@SpringBootTest( | ||
webEnvironment = SpringBootTest.WebEnvironment.MOCK, | ||
properties = { "zalando.team.id:alpha-local-testing", "nakadi-producer.scheduled-transmission-enabled:false", "spring.flyway.enabled:false"}, |
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.
"alpha-local-testing"
? 😃
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.
That was inherited from the previous project (tarbela-producer-spring-boot-starter), I guess.
Not sure where this team ID is used, though.
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.
Yeah, it's probably just a copy-paste mistake and it doesn't affect anything in fact.
Upgrading to Spring Boot 2, which will be a new major release
Fixes #81.