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

Refresh the backend name in UI on every page refresh #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -84,6 +84,7 @@ public List<Backend> register(@RequestParam(value = "endpoint") String endpoint)
if ((newBackend = apiGateway.getFromRemote(endpointUrl)) != null) {
// TODO: BackendId should not be fetched from remote. For now I replace the remote one with the local one.
newBackend.setId(endpoint);

// Register the new backend
apiGateway.add(endpoint, endpointUrl);
dataGateway.add(endpoint, endpointUrl);
Expand Down Expand Up @@ -119,6 +120,15 @@ public List<Backend> unregister(@RequestParam(value = "endpointName") String end
@RequestMapping(method = RequestMethod.GET, value = "/list", produces = "application/json")
public List<Backend> getAll() {
logger.info("Backends: getAll");

// refresh backend metadata
for (String endpoint : registeredBackends.keySet()) {
Backend updatedBackend = apiGateway.getFromLocal(endpoint);
updatedBackend.setId(endpoint);
registeredBackends.put(endpoint, updatedBackend);
logger.info("Backend {} updated from server: ({}) ", endpoint, updatedBackend);
}

return new ArrayList<Backend>(registeredBackends.values());
}
}