-
Notifications
You must be signed in to change notification settings - Fork 212
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
[All jobs done] Spring Boot Cloud Config #1230
Open
lony2003
wants to merge
21
commits into
dapr:master
Choose a base branch
from
fangkehou-team:development-cloudconfig
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,584
−3
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f19a5f8
style(springboot autoconfigure): use a PROPERTY_PREFIX instead of har…
lony2003 2b4022b
feat(springboot cloudconfig): A new library that implement a backend …
lony2003 0850990
Merge branch 'master' into development-cloudconfig
lony2003 6879d56
style(springboot cloudconfig): update file header
lony2003 736aaa2
style(springboot cloudconfig): change code style to match checkstyle
lony2003 02e3bbf
Merge branch 'master' into development-cloudconfig
lony2003 6303b5a
feat(springboot cloudconfig): Implement Configuration Cloud Config Im…
lony2003 781fbc1
Merge branch 'master' into development-cloudconfig
lony2003 c8c1958
fix(springboot cloudconfig): Update version of dapr-spring-parent
lony2003 33f1821
feat(springboot cloudconfig): test cases for cloud config
lony2003 7bb170d
fix(springboot cloudconfig): Fix problems of PropertySourceLoader
lony2003 1de8f47
Merge branch 'master' into development-cloudconfig
lony2003 1239f14
feat(springboot cloudconfig): Change the behavior of Config Type
lony2003 51bbffc
test(springboot cloudconfig): Implemented integration test for secret…
lony2003 802d0ec
Merge branch 'master' into development-cloudconfig
lony2003 034baad
test(springboot cloudconfig): fix integration test for secret and con…
lony2003 661f11e
docs(springboot cloudconfig): Write examples and docs for springboot …
lony2003 b2090a5
style(springboot cloudconfig): Clean comments
lony2003 e92ae51
docs(springboot cloudconfig): Fix typo of import
lony2003 41c6110
Merge branch 'master' into development-cloudconfig
lony2003 841b2f8
Merge branch 'master' into development-cloudconfig
lony2003 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.dapr.spring</groupId> | ||
<artifactId>dapr-spring-parent</artifactId> | ||
<version>0.15.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>dapr-spring-cloudconfig</artifactId> | ||
<name>dapr-spring-cloudconfig</name> | ||
<description>Dapr Spring Cloud Config</description> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.dapr.spring</groupId> | ||
<artifactId>dapr-spring-boot-autoconfigure</artifactId> | ||
<version>${project.parent.version}</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.dapr.spring</groupId> | ||
<artifactId>dapr-spring-data</artifactId> | ||
<version>${project.parent.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.dapr.spring</groupId> | ||
<artifactId>dapr-spring-messaging</artifactId> | ||
<version>${project.parent.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.dapr.spring</groupId> | ||
<artifactId>dapr-spring-workflows</artifactId> | ||
<version>${project.parent.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.github.spotbugs</groupId> | ||
<artifactId>spotbugs-maven-plugin</artifactId> | ||
<version>4.8.2.0</version> | ||
<configuration> | ||
<excludeFilterFile>./spotbugs-exclude.xml</excludeFilterFile> | ||
<failOnError>${spotbugs.fail}</failOnError> | ||
<xmlOutput>true</xmlOutput> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>validate</id> | ||
<phase>validate</phase> | ||
<goals> | ||
<goal>check</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<FindBugsFilter> | ||
<Match> | ||
<Package name="~io\.dapr\.spring.*"/> | ||
<Bug pattern="EI_EXPOSE_REP"/> | ||
</Match> | ||
|
||
<Match> | ||
<Package name="~io\.dapr\.spring.*"/> | ||
<Bug pattern="EI_EXPOSE_REP2"/> | ||
</Match> | ||
<Match> | ||
<Class name="~io.dapr.spring.boot.cloudconfig.configdata.*"/> | ||
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/> | ||
</Match> | ||
<Match> | ||
<Class name="~io.dapr.spring.boot.cloudconfig.*"/> | ||
<Bug pattern="MS_EXPOSE_REP"/> | ||
</Match> | ||
</FindBugsFilter> |
29 changes: 29 additions & 0 deletions
29
.../java/io/dapr/spring/boot/cloudconfig/autoconfigure/DaprCloudConfigAutoConfiguration.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2025 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.spring.boot.cloudconfig.autoconfigure; | ||
|
||
import io.dapr.client.DaprClient; | ||
import io.dapr.spring.boot.cloudconfig.config.DaprCloudConfigProperties; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
@EnableConfigurationProperties(DaprCloudConfigProperties.class) | ||
@ConditionalOnProperty(name = DaprCloudConfigProperties.PROPERTY_PREFIX + ".enabled", matchIfMissing = true) | ||
@ConditionalOnClass(DaprClient.class) | ||
public class DaprCloudConfigAutoConfiguration { | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
...va/io/dapr/spring/boot/cloudconfig/config/CloudConfigPropertiesDaprConnectionDetails.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2025 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.spring.boot.cloudconfig.config; | ||
|
||
import io.dapr.spring.boot.autoconfigure.client.DaprClientProperties; | ||
import io.dapr.spring.boot.autoconfigure.client.DaprConnectionDetails; | ||
|
||
class CloudConfigPropertiesDaprConnectionDetails implements DaprConnectionDetails { | ||
|
||
private final DaprClientProperties daprClientProperties; | ||
|
||
public CloudConfigPropertiesDaprConnectionDetails(DaprClientProperties daprClientProperties) { | ||
this.daprClientProperties = daprClientProperties; | ||
} | ||
|
||
@Override | ||
public String httpEndpoint() { | ||
return this.daprClientProperties.getHttpEndpoint(); | ||
} | ||
|
||
@Override | ||
public String grpcEndpoint() { | ||
return this.daprClientProperties.getGrpcEndpoint(); | ||
} | ||
|
||
@Override | ||
public Integer httpPort() { | ||
return this.daprClientProperties.getHttpPort(); | ||
} | ||
|
||
@Override | ||
public Integer grpcPort() { | ||
return this.daprClientProperties.getGrpcPort(); | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
...ig/src/main/java/io/dapr/spring/boot/cloudconfig/config/DaprCloudConfigClientManager.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright 2025 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.spring.boot.cloudconfig.config; | ||
|
||
import io.dapr.client.DaprClient; | ||
import io.dapr.client.DaprClientBuilder; | ||
import io.dapr.client.DaprPreviewClient; | ||
import io.dapr.config.Properties; | ||
import io.dapr.spring.boot.autoconfigure.client.DaprClientProperties; | ||
import io.dapr.spring.boot.autoconfigure.client.DaprConnectionDetails; | ||
|
||
public class DaprCloudConfigClientManager { | ||
|
||
private static DaprClient daprClient; | ||
private static DaprPreviewClient daprPreviewClient; | ||
private final DaprCloudConfigProperties daprCloudConfigProperties; | ||
private final DaprClientProperties daprClientConfig; | ||
|
||
/** | ||
* Create a DaprCloudConfigClientManager to create Config-Specific Dapr Client. | ||
* | ||
* @param daprCloudConfigProperties Properties of Dapr Cloud Config | ||
* @param daprClientConfig Properties of Dapr Client | ||
*/ | ||
public DaprCloudConfigClientManager(DaprCloudConfigProperties daprCloudConfigProperties, | ||
DaprClientProperties daprClientConfig) { | ||
this.daprCloudConfigProperties = daprCloudConfigProperties; | ||
this.daprClientConfig = daprClientConfig; | ||
|
||
DaprClientBuilder daprClientBuilder = createDaprClientBuilder( | ||
createDaprConnectionDetails(daprClientConfig) | ||
); | ||
|
||
if (DaprCloudConfigClientManager.daprClient == null) { | ||
DaprCloudConfigClientManager.daprClient = daprClientBuilder.build(); | ||
} | ||
|
||
if (DaprCloudConfigClientManager.daprPreviewClient == null) { | ||
DaprCloudConfigClientManager.daprPreviewClient = daprClientBuilder.buildPreviewClient(); | ||
} | ||
} | ||
|
||
public static DaprPreviewClient getDaprPreviewClient() { | ||
return DaprCloudConfigClientManager.daprPreviewClient; | ||
} | ||
|
||
public static DaprClient getDaprClient() { | ||
return DaprCloudConfigClientManager.daprClient; | ||
} | ||
|
||
private DaprConnectionDetails createDaprConnectionDetails(DaprClientProperties properties) { | ||
return new CloudConfigPropertiesDaprConnectionDetails(properties); | ||
} | ||
|
||
DaprClientBuilder createDaprClientBuilder(DaprConnectionDetails daprConnectionDetails) { | ||
DaprClientBuilder builder = new DaprClientBuilder(); | ||
if (daprConnectionDetails.httpEndpoint() != null) { | ||
builder.withPropertyOverride(Properties.HTTP_ENDPOINT, daprConnectionDetails.httpEndpoint()); | ||
} | ||
if (daprConnectionDetails.grpcEndpoint() != null) { | ||
builder.withPropertyOverride(Properties.GRPC_ENDPOINT, daprConnectionDetails.grpcEndpoint()); | ||
} | ||
if (daprConnectionDetails.httpPort() != null) { | ||
builder.withPropertyOverride(Properties.HTTP_PORT, String.valueOf(daprConnectionDetails.httpPort())); | ||
} | ||
if (daprConnectionDetails.grpcPort() != null) { | ||
builder.withPropertyOverride(Properties.GRPC_PORT, String.valueOf(daprConnectionDetails.grpcPort())); | ||
} | ||
return builder; | ||
} | ||
|
||
public DaprCloudConfigProperties getDaprCloudConfigProperties() { | ||
return daprCloudConfigProperties; | ||
} | ||
|
||
public DaprClientProperties getDaprClientConfig() { | ||
return daprClientConfig; | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...onfig/src/main/java/io/dapr/spring/boot/cloudconfig/config/DaprCloudConfigProperties.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright 2025 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.spring.boot.cloudconfig.config; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
/** | ||
* The properties for creating dapr client. | ||
*/ | ||
@ConfigurationProperties(DaprCloudConfigProperties.PROPERTY_PREFIX) | ||
public class DaprCloudConfigProperties { | ||
lony2003 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public static final String PROPERTY_PREFIX = "dapr.cloudconfig"; | ||
|
||
/** | ||
* whether enable cloud config. | ||
*/ | ||
private Boolean enabled = true; | ||
|
||
/** | ||
* whether enable dapr client wait for sidecar, if no response, will throw IOException. | ||
*/ | ||
private Boolean waitSidecarEnabled = false; | ||
|
||
/** | ||
* retries of dapr client wait for sidecar. | ||
*/ | ||
private Integer waitSidecarRetries = 3; | ||
|
||
/** | ||
* get config timeout (include wait for dapr sidecar). | ||
*/ | ||
private Integer timeout = 2000; | ||
|
||
public Integer getTimeout() { | ||
return timeout; | ||
} | ||
|
||
public void setTimeout(Integer timeout) { | ||
this.timeout = timeout; | ||
} | ||
|
||
public Boolean getEnabled() { | ||
return enabled; | ||
} | ||
|
||
public void setEnabled(Boolean enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
public Boolean getWaitSidecarEnabled() { | ||
return waitSidecarEnabled; | ||
} | ||
|
||
public void setWaitSidecarEnabled(Boolean waitSidecarEnabled) { | ||
this.waitSidecarEnabled = waitSidecarEnabled; | ||
} | ||
|
||
public Integer getWaitSidecarRetries() { | ||
return waitSidecarRetries; | ||
} | ||
|
||
public void setWaitSidecarRetries(Integer waitSidecarRetries) { | ||
this.waitSidecarRetries = waitSidecarRetries; | ||
} | ||
} |
Oops, something went wrong.
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.
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.
@lony2003 do we need to duplicate the DaprConnectionDetails, why are these different for the normal 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.
No difference, just because the PropertyDaprConnectionDetails is protected and can't be used in another package.
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 should we change the
PropertyDaprConnectionDetails
visibility so it can be reused?