Skip to content
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

Support for Targeted Property Refresh in /actuator/refresh Endpoint #1371

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ protected RefreshScope getScope() {
return this.scope;
}

public synchronized Set<String> refresh() {
Set<String> keys = refreshEnvironment();
this.scope.refreshAll();
return keys;
public Set<String> refresh(Set<String> propertiesToRefresh, RefreshStrategy strategy) {
return strategy.refresh(this, propertiesToRefresh);
}

public synchronized Set<String> refreshSpecificEnvironment(Set<String> propertiesToRefresh){
//TODO: Implement this.
return propertiesToRefresh;
}

public synchronized Set<String> refreshEnvironment() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.springframework.cloud.context.refresh;

import java.util.Set;

public class RefreshAllStrategy implements RefreshStrategy {
@Override
public Set<String> refresh(ContextRefresher contextRefresher, Set<String> propertiesToRefresh) {
return contextRefresher.refreshEnvironment();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.springframework.cloud.context.refresh;

import java.util.Set;

public class RefreshSpecificPropertiesStrategy implements RefreshStrategy {
@Override
public Set<String> refresh(ContextRefresher contextRefresher, Set<String> propertiesToRefresh) {
return contextRefresher.refreshSpecificEnvironment(propertiesToRefresh);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.springframework.cloud.context.refresh;

import java.util.Set;

public interface RefreshStrategy {
Set<String> refresh(ContextRefresher contextRefresher, Set<String> propertiesToRefresh);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ public RefreshEndpoint(ContextRefresher contextRefresher) {
}

@WriteOperation
public Collection<String> refresh() {
Set<String> keys = this.contextRefresher.refresh();
public Collection<String> refresh(Set<String> propertiesToRefresh) {
RefreshStrategy strategy = (propertiesToRefresh != null && !propertiesToRefresh.isEmpty())
? new RefreshSpecificPropertiesStrategy()
: new RefreshAllStrategy();
Set<String> keys = this.contextRefresher.refresh(propertiesToRefresh, strategy);
LOG.info("Refreshed keys : " + keys);
return keys;
}
Expand Down