aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-feed-client
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2021-06-25 15:57:20 +0200
committerJon Marius Venstad <venstad@gmail.com>2021-06-25 15:57:20 +0200
commitbc50ba75be522ac5edbca6ef2d630d0f72ae7b2e (patch)
tree725fae5b17802706f4b00417e77f0b56add3f678 /vespa-feed-client
parent360ece7a86f3dad99240b5d2da9428c15c2c175e (diff)
Add interface that was moved up
Diffstat (limited to 'vespa-feed-client')
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/Throttler.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/Throttler.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/Throttler.java
new file mode 100644
index 00000000000..fa1660d99e6
--- /dev/null
+++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/Throttler.java
@@ -0,0 +1,33 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.feed.client;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Determines the number of requests to have inflight at any point.
+ *
+ * @author jonmv
+ */
+interface Throttler {
+
+ /**
+ * A request was just sent with {@code vessel}, with {@code inflight} total in flight.
+ */
+ void sent(long inflight, CompletableFuture<HttpResponse> vessel);
+
+ /**
+ * A successful response was obtained.
+ */
+ void success();
+
+ /**
+ * A throttle signal was obtained from the server.
+ */
+ void throttled(long inflight);
+
+ /**
+ * The target inflight operations right now.
+ */
+ long targetInflight();
+
+}