Skip to content

Commit

Permalink
pass in the okHttpClient to updater
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Graff committed Nov 21, 2017
1 parent 26241c4 commit f46bfb2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public class BackendUpdater {
// is likely safe enough.
private boolean succeededAtLeastOnce = false;

public boolean run(RetrofitClientFactory retrofitClientFactory, ObjectMapper objectMapper) {
OkHttpClient okHttpClient = new OkHttpClient();
public boolean run(RetrofitClientFactory retrofitClientFactory, ObjectMapper objectMapper, OkHttpClient okHttpClient) {
RemoteService remoteService = new RemoteService();
remoteService.setBaseUrl(uri);
BackendsRemoteService backendsRemoteService = retrofitClientFactory.createClient(BackendsRemoteService.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.kayenta.retrofit.config.RetrofitClientFactory;
import com.squareup.okhttp.OkHttpClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
Expand All @@ -25,6 +26,9 @@ public class BackendUpdaterService extends AbstractHealthIndicator {
@Autowired
private ObjectMapper objectMapper;

@Autowired
private OkHttpClient okHttpClient;

private final List<BackendUpdater> backendUpdaters = new ArrayList<>();
private int checksCompleted = 0;

Expand All @@ -36,7 +40,7 @@ public synchronized void run() {
// TODO: Although, for healthcheck, it may...
int checks = 0;
for (BackendUpdater updater: backendUpdaters) {
Boolean result = updater.run(retrofitClientFactory, objectMapper);
Boolean result = updater.run(retrofitClientFactory, objectMapper, okHttpClient);
if (result)
checks++;
}
Expand Down

0 comments on commit f46bfb2

Please sign in to comment.