Skip to content

Conversation

aaaandychen
Copy link
Collaborator

support ApolloDynamicConfigService and implement CRUD operations for configs

What type of PR is this?

Feature

What this PR does / why we need it?

Describe it.

Which issue(s) this PR fixes?

Fixes #1806

Does this PR introduce a user-facing change?

No

Checklist

  • Make sure there is a GitHub_issue related with this PR before you start working on it.
  • Make sure you have squashed your change to one single commit.
  • GitHub Actions works fine in this PR.

@aaaandychen aaaandychen force-pushed the apollo-dynamic-config branch 3 times, most recently from d1bf2ba to 1b14006 Compare September 15, 2025 06:07
@@ -0,0 +1,54 @@
package io.sermant.implement.service.dynamicconfig.apollo.config;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add copyright for any new files

Comment on lines 43 to 67
if ("app.id".equals(name)) {
val = getAppId();
return StringUtils.isNoneBlank(val) ? val : defaultValue;
} else if ("apollo.access-key.secret".equals(name)) {
val = getAccessKeySecret();
return StringUtils.isNoneBlank(val) ? val : defaultValue;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constant string can be extracted

Comment on lines 33 to 52
if ("apollo.cluster".equals(name)) {
String c = ApolloProperty.getCluster();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constant string

* @since 2025/8/7
*/
public class ApolloBufferedClient implements Closeable {
private static final Logger LOGGER = LoggerFactory.getLogger(ApolloBufferedClient.class.getName());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use java util logging logger

} catch (ApolloOpenApiException e) {
if (e.getCause() instanceof ApolloOpenApiException) {
ApolloOpenApiException apolloException = (ApolloOpenApiException) e.getCause();
if (apolloException.getStatus() == 400 || apolloException.getStatus() == 409) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

define error code or use exists constant code

connection.setReadTimeout(ApolloProperty.getReadTimeout());

int responseCode = connection.getResponseCode();
return responseCode >= 200 && responseCode < 300;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

define response code or use exists constant code


private final ServiceMeta serviceMeta;

private final Map<String, List<ConfigChangeListener>> groupListeners = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ConcurrentHashMap to avoid multi thread problems

Comment on lines +38 to +65
public ApolloDynamicConfigService() {
serviceMeta = ConfigManager.getConfig(ServiceMeta.class);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add success logs for operations in methods below

Comment on lines +20 to +44
/**
* Check whether the group name is valid
* 1. supports only English and digit characters and three special symbols ('.','-','_')
* 2. not supports single "." or "/", and it cannot end with ".json", ".yml", ".yaml",
* ".xml", or ".properties".
*
* @param namespace group name
* @return true: valid; false: invalid
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remember introduce rules in docs on Sermant website

@lilai23
Copy link
Collaborator

lilai23 commented Sep 15, 2025

Copy link

codecov bot commented Sep 29, 2025

Codecov Report

❌ Patch coverage is 53.70370% with 175 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ent/service/dynamicconfig/apollo/ApolloClient.java 50.00% 67 Missing and 6 partials ⚠️
...namicconfig/apollo/ApolloDynamicConfigService.java 67.39% 26 Missing and 19 partials ⚠️
...onfig/apollo/config/ApolloApplicationProvider.java 0.00% 17 Missing ⚠️
...micconfig/apollo/config/ApolloProviderManager.java 0.00% 11 Missing ⚠️
...amicconfig/apollo/config/ApolloServerProvider.java 0.00% 9 Missing ⚠️
...java/io/sermant/backend/service/ConfigService.java 0.00% 5 Missing ⚠️
...ment/service/dynamicconfig/apollo/ApolloUtils.java 50.00% 2 Missing and 2 partials ⚠️
...config/apollo/config/ApolloMetaServerProvider.java 0.00% 4 Missing ⚠️
...ce/dynamicconfig/apollo/config/ApolloProperty.java 82.60% 4 Missing ⚠️
...ce/dynamicconfig/BufferedDynamicConfigService.java 0.00% 2 Missing ⚠️
... and 1 more
Flag Coverage Δ Complexity Δ
unittests 27.72% <53.70%> (?) 375.00 <0.00> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ Complexity Δ
...ice/dynamicconfig/apollo/ApolloBufferedClient.java 100.00% <100.00%> (ø) 0.00 <0.00> (?)
...dynamicconfig/common/DynamicConfigServiceType.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...ce/dynamicconfig/BufferedDynamicConfigService.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...ment/service/dynamicconfig/apollo/ApolloUtils.java 50.00% <50.00%> (ø) 0.00 <0.00> (?)
...config/apollo/config/ApolloMetaServerProvider.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...ce/dynamicconfig/apollo/config/ApolloProperty.java 82.60% <82.60%> (ø) 0.00 <0.00> (?)
...java/io/sermant/backend/service/ConfigService.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...amicconfig/apollo/config/ApolloServerProvider.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...micconfig/apollo/config/ApolloProviderManager.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...onfig/apollo/config/ApolloApplicationProvider.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
... and 2 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Surpports apollo config center
2 participants