Skip to content

Commit

Permalink
feat: support incremental configuration synchronization client
Browse files Browse the repository at this point in the history
  • Loading branch information
jackie-coming committed Nov 28, 2024
1 parent a6a412a commit 07bb41c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class ConfigServiceWithChangeCache extends ConfigServiceWithCache {
private static final Logger logger = LoggerFactory.getLogger(ConfigServiceWithChangeCache.class);


private static final long DEFAULT_EXPIRED_AFTER_ACCESS_IN_SencondS = 10;
private static final long DEFAULT_EXPIRED_AFTER_ACCESS_IN_SENCONDS = 10;

private static final String TRACER_EVENT_CHANGE_CACHE_LOAD_KEY = "ConfigChangeCache.LoadFromDBbyKey";

Expand Down Expand Up @@ -83,7 +83,7 @@ public void initialize() {
private void buildReleaseCache() {

CacheBuilder releasesCacheBuilder = CacheBuilder.newBuilder()
.expireAfterAccess(DEFAULT_EXPIRED_AFTER_ACCESS_IN_SencondS, TimeUnit.SECONDS);
.expireAfterAccess(DEFAULT_EXPIRED_AFTER_ACCESS_IN_SENCONDS, TimeUnit.SECONDS);

releasesCache = releasesCacheBuilder.build(new CacheLoader<String, Optional<Release>>() {
@Override
Expand Down Expand Up @@ -113,21 +113,24 @@ public void handleMessage(ReleaseMessage message, String channel) {
message.getMessage())) {
return;
}

String messageKey = message.getMessage();
if (bizConfig.isConfigServiceCacheKeyIgnoreCase()) {
messageKey = messageKey.toLowerCase();
}
Transaction transaction = Tracer.newTransaction(TRACER_EVENT_CHANGE_CACHE_LOAD, messageKey);
try {
String messageKey = message.getMessage();
if (bizConfig.isConfigServiceCacheKeyIgnoreCase()) {
messageKey = messageKey.toLowerCase();
}
Tracer.newTransaction(TRACER_EVENT_CHANGE_CACHE_LOAD, messageKey);

List<String> namespaceInfo = ReleaseMessageKeyGenerator.messageToList(messageKey);
Release latestRelease = releaseService.findLatestActiveRelease(namespaceInfo.get(0),
namespaceInfo.get(1), namespaceInfo.get(2));

releasesCache.put(latestRelease.getReleaseKey(), Optional.ofNullable(latestRelease));

transaction.setStatus(Transaction.SUCCESS);
} catch (Throwable ex) {
transaction.setStatus(ex);
//ignore
} finally {
transaction.complete();
}
}

Expand Down
2 changes: 2 additions & 0 deletions changes/changes-2.4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Apollo 2.4.0
* [Feature support portal restTemplate Client connection pool config](https://github.com/apolloconfig/apollo/pull/5200)
* [Feature added the ability for administrators to globally search for Value](https://github.com/apolloconfig/apollo/pull/5182)
* [Feature support the observe status access-key for pre-check and logging only](https://github.com/apolloconfig/apollo/pull/5236)
* [Feature support incremental configuration synchronization client](https://github.com/apolloconfig/apollo/pull/5288)


------------------
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/15?closed=1)

0 comments on commit 07bb41c

Please sign in to comment.