diff options
author | jonmv <venstad@gmail.com> | 2022-05-02 13:56:29 +0200 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2022-05-02 13:56:29 +0200 |
commit | 0b950e98b688edb6d67773c8ff536ba8db4c35d9 (patch) | |
tree | b76ffcd64ca12f959fb01e2dc5524658ddd4ff62 /http-client | |
parent | 94589122f8da483788d1a69d3f0e2f919fb226ee (diff) |
Another utility method
Diffstat (limited to 'http-client')
-rw-r--r-- | http-client/src/main/java/ai/vespa/hosted/client/AbstractHttpClient.java | 4 | ||||
-rw-r--r-- | http-client/src/main/java/ai/vespa/hosted/client/HttpClient.java | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/http-client/src/main/java/ai/vespa/hosted/client/AbstractHttpClient.java b/http-client/src/main/java/ai/vespa/hosted/client/AbstractHttpClient.java index 6a76ef65082..ed3fee101ed 100644 --- a/http-client/src/main/java/ai/vespa/hosted/client/AbstractHttpClient.java +++ b/http-client/src/main/java/ai/vespa/hosted/client/AbstractHttpClient.java @@ -147,10 +147,10 @@ public abstract class AbstractHttpClient implements HttpClient { private final Method method; private final HostStrategy hosts; + private final List<Supplier<Query>> dynamicQuery = new ArrayList<>(); + private final Map<String, List<String>> headers = new LinkedHashMap<>(); private HttpURL.Path path = Path.empty(); private HttpURL.Query query = Query.empty(); - private List<Supplier<Query>> dynamicQuery = new ArrayList<>(); - private Map<String, List<String>> headers = new LinkedHashMap<>(); private Supplier<HttpEntity> entity = () -> null; private RequestConfig config = HttpClient.defaultRequestConfig; private ResponseVerifier verifier = HttpClient.throwOnError; diff --git a/http-client/src/main/java/ai/vespa/hosted/client/HttpClient.java b/http-client/src/main/java/ai/vespa/hosted/client/HttpClient.java index 16a419bf324..eeb9c353f64 100644 --- a/http-client/src/main/java/ai/vespa/hosted/client/HttpClient.java +++ b/http-client/src/main/java/ai/vespa/hosted/client/HttpClient.java @@ -249,6 +249,11 @@ public interface HttpClient extends Closeable { @FunctionalInterface interface HostStrategy extends Iterable<URI> { + /** Attempts the given host once. */ + static HostStrategy of(URI host) { + return repeating(host, 1); + } + /** Attempts each request once against each listed host. */ static HostStrategy ordered(List<URI> hosts) { return List.copyOf(hosts)::iterator; |