-
Notifications
You must be signed in to change notification settings - Fork 207
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
Adding @ServiceConnection spring boot support with Testcontainers #1118
Conversation
8d23d1a
to
13673ab
Compare
1850c5b
to
b6bd2ee
Compare
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.
Just leaving some suggestions and improvements
.../src/main/java/io/dapr/spring/boot/autoconfigure/client/PropertiesDaprConnectionDetails.java
Outdated
Show resolved
Hide resolved
...gure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientAutoConfiguration.java
Outdated
Show resolved
Hide resolved
...oot-tests/src/main/java/io/dapr/spring/boot/tests/DaprContainerConnectionDetailsFactory.java
Outdated
Show resolved
Hide resolved
...oot-tests/src/main/java/io/dapr/spring/boot/tests/DaprContainerConnectionDetailsFactory.java
Outdated
Show resolved
Hide resolved
1307148
to
cbced54
Compare
sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java
Outdated
Show resolved
Hide resolved
dapr-spring/dapr-spring-boot-tests/src/main/resources/META-INF/spring.factories
Outdated
Show resolved
Hide resolved
@salaboy could you please rebase your PR. Thank you! |
7867cc6
to
2e1eb11
Compare
a3cf5ec
to
c85cd22
Compare
@artursouza @cicoyle this is the last PR to get the Documentation working with an example. Please review and I am happy to have a call if you want to make the review faster. |
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.
@salaboy awesome job! I have left a few tiny comments, mostly for renaming and cleanup.
package io.dapr.spring.boot.autoconfigure.client; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
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.
Just a small question, should we use the old Java style Java Beans or should we recommend users to go with Java records
?
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.
both should be fine right?
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.
IMO, I would go with java beans in order to add javadoc and could generate the metadata, the configuration processor is already in the classpath. See https://docs.spring.io/spring-boot/specification/configuration-metadata/annotation-processor.html
|
||
public class DaprContainerConnectionDetailsFactory | ||
extends ContainerConnectionDetailsFactory<DaprContainer, DaprConnectionDetails> { | ||
|
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.
I don't think this constructor provides any value
import io.dapr.testcontainers.DaprContainer; | ||
import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactory; | ||
import org.springframework.boot.testcontainers.service.connection.ContainerConnectionSource; | ||
|
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.
We could rename this to DaprConnectionDetailsFactory
so it is similar to other connection details factory like Redis, Mongo, Kafka, etc
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.
@artur-ciocanu I am following testcontainers conventions as the connectiondetails for this will be extracted from the DaprContainer
protected DaprConnectionDetails getContainerConnectionDetails(ContainerConnectionSource<DaprContainer> source) { | ||
return new DaprContainerConnectionDetails(source); | ||
} | ||
|
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 rename this to DefaultDaprConnectionDetails
, DaprContainer
seems redundant. We want to connect to Dapr, irrespective where it is running, container or not.
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 naming convention comes from this: DaprContainer paramter
@@ -93,6 +95,8 @@ public class MySQLDaprKeyValueTemplateIT { | |||
static void daprProperties(DynamicPropertyRegistry registry) { |
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.
We should remove the daprProperties
method, we are using @ServiceConnection
691d852
to
697c471
Compare
package io.dapr.spring.boot.autoconfigure.client; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
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.
IMO, I would go with java beans in order to add javadoc and could generate the metadata, the configuration processor is already in the classpath. See https://docs.spring.io/spring-boot/specification/configuration-metadata/annotation-processor.html
dapr-spring/dapr-spring-boot-starters/dapr-spring-boot-starter-test/pom.xml
Outdated
Show resolved
Hide resolved
...apr/spring/boot/testcontainers/service/connection/DaprContainerConnectionDetailsFactory.java
Show resolved
Hide resolved
9f130eb
to
73a1f55
Compare
...toconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientProperties.java
Show resolved
Hide resolved
@salaboy I have added a small comment, the issue with the build that you have faced is related to
Let me know your thoughts. |
Signed-off-by: salaboy <Salaboy@gmail.com>
Signed-off-by: salaboy <Salaboy@gmail.com>
Signed-off-by: salaboy <Salaboy@gmail.com>
…pr/spring/boot/autoconfigure/client/DaprClientAutoConfiguration.java Co-authored-by: Eddú Meléndez Gonzales <eddu.melendez@gmail.com> Signed-off-by: salaboy <Salaboy@gmail.com>
…pr/spring/boot/autoconfigure/client/PropertiesDaprConnectionDetails.java Co-authored-by: Eddú Meléndez Gonzales <eddu.melendez@gmail.com> Signed-off-by: salaboy <Salaboy@gmail.com>
Signed-off-by: salaboy <Salaboy@gmail.com>
Signed-off-by: salaboy <Salaboy@gmail.com>
Signed-off-by: salaboy <Salaboy@gmail.com>
Signed-off-by: salaboy <Salaboy@gmail.com>
Signed-off-by: salaboy <Salaboy@gmail.com>
Signed-off-by: salaboy <Salaboy@gmail.com>
Signed-off-by: salaboy <Salaboy@gmail.com>
Signed-off-by: salaboy <Salaboy@gmail.com>
Signed-off-by: salaboy <Salaboy@gmail.com>
Signed-off-by: salaboy <Salaboy@gmail.com>
Signed-off-by: salaboy <Salaboy@gmail.com>
Signed-off-by: salaboy <Salaboy@gmail.com>
a1247d0
to
82eb498
Compare
This is solved now |
Description
This PR implements the Testcontainers @Serviceconnection to simplify how applications can connect to DaprContainers.
This PR also aligns Spring Boot dependencies to reduce the amount of dependencies that users need to add to their projects.
Issue reference
Fixes: #1117
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: