Repository navigation
feat: Add a Spring Boot starter that creates the client from the configuration of the application. - #14
Merged
Conversation
…hand out a client with options. Container wrapped a GenericContainer, so it did not work where frameworks expect a Testcontainers container, e.g. with @Serviceconnection in Spring Boot. It now extends GenericContainer, as the official modules of Testcontainers do. All of its methods keep their names and their behavior, including replacing a container whose database does not become reachable. It also works in a try-with-resources statement now. getClient(ClientOptions) hands out a client with options of the caller, so that tests can use the same data mapper as production. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hc2MPSLu7HDHTm8HiBsrDz
…iguration of the application. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hc2MPSLu7HDHTm8HiBsrDz
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hc2MPSLu7HDHTm8HiBsrDz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a third artifact,
io.thenativeweb:eventsourcingdb-spring-boot-starter, that sets up the client in Spring Boot 4 applications.It builds on #13, which made the test container a Testcontainers
GenericContainer, so that@ServiceConnectioncan use it.What the starter does
Clientbean fromeventsourcingdb.base-urlandeventsourcingdb.api-token. If one of them is not set (or empty), the application fails to start witheventsourcingdb.base-url must be setoreventsourcingdb.api-token must be set. There is no default URL.JsonMapper, the client uses it for the data of events, so the data follows the Jackson configuration of the application. Otherwise it uses a mapper of its own.Clientbean gets that one instead. It can injectEventSourcingDbConnectionDetailsto connect its client to the configured instance.@ServiceConnection: A test container bean annotated with@ServiceConnectionprovides the URL and the API token, so tests need no properties.Public types live in
io.thenativeweb.eventsourcingdb.springboot:EventSourcingDbAutoConfiguration,EventSourcingDbConnectionDetails(getBaseUrl(),getApiToken()) andEventSourcingDbProperties. The factory for@ServiceConnectionis package-private, as in Spring Boot itself.Dependencies
The starter brings
spring-boot-starter(as Spring requires of starters) and the client. It does not bring the test container orspring-boot-testcontainers(compileOnly). Applications add both to their tests anyway, to create the container.The
@ServiceConnectionfactory is registered inspring.factories, the way Spring's own modules (e.g.spring-boot-data-redis) register theirs:spring-boot-testcontainers: Spring Boot can not load the factory and skips it.Built against Spring Boot 4.1.1. The tests also pass against Spring Boot 4.0.8, so the README says "Spring Boot 4". Which Jackson versions the client supports is still an open question before publishing: Spring Boot pins Jackson to 3.1.x, while we build against 3.2.3.
Build
spring-configuration-metadata.json, so IDEs complete and explain the two properties. It reads@ConfigurationPropertieswithout claiming it. javac warns about that in the lint categoryprocessing, and-Werrorturns the warning into an error. As agreed, only that category is turned off, only for the main code of the starter. All other warnings stay errors.slf4j-nop, because Spring Boot refuses to start next to it while Logback is present. Alogback-test.xmlkeeps the output quiet instead.Tests
make qapasses (191 + 13 + 10 tests, 100% coverage in all three modules):ApplicationContextRunnertests: These run against a real container. They cover the properties, connection details of the application, an application-defined client, Spring'sJsonMapperversus the client's own mapper, closing with the context, and missing properties.@SpringBootTest: It wires the container through@ServiceConnection, exactly as the README describes.🤖 Generated with Claude Code
https://claude.ai/code/session_01Hc2MPSLu7HDHTm8HiBsrDz